1 # -*- encoding: utf-8 -*-
8 from djangorecipe
.boilerplate
import versions
9 from djangorecipe
.recipe
import Recipe
as OriginalDjangoRecipe
10 from boilerplate
import *
12 djangorecipe
.boilerplate
.versions
['1.2']['settings'] = auf_settings_template
13 djangorecipe
.boilerplate
.versions
['1.2']['urls'] = auf_urls_template
14 djangorecipe
.boilerplate
.versions
['1.2']['production_settings'] = auf_production_settings
15 djangorecipe
.boilerplate
.versions
['1.2']['development_settings'] = auf_development_settings
18 class Recipe(OriginalDjangoRecipe
):
23 location
= self
.options
['location']
24 base_dir
= self
.buildout
['buildout']['directory']
25 self
.options
['project_name'] = os
.path
.basename(base_dir
)
27 project_dir
= os
.path
.join(base_dir
, self
.options
['project'])
29 extra_paths
= self
.get_extra_paths()
30 requirements
, ws
= self
.egg
.working_set(['djangorecipe'])
34 # Create the Django management script
35 script_paths
.extend(self
.create_manage_script(extra_paths
, ws
))
37 # Create the test runner
38 script_paths
.extend(self
.create_test_runner(extra_paths
, ws
))
40 # Make the wsgi and fastcgi scripts if enabled
41 script_paths
.extend(self
.make_scripts(extra_paths
, ws
))
43 # Create default settings if we haven't got a project
44 # egg specified, and if it doesn't already exist
45 if not self
.options
.get('projectegg'):
46 if not os
.path
.exists(project_dir
):
47 self
.create_project(project_dir
)
50 'Skipping creating of project: %(project)s since '
51 'it exists' % self
.options
)
53 return script_paths
+ [location
]
55 def create_project(self
, project_dir
):
56 super(Recipe
, self
).create_project(project_dir
)
58 # fichier de configuration de base de données
59 self
.create_file(os
.path
.join(project_dir
, 'conf.py'), conf_file
, self
.options
)
60 self
.create_file(os
.path
.join(project_dir
, 'conf.py.edit'), conf_file
, self
.options
)
61 self
.create_file(os
.path
.join(project_dir
, 'dashboard.py'), dashboard_file
, self
.options
)
63 os
.mkdir(os
.path
.join(project_dir
, 'media', 'css'))
64 os
.mkdir(os
.path
.join(project_dir
, 'media', 'images'))
65 os
.mkdir(os
.path
.join(project_dir
, 'media', 'js'))
67 # copie des medias django-admin-tools
68 requirements
, ws
= self
.egg
.working_set(['djangorecipe'])
69 req
= pkg_resources
.Requirement
.parse('django-admin-tools')
70 src
= os
.path
.join(ws
.find(req
).location
, 'admin_tools', 'media', 'admin_tools')
71 dst
= os
.path
.join(project_dir
, 'media', 'admin_tools')
72 shutil
.copytree(src
, dst
)
74 # copier les medias de auf.django.skin
75 req
= pkg_resources
.Requirement
.parse('auf.django.skin')
76 src
= os
.path
.join(ws
.find(req
).location
, 'auf', 'django', 'skin', 'media', 'skin')
77 dst
= os
.path
.join(project_dir
, 'media', 'skin')
78 shutil
.copytree(src
, dst
)
80 # copier les medias de Django
81 req
= pkg_resources
.Requirement
.parse('django')
82 src
= os
.path
.join(ws
.find(req
).location
, 'django', 'contrib', 'admin', 'media')
83 dst
= os
.path
.join(project_dir
, 'media', 'django')
84 shutil
.copytree(src
, dst
)
86 def create_manage_script(self
, extra_paths
, ws
):
87 project
= self
.options
.get('projectegg', self
.options
['project'])
88 return zc
.buildout
.easy_install
.scripts(
89 [(self
.options
.get('control-script', self
.name
),
90 'auf.recipe.django.manage', 'main')],
91 ws
, self
.options
['executable'], self
.options
['bin-directory'],
92 extra_paths
=extra_paths
,
93 arguments
="'%s.%s'" % (project
,
94 self
.options
['settings']))