1 # -*- encoding: utf-8 -*-
5 from djangorecipe
.recipe
import Recipe
as OriginalDjangoRecipe
6 from boilerplate
import auf_buildout_file
, auf_script_template
9 class Recipe(OriginalDjangoRecipe
):
14 location
= self
.options
['location']
15 base_dir
= self
.buildout
['buildout']['directory']
16 self
.options
['project_name'] = os
.path
.basename(base_dir
)
18 project_dir
= os
.path
.join(base_dir
, self
.options
['project'])
20 extra_paths
= self
.get_extra_paths()
21 requirements
, ws
= self
.egg
.working_set(['auf.recipe.django'])
25 # Create the Django management script
26 script_paths
.extend(self
.create_manage_script(extra_paths
, ws
))
28 # Create the test runner
29 script_paths
.extend(self
.create_test_runner(extra_paths
, ws
))
31 # Make the wsgi and fastcgi scripts if enabled
32 script_paths
.extend(self
.make_scripts(extra_paths
, ws
))
34 # Create default settings if we haven't got a project
35 # egg specified, and if it doesn't already exist
36 if not self
.options
.get('projectegg'):
37 if not os
.path
.exists(project_dir
):
38 self
.create_project(project_dir
)
41 'Skipping creating of project: %(project)s since '
42 'it exists' % self
.options
)
44 return script_paths
+ [location
]
46 def create_manage_script(self
, extra_paths
, ws
):
47 _script_template
= zc
.buildout
.easy_install
.script_template
48 zc
.buildout
.easy_install
.script_template
= auf_buildout_file
49 project
= self
.options
.get('projectegg', self
.options
['project'])
50 scripts
= zc
.buildout
.easy_install
.scripts(
51 [(self
.options
.get('control-script', self
.name
),
52 'auf.recipe.django.manage', 'main')],
53 ws
, self
.options
['executable'], self
.options
['bin-directory'],
54 extra_paths
=extra_paths
,
55 arguments
="'%s.%s'" % (project
,
56 self
.options
['settings']))
57 zc
.buildout
.easy_install
.script_template
= _script_template
60 def make_scripts(self
, extra_paths
, ws
):
62 _script_template
= zc
.buildout
.easy_install
.script_template
63 for protocol
in ('wsgi', 'fcgi'):
64 zc
.buildout
.easy_install
.script_template
= \
65 zc
.buildout
.easy_install
.script_header
+ \
66 auf_script_template
[protocol
]
67 if self
.options
.get(protocol
, '').lower() == 'true':
68 project
= self
.options
.get('projectegg',
69 self
.options
['project'])
71 zc
.buildout
.easy_install
.scripts(
72 [('%s.%s' % (self
.options
.get('control-script',
75 'djangorecipe.%s' % protocol
, 'main')],
77 self
.options
['executable'],
78 self
.options
['bin-directory'],
79 extra_paths
=extra_paths
,
80 arguments
="'%s.%s', logfile='%s'" % (
81 project
, self
.options
['settings'],
82 self
.options
.get('logfile')),
83 initialization
=self
.options
.get(
87 zc
.buildout
.easy_install
.script_template
= _script_template