From e5b058a1070230fe7eb86f549b6d66feb757fc2e Mon Sep 17 00:00:00 2001 From: Kumar McMillan Date: Sun, 8 Jan 2012 13:17:04 -0600 Subject: [PATCH] More pythonic Playdoh layout: no top level __init__, no apps The base app has moved to a single module named project. All apps are submodules of project and must be imported as such. --- .gitignore | 2 ++ MANIFEST.in | 2 ++ apps/examples/urls.py | 7 ------- manage.py | 5 ++++- __init__.py => project/__init__.py | 0 project/base/__init__.py | 1 + {apps/examples => project/base}/models.py | 0 {apps => project/base/templates}/.gitignore | 0 .../base/templates}/example_base.html | 0 {apps => project/examples}/__init__.py | 0 .../__init__.py => project/examples/models.py | 0 .../examples/templates/examples/bleach.html | 0 .../examples/templates/examples/home.html | 0 .../templates/examples/mobile/home.html | 0 project/examples/urls.py | 9 +++++++++ {apps => project}/examples/views.py | 0 .../locale}/en_US/LC_MESSAGES/messages.po | 0 .../locale}/fr/LC_MESSAGES/messages.po | 0 .../locale}/templates/LC_MESSAGES/messages.pot | 0 {settings => project/settings}/__init__.py | 0 {settings => project/settings}/base.py | 7 +++++-- {settings => project/settings}/local.py-dist | 1 - urls.py => project/urls.py | 4 +++- setup.py | 17 +++++++++++++++++ templates/.gitignore | 0 25 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 apps/examples/urls.py rename __init__.py => project/__init__.py (100%) create mode 100644 project/base/__init__.py rename {apps/examples => project/base}/models.py (100%) rename {apps => project/base/templates}/.gitignore (100%) rename {templates => project/base/templates}/example_base.html (100%) rename {apps => project/examples}/__init__.py (100%) rename apps/examples/__init__.py => project/examples/models.py (100%) rename {apps => project}/examples/templates/examples/bleach.html (100%) rename {apps => project}/examples/templates/examples/home.html (100%) rename {apps => project}/examples/templates/examples/mobile/home.html (100%) create mode 100644 project/examples/urls.py rename {apps => project}/examples/views.py (100%) rename {locale => project/locale}/en_US/LC_MESSAGES/messages.po (100%) rename {locale => project/locale}/fr/LC_MESSAGES/messages.po (100%) rename {locale => project/locale}/templates/LC_MESSAGES/messages.pot (100%) rename {settings => project/settings}/__init__.py (100%) rename {settings => project/settings}/base.py (90%) rename {settings => project/settings}/local.py-dist (99%) rename urls.py => project/urls.py (93%) create mode 100644 setup.py delete mode 100644 templates/.gitignore diff --git a/.gitignore b/.gitignore index 13acb16df..8ed0271ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ settings_local.py settings/local.py +*/settings/local.py *.py[co] *.sw[po] .coverage pip-log.txt docs/_gh-pages build.py +build .DS_Store *-min.css *-all.css diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..1d2cb6458 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include */*/templates *.* +recursive-include */locale *.* diff --git a/apps/examples/urls.py b/apps/examples/urls.py deleted file mode 100644 index a5bd3a3fd..000000000 --- a/apps/examples/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.conf.urls.defaults import * - - -urlpatterns = patterns('examples.views', - url(r'^$', 'home', name='examples.home'), - url(r'^bleach/?$', 'bleach_test', name='examples.bleach'), -) diff --git a/manage.py b/manage.py index d01401809..40ebb0ac8 100755 --- a/manage.py +++ b/manage.py @@ -2,6 +2,9 @@ import os import sys +# Edit this if necessary or override the variable in your environment. +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') + try: # For local development in a virtualenv: from funfactory import manage @@ -18,7 +21,7 @@ except ImportError: sys.path.remove(tmp_path) -manage.setup_environ(__file__) +manage.setup_environ(__file__, more_pythonic=True) if __name__ == "__main__": manage.main() diff --git a/__init__.py b/project/__init__.py similarity index 100% rename from __init__.py rename to project/__init__.py diff --git a/project/base/__init__.py b/project/base/__init__.py new file mode 100644 index 000000000..96eaf0d1c --- /dev/null +++ b/project/base/__init__.py @@ -0,0 +1 @@ +"""Application base, containing global templates.""" diff --git a/apps/examples/models.py b/project/base/models.py similarity index 100% rename from apps/examples/models.py rename to project/base/models.py diff --git a/apps/.gitignore b/project/base/templates/.gitignore similarity index 100% rename from apps/.gitignore rename to project/base/templates/.gitignore diff --git a/templates/example_base.html b/project/base/templates/example_base.html similarity index 100% rename from templates/example_base.html rename to project/base/templates/example_base.html diff --git a/apps/__init__.py b/project/examples/__init__.py similarity index 100% rename from apps/__init__.py rename to project/examples/__init__.py diff --git a/apps/examples/__init__.py b/project/examples/models.py similarity index 100% rename from apps/examples/__init__.py rename to project/examples/models.py diff --git a/apps/examples/templates/examples/bleach.html b/project/examples/templates/examples/bleach.html similarity index 100% rename from apps/examples/templates/examples/bleach.html rename to project/examples/templates/examples/bleach.html diff --git a/apps/examples/templates/examples/home.html b/project/examples/templates/examples/home.html similarity index 100% rename from apps/examples/templates/examples/home.html rename to project/examples/templates/examples/home.html diff --git a/apps/examples/templates/examples/mobile/home.html b/project/examples/templates/examples/mobile/home.html similarity index 100% rename from apps/examples/templates/examples/mobile/home.html rename to project/examples/templates/examples/mobile/home.html diff --git a/project/examples/urls.py b/project/examples/urls.py new file mode 100644 index 000000000..ac95e9f41 --- /dev/null +++ b/project/examples/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls.defaults import * + +from . import views + + +urlpatterns = patterns('', + url(r'^$', views.home, name='examples.home'), + url(r'^bleach/?$', views.bleach_test, name='examples.bleach'), +) diff --git a/apps/examples/views.py b/project/examples/views.py similarity index 100% rename from apps/examples/views.py rename to project/examples/views.py diff --git a/locale/en_US/LC_MESSAGES/messages.po b/project/locale/en_US/LC_MESSAGES/messages.po similarity index 100% rename from locale/en_US/LC_MESSAGES/messages.po rename to project/locale/en_US/LC_MESSAGES/messages.po diff --git a/locale/fr/LC_MESSAGES/messages.po b/project/locale/fr/LC_MESSAGES/messages.po similarity index 100% rename from locale/fr/LC_MESSAGES/messages.po rename to project/locale/fr/LC_MESSAGES/messages.po diff --git a/locale/templates/LC_MESSAGES/messages.pot b/project/locale/templates/LC_MESSAGES/messages.pot similarity index 100% rename from locale/templates/LC_MESSAGES/messages.pot rename to project/locale/templates/LC_MESSAGES/messages.pot diff --git a/settings/__init__.py b/project/settings/__init__.py similarity index 100% rename from settings/__init__.py rename to project/settings/__init__.py diff --git a/settings/base.py b/project/settings/base.py similarity index 90% rename from settings/base.py rename to project/settings/base.py index 67afc3a84..cd6950871 100644 --- a/settings/base.py +++ b/project/settings/base.py @@ -3,7 +3,6 @@ from funfactory.settings_base import * - # Bundles is a dictionary of two dictionaries, css and js, which list css files # and js files that can be bundled together by the minify app. MINIFY_BUNDLES = { @@ -24,10 +23,14 @@ MINIFY_BUNDLES = { } } +# Defines the views served for root URLs. +ROOT_URLCONF = 'project.urls' INSTALLED_APPS = list(INSTALLED_APPS) + [ + # Application base, containing global templates. + 'project.base', # Example code. Can (and should) be removed for actual projects. - 'examples', + 'project.examples', ] diff --git a/settings/local.py-dist b/project/settings/local.py-dist similarity index 99% rename from settings/local.py-dist rename to project/settings/local.py-dist index 124aacea2..90e1991a8 100644 --- a/settings/local.py-dist +++ b/project/settings/local.py-dist @@ -5,7 +5,6 @@ #from . import base #INSTALLED_APPS = base.INSTALLED_APPS + ['debug_toolbar'] - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', diff --git a/urls.py b/project/urls.py similarity index 93% rename from urls.py rename to project/urls.py index ed7f87331..c20086817 100644 --- a/urls.py +++ b/project/urls.py @@ -1,13 +1,15 @@ from django.conf import settings from django.conf.urls.defaults import * +from .examples import urls + # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', # Example: - (r'', include('examples.urls')), + (r'', include(urls)), # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..58dbd933f --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +import os + +from setuptools import setup, find_packages + + +setup(name='project', + version='1.0', + description='Django application.', + long_description='', + author='', + author_email='', + license='', + url='', + include_package_data=True, + classifiers = [], + packages=find_packages(exclude=['tests']), + install_requires=[]) diff --git a/templates/.gitignore b/templates/.gitignore deleted file mode 100644 index e69de29bb..000000000