[#2555] [#2601] Bugfixes + version 1.1
[auf_recipe_django.git] / auf / recipe / django / recipe.py
1 # -*- encoding: utf-8 -*-
2
3 import os
4 import shutil
5 import pkg_resources
6 import djangorecipe
7 import zc.buildout
8 from djangorecipe.boilerplate import versions
9 from djangorecipe.recipe import Recipe as OriginalDjangoRecipe
10 from boilerplate import *
11
12 djangorecipe.boilerplate.versions['1.3']['settings'] = auf_settings_template
13 djangorecipe.boilerplate.versions['1.3']['urls'] = auf_urls_template
14 djangorecipe.boilerplate.versions['1.3']['production_settings'] = auf_production_settings
15 djangorecipe.boilerplate.versions['1.3']['development_settings'] = auf_development_settings
16
17
18 class Recipe(OriginalDjangoRecipe):
19
20 def install(self):
21 """
22 """
23 location = self.options['location']
24 base_dir = self.buildout['buildout']['directory']
25 self.options['project_name'] = os.path.basename(base_dir)
26
27 project_dir = os.path.join(base_dir, self.options['project'])
28
29 extra_paths = self.get_extra_paths()
30 requirements, ws = self.egg.working_set(['auf.recipe.django'])
31
32 script_paths = []
33
34 # Create the Django management script
35 script_paths.extend(self.create_manage_script(extra_paths, ws))
36
37 # Create the test runner
38 script_paths.extend(self.create_test_runner(extra_paths, ws))
39
40 # Make the wsgi and fastcgi scripts if enabled
41 script_paths.extend(self.make_scripts(extra_paths, ws))
42
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)
48 else:
49 self.log.info(
50 'Skipping creating of project: %(project)s since '
51 'it exists' % self.options)
52
53 return script_paths + [location]
54
55 def create_project(self, project_dir):
56 super(Recipe, self).create_project(project_dir)
57
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)
62
63 def create_manage_script(self, extra_paths, ws):
64 project = self.options.get('projectegg', self.options['project'])
65 return zc.buildout.easy_install.scripts(
66 [(self.options.get('control-script', self.name),
67 'auf.recipe.django.manage', 'main')],
68 ws, self.options['executable'], self.options['bin-directory'],
69 extra_paths=extra_paths,
70 arguments="'%s.%s'" % (project,
71 self.options['settings']))