diff --git a/dbreset b/dbreset deleted file mode 100755 index d7c3e26..0000000 --- a/dbreset +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -rm /var/tmp/django-polymorphic-test-db.sqlite3 -./manage.py syncdb - diff --git a/__init__.py b/example/example/__init__.py similarity index 100% rename from __init__.py rename to example/example/__init__.py diff --git a/example/example/settings.py b/example/example/settings.py new file mode 100644 index 0000000..05a5c1f --- /dev/null +++ b/example/example/settings.py @@ -0,0 +1,100 @@ +import os + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@example.com'), +) + +MANAGERS = ADMINS +PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__)) + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(PROJECT_ROOT, 'example.db'), + } +} + +SITE_ID = 1 + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '5$f%)&a4tc*bg(79+ku!7o$kri-duw99@hq_)va^_kaw9*l)!7' + + +# Language +# TIME_ZONE = 'America/Chicago' +LANGUAGE_CODE = 'en-us' +USE_I18N = True +USE_L10N = True +USE_TZ = True + +# Paths +MEDIA_ROOT = '' +MEDIA_URL = '/media/' +STATIC_ROOT = '' +STATIC_URL = '/static/' + +# Apps +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +) + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'example.urls' + +WSGI_APPLICATION = 'example.wsgi.application' + +TEMPLATE_DIRS = () + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.admin', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + #'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'polymorphic', # needed if you want to use the polymorphic admin + 'pexp', # this Django app is for testing and experimentation; not needed otherwise +) + +# Logging configuration +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} diff --git a/example/example/urls.py b/example/example/urls.py new file mode 100644 index 0000000..d070426 --- /dev/null +++ b/example/example/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls import patterns, include, url +from django.contrib import admin +from django.core.urlresolvers import reverse_lazy +from django.views.generic import RedirectView + +admin.autodiscover() + +urlpatterns = patterns('', + url(r'^admin/', include(admin.site.urls)), + url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'), permanent=False)), +) diff --git a/example/example/wsgi.py b/example/example/wsgi.py new file mode 100644 index 0000000..9b42e63 --- /dev/null +++ b/example/example/wsgi.py @@ -0,0 +1,28 @@ +""" +WSGI config for example project. + +This module contains the WSGI application used by Django's development server +and any production WSGI deployments. It should expose a module-level variable +named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover +this application via the ``WSGI_APPLICATION`` setting. + +Usually you will have the standard Django WSGI application here, but it also +might make sense to replace the whole Django WSGI application with a custom one +that later delegates to the Django one. For example, you could introduce WSGI +middleware here, or combine a Django application with an application of another +framework. + +""" +import os + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + +# This application object is used by any WSGI server configured to use this +# file. This includes Django's development server, if the WSGI_APPLICATION +# setting points here. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() + +# Apply WSGI middleware here. +# from helloworld.wsgi import HelloWorldApplication +# application = HelloWorldApplication(application) diff --git a/example/manage.py b/example/manage.py new file mode 100755 index 0000000..f920f18 --- /dev/null +++ b/example/manage.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + + # Import polymorphic from this folder. + SRC_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + sys.path.insert(0, SRC_ROOT) + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/pexp/__init__.py b/example/pexp/__init__.py similarity index 100% rename from pexp/__init__.py rename to example/pexp/__init__.py diff --git a/pexp/admin.py b/example/pexp/admin.py similarity index 100% rename from pexp/admin.py rename to example/pexp/admin.py diff --git a/pexp/dumpdata_test_correct_output.txt b/example/pexp/dumpdata_test_correct_output.txt similarity index 100% rename from pexp/dumpdata_test_correct_output.txt rename to example/pexp/dumpdata_test_correct_output.txt diff --git a/pexp/management/__init__.py b/example/pexp/management/__init__.py similarity index 100% rename from pexp/management/__init__.py rename to example/pexp/management/__init__.py diff --git a/pexp/management/commands/__init__.py b/example/pexp/management/commands/__init__.py similarity index 100% rename from pexp/management/commands/__init__.py rename to example/pexp/management/commands/__init__.py diff --git a/pexp/management/commands/p2cmd.py b/example/pexp/management/commands/p2cmd.py similarity index 100% rename from pexp/management/commands/p2cmd.py rename to example/pexp/management/commands/p2cmd.py diff --git a/pexp/management/commands/pcmd.py b/example/pexp/management/commands/pcmd.py similarity index 100% rename from pexp/management/commands/pcmd.py rename to example/pexp/management/commands/pcmd.py diff --git a/pexp/management/commands/polybench.py b/example/pexp/management/commands/polybench.py similarity index 100% rename from pexp/management/commands/polybench.py rename to example/pexp/management/commands/polybench.py diff --git a/pexp/management/commands/polymorphic_create_test_data.py b/example/pexp/management/commands/polymorphic_create_test_data.py similarity index 100% rename from pexp/management/commands/polymorphic_create_test_data.py rename to example/pexp/management/commands/polymorphic_create_test_data.py diff --git a/pexp/models.py b/example/pexp/models.py similarity index 100% rename from pexp/models.py rename to example/pexp/models.py diff --git a/manage.py b/manage.py deleted file mode 100755 index 7a60030..0000000 --- a/manage.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -# Prepend project subdirectory 'libraries-local' to sys.path. -# This allows us to use/test any version of Django -# (e.g. Django 1.2 subversion) or any other packages/libraries. -import sys, os -project_path = os.path.dirname(os.path.abspath(__file__)) -libs_local_path = os.path.join(project_path, 'libraries-local') -if libs_local_path not in sys.path: sys.path.insert(1, libs_local_path) - -sys.stderr.write( 'using Python version: %s\n' % sys.version[:5]) - -import django -sys.stderr.write( 'using Django version: %s, from %s\n' % ( - django.get_version(), - os.path.dirname(os.path.abspath(django.__file__))) ) - -# vanilla Django manage.py from here on: - -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) - -if __name__ == "__main__": - execute_manager(settings) diff --git a/pexp/tests.py b/pexp/tests.py deleted file mode 100644 index 2247054..0000000 --- a/pexp/tests.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - -from django.test import TestCase - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.failUnlessEqual(1 + 1, 2) - -__test__ = {"doctest": """ -Another way to test that 1 + 1 is equal to 2. - ->>> 1 + 1 == 2 -True -"""} - diff --git a/pexp/views.py b/pexp/views.py deleted file mode 100644 index 60f00ef..0000000 --- a/pexp/views.py +++ /dev/null @@ -1 +0,0 @@ -# Create your views here. diff --git a/settings.py b/settings.py deleted file mode 100644 index f95cfe7..0000000 --- a/settings.py +++ /dev/null @@ -1,87 +0,0 @@ -# Django settings for polymorphic_demo project. - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - -ADMINS = ( - # ('Your Name', 'your_email@domain.com'), -) - -MANAGERS = ADMINS - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:' - } -} - -# Local time zone for this installation. Choices can be found here: -# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name -# although not all choices may be available on all operating systems. -# If running in a Windows environment this must be set to the same as your -# system time zone. -TIME_ZONE = 'America/Chicago' - -# Language code for this installation. All choices can be found here: -# http://www.i18nguy.com/unicode/language-identifiers.html -LANGUAGE_CODE = 'en-us' - -SITE_ID = 1 - -# If you set this to False, Django will make some optimizations so as not -# to load the internationalization machinery. -USE_I18N = True - -# Absolute path to the directory that holds media. -# Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = '' - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = '' - -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/media/' - -# Make this unique, and don't share it with anybody. -SECRET_KEY = 'nk=c&k+c&#+)8557)%&0auysdd3g^sfq6@rw8_x1k8)-p@y)!(' - -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', -) - -ROOT_URLCONF = 'urls' -STATIC_URL = '/static/' -ADMIN_MEDIA_PREFIX = '/static/admin/' # 1.3 compatibility - -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. -) - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.admin', - 'django.contrib.contenttypes', - 'django.contrib.messages', - 'django.contrib.sessions', - 'django.contrib.staticfiles', - - #'django.contrib.sites', - 'polymorphic', # needed if you want to use the polymorphic admin - 'pexp', # this Django app is for testing and experimentation; not needed otherwise -) diff --git a/urls.py b/urls.py deleted file mode 100644 index d54ec31..0000000 --- a/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.conf import settings -from django.conf.urls.defaults import patterns, include, url -from django.conf.urls.static import static -from django.contrib import admin - -admin.autodiscover() - -urlpatterns = patterns('', - url(r'^admin/', include(admin.site.urls)), -)