From 7b0d690239d23b90ea8421f0eebd3dbd42e98aa9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Larchev=C3=AAque?= Date: Wed, 11 Jul 2012 10:07:57 -0400 Subject: [PATCH] v2.0 : plus de squelette projet --- CHANGES | 7 ++ auf/recipe/django/boilerplate.py | 176 -------------------------------------- auf/recipe/django/recipe.py | 22 +---- setup.py | 8 +- 4 files changed, 14 insertions(+), 199 deletions(-) diff --git a/CHANGES b/CHANGES index dc4324e..4e07309 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +2.0 +=== + +* la recette ne sert plus à construire le squelette du module "projet". + +* PEP8 + 1.7 === diff --git a/auf/recipe/django/boilerplate.py b/auf/recipe/django/boilerplate.py index 14f4f10..ed07087 100644 --- a/auf/recipe/django/boilerplate.py +++ b/auf/recipe/django/boilerplate.py @@ -2,7 +2,6 @@ import zc.buildout.easy_install - env = ''' %(relative_paths_setup)s import sys @@ -35,178 +34,3 @@ application = %(module_name)s.%(attrs)s(%(arguments)s) %(module_name)s.%(attrs)s(%(arguments)s) """, } - - -################################################################################ -# SETTINGS -################################################################################ - -conf_file = '''# -*- encoding: utf-8 -* - -DATABASES = { - 'default': { - #'ENGINE': 'django.db.backends.mysql', - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'db.sqlite', - 'USER': '', - 'PASSWORD': '', - 'HOST' : '', - 'PORT' : '', - } -} - -''' - -dashboard_file ='''# -*- encoding: utf-8 -* - -from django.utils.translation import ugettext_lazy as _ -from django.core.urlresolvers import reverse - -from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard -from admin_tools.utils import get_admin_site_name - - -class CustomIndexDashboard(Dashboard): - """ - Custom index dashboard - """ - def init_with_context(self, context): - site_name = get_admin_site_name(context) - - # append an app list module for "Applications" - self.children.append(modules.AppList( - _('Applications'), - exclude=('django.contrib.*',), - )) - - # append an app list module for "Administration" - self.children.append(modules.AppList( - _('Administration'), - models=('django.contrib.*',), - )) - - # append a recent actions module - self.children.append(modules.RecentActions(_('Recent Actions'), 5)) -''' - - -auf_urls_template = '''# -*- encoding: utf-8 -* -from django.conf.urls.defaults import patterns, include, handler500, handler404, url -from django.conf import settings -from django.contrib import admin - -admin.autodiscover() - -handler404 -handler500 # Pyflakes - -urlpatterns = patterns( - '', - ######## page d'accueil de demo ###### - (r'^$', 'auf.django.skin.views.demo'), - ###################################### - url(r'^admin_tools/', include('admin_tools.urls')), - (r'^admin/', include(admin.site.urls)), - (r'^connexion/$', 'django.contrib.auth.views.login'), - (r'^deconnexion/$', 'django.contrib.auth.views.logout'), - -) - -if settings.DEBUG: - urlpatterns += patterns('', - (r'^media/(?P.*)$', 'django.views.static.serve', - {'document_root': settings.MEDIA_ROOT}), - ) -''' - -auf_settings_template = '''# -*- encoding: utf-8 -*- - -import os -import socket -from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as DEFAULT_TEMPLATE_CONTEXT_PROCESSORS - -# Rapports d'erreurs -SERVER_EMAIL = 'ne-pas-repondre@auf.org' -EMAIL_SUBJECT_PREFIX = '[%(project_name)s - %%s] ' %% socket.gethostname() -ADMINS = ( - ('Équipe ARI-SI', 'developpeurs@ca.auf.org'), -) - -MANAGERS = ADMINS - -TIME_ZONE = 'America/Montreal' - -LANGUAGE_CODE = 'fr-ca' - -PROJECT_ROOT = os.path.dirname(__file__) -SITE_ROOT = os.path.dirname(PROJECT_ROOT) - -MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') -MEDIA_URL = '/media/' - -STATIC_ROOT = os.path.join(SITE_ROOT, 'sitestatic') -STATIC_URL = '/static/' - -ROOT_URLCONF = '%(urlconf)s' - -INSTALLED_APPS = ( - 'auf.django.skin', - 'admin_tools', - 'admin_tools.theming', - 'admin_tools.menu', - 'admin_tools.dashboard', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.admin', - 'django.contrib.staticfiles', - 'south', -) - -TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_TEMPLATE_CONTEXT_PROCESSORS + ( - 'django.core.context_processors.static', - 'django.core.context_processors.request', - 'auf.django.skin.context_processors.auf', -) - - -TEMPLATE_DIRS = ( - os.path.join(os.path.dirname(__file__), "templates"), -) - -SOUTH_TESTS_MIGRATE = False - -ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard' - -from conf import * -''' - -################################################################################ -# DEVELOPPEMENT -################################################################################ -auf_development_settings = '''# -*- encoding: utf-8 -*- - -from %(project)s.settings import * -DEBUG=True -TEMPLATE_DEBUG=DEBUG - -# Décommentez ces lignes pour activer la debugtoolbar -#INTERNAL_IPS = ('127.0.0.1',) -#INSTALLED_APPS += ('debug_toolbar',) -#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) - -AUTH_PASSWORD_REQUIRED = False -''' - -################################################################################ -# PRODUCTION -################################################################################ -auf_production_settings = ''' # -*- encoding: utf-8 -*- - -# En production, rediriger la sortie terminal on disponible en WSGI -# vers la sortie fichier errorlog. -import sys -sys.stdout = sys.stderr - -from %(project)s.settings import * -''' diff --git a/auf/recipe/django/recipe.py b/auf/recipe/django/recipe.py index 5402af6..1c1dad6 100644 --- a/auf/recipe/django/recipe.py +++ b/auf/recipe/django/recipe.py @@ -1,17 +1,9 @@ # -*- encoding: utf-8 -*- import os -import shutil -import pkg_resources -import djangorecipe -from djangorecipe.boilerplate import versions +import zc from djangorecipe.recipe import Recipe as OriginalDjangoRecipe -from boilerplate import * - -djangorecipe.boilerplate.versions['1.3']['settings'] = auf_settings_template -djangorecipe.boilerplate.versions['1.3']['urls'] = auf_urls_template -djangorecipe.boilerplate.versions['1.3']['production_settings'] = auf_production_settings -djangorecipe.boilerplate.versions['1.3']['development_settings'] = auf_development_settings +from boilerplate import auf_buildout_file, auf_script_template class Recipe(OriginalDjangoRecipe): @@ -51,19 +43,11 @@ class Recipe(OriginalDjangoRecipe): return script_paths + [location] - def create_project(self, project_dir): - super(Recipe, self).create_project(project_dir) - - # fichier de configuration de base de données - self.create_file(os.path.join(project_dir, 'conf.py'), conf_file, self.options) - self.create_file(os.path.join(project_dir, 'conf.py.edit'), conf_file, self.options) - self.create_file(os.path.join(project_dir, 'dashboard.py'), dashboard_file, self.options) - def create_manage_script(self, extra_paths, ws): _script_template = zc.buildout.easy_install.script_template zc.buildout.easy_install.script_template = auf_buildout_file project = self.options.get('projectegg', self.options['project']) - scripts = zc.buildout.easy_install.scripts( + scripts = zc.buildout.easy_install.scripts( [(self.options.get('control-script', self.name), 'auf.recipe.django.manage', 'main')], ws, self.options['executable'], self.options['bin-directory'], diff --git a/setup.py b/setup.py index ca0c00d..b3b25f0 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,20 @@ from setuptools import setup, find_packages name = 'auf.recipe.django' -version = '1.7' +version = '2.0' setup(name=name, version=version, - description="Recette Django AUF avec nos pratiques internes", + description="Recette Django AUF", long_description="""\ """, - classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[], keywords='', author='Olivier Larchev\xc3\xaaque', author_email='olivier.larcheveque@auf.org', url='http://pypi.auf.org/%s' % name, license='GPL', - namespace_packages = ['auf', 'auf.recipe', ], + namespace_packages=['auf', 'auf.recipe', ], packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=False, -- 1.7.10.4