1 # -*- encoding: utf-8 -*-
7 from djangorecipe
.boilerplate
import versions
8 from djangorecipe
.recipe
import Recipe
as OriginalDjangoRecipe
9 from boilerplate
import *
11 djangorecipe
.boilerplate
.versions
['1.3']['settings'] = auf_settings_template
12 djangorecipe
.boilerplate
.versions
['1.3']['urls'] = auf_urls_template
13 djangorecipe
.boilerplate
.versions
['1.3']['production_settings'] = auf_production_settings
14 djangorecipe
.boilerplate
.versions
['1.3']['development_settings'] = auf_development_settings
17 class Recipe(OriginalDjangoRecipe
):
22 location
= self
.options
['location']
23 base_dir
= self
.buildout
['buildout']['directory']
24 self
.options
['project_name'] = os
.path
.basename(base_dir
)
26 project_dir
= os
.path
.join(base_dir
, self
.options
['project'])
28 extra_paths
= self
.get_extra_paths()
29 requirements
, ws
= self
.egg
.working_set(['auf.recipe.django'])
33 # Create the Django management script
34 script_paths
.extend(self
.create_manage_script(extra_paths
, ws
))
36 # Create the test runner
37 script_paths
.extend(self
.create_test_runner(extra_paths
, ws
))
39 # Make the wsgi and fastcgi scripts if enabled
40 script_paths
.extend(self
.make_scripts(extra_paths
, ws
))
42 # Create default settings if we haven't got a project
43 # egg specified, and if it doesn't already exist
44 if not self
.options
.get('projectegg'):
45 if not os
.path
.exists(project_dir
):
46 self
.create_project(project_dir
)
49 'Skipping creating of project: %(project)s since '
50 'it exists' % self
.options
)
52 return script_paths
+ [location
]
54 def create_project(self
, project_dir
):
55 super(Recipe
, self
).create_project(project_dir
)
57 # fichier de configuration de base de données
58 self
.create_file(os
.path
.join(project_dir
, 'conf.py'), conf_file
, self
.options
)
59 self
.create_file(os
.path
.join(project_dir
, 'conf.py.edit'), conf_file
, self
.options
)
60 self
.create_file(os
.path
.join(project_dir
, 'dashboard.py'), dashboard_file
, self
.options
)
62 def create_manage_script(self
, extra_paths
, ws
):
63 _script_template
= zc
.buildout
.easy_install
.script_template
64 zc
.buildout
.easy_install
.script_template
= auf_buildout_file
65 project
= self
.options
.get('projectegg', self
.options
['project'])
66 scripts
= zc
.buildout
.easy_install
.scripts(
67 [(self
.options
.get('control-script', self
.name
),
68 'auf.recipe.django.manage', 'main')],
69 ws
, self
.options
['executable'], self
.options
['bin-directory'],
70 extra_paths
=extra_paths
,
71 arguments
="'%s.%s'" % (project
,
72 self
.options
['settings']))
73 zc
.buildout
.easy_install
.script_template
= _script_template
76 def make_scripts(self
, extra_paths
, ws
):
78 _script_template
= zc
.buildout
.easy_install
.script_template
79 for protocol
in ('wsgi', 'fcgi'):
80 zc
.buildout
.easy_install
.script_template
= \
81 zc
.buildout
.easy_install
.script_header
+ \
82 auf_script_template
[protocol
]
83 if self
.options
.get(protocol
, '').lower() == 'true':
84 project
= self
.options
.get('projectegg',
85 self
.options
['project'])
87 zc
.buildout
.easy_install
.scripts(
88 [('%s.%s' % (self
.options
.get('control-script',
91 'djangorecipe.%s' % protocol
, 'main')],
93 self
.options
['executable'],
94 self
.options
['bin-directory'],
95 extra_paths
=extra_paths
,
96 arguments
="'%s.%s', logfile='%s'" % (
97 project
, self
.options
['settings'],
98 self
.options
.get('logfile'))))
99 zc
.buildout
.easy_install
.script_template
= _script_template