From 01919b44b81dd3cb38f38775e419898f7eb119b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADn?= Date: Mon, 20 May 2013 13:56:58 +0200 Subject: [PATCH] Added django 1.5.1 and configured local_settings --- config/development/__init__.py | 0 config/development/admin.json | 16 ++ config/development/local_settings.py | 14 ++ config/production/local_settings.py | 4 + fabfile.py | 21 ++- minecraftcodex/herobrine/__init__.py | 0 minecraftcodex/herobrine/local_settings.py | 1 + minecraftcodex/herobrine/settings.py | 164 +++++++++++++++++++++ minecraftcodex/herobrine/urls.py | 17 +++ minecraftcodex/herobrine/wsgi.py | 32 ++++ minecraftcodex/manage.py | 10 ++ 11 files changed, 273 insertions(+), 6 deletions(-) create mode 100644 config/development/__init__.py create mode 100644 config/development/admin.json create mode 100644 minecraftcodex/herobrine/__init__.py create mode 120000 minecraftcodex/herobrine/local_settings.py create mode 100644 minecraftcodex/herobrine/settings.py create mode 100644 minecraftcodex/herobrine/urls.py create mode 100644 minecraftcodex/herobrine/wsgi.py create mode 100644 minecraftcodex/manage.py diff --git a/config/development/__init__.py b/config/development/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/development/admin.json b/config/development/admin.json new file mode 100644 index 0000000..4b888b1 --- /dev/null +++ b/config/development/admin.json @@ -0,0 +1,16 @@ +[ + { + "model": "auth.user", + "pk": 1, + "fields": { + "first_name": "John", + "last_name": "Doe", + "username": "admin", + "email": "email@mydevsite.com", + "password": "pbkdf2_sha256$10000$VVJjeNI4DX0Z$dI0w6zSkvvFO+B7s9+rxVS0sj6N2Tp/xVny3FokWQis=", + "is_superuser": "1", + "is_active": "1", + "is_staff": "1" + } + } +] diff --git a/config/development/local_settings.py b/config/development/local_settings.py index e69de29..5637911 100644 --- a/config/development/local_settings.py +++ b/config/development/local_settings.py @@ -0,0 +1,14 @@ +LOCAL_SETTINGS = True +from herobrine.settings import * + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'dev_ddbb.sqlite', + } +} + +JINGO_EXCLUDE_APPS = ('debug_toolbar',) diff --git a/config/production/local_settings.py b/config/production/local_settings.py index e69de29..6fdab84 100644 --- a/config/production/local_settings.py +++ b/config/production/local_settings.py @@ -0,0 +1,4 @@ +LOCAL_SETTINGS = True +from settings import * + +DEBUG = False diff --git a/fabfile.py b/fabfile.py index 479a034..f13f71c 100644 --- a/fabfile.py +++ b/fabfile.py @@ -8,7 +8,7 @@ from fabric.api import local, env, prefix, execute from fabric.context_managers import settings, hide from os.path import exists -from os import environ, stat +from os import environ, stat, getcwd from fabric.colors import yellow, red, green from subprocess import PIPE, Popen import sys @@ -22,8 +22,8 @@ env.python = None env.development_ddbb = 'dev.sqlite3' # Configuration -#python_version = "3.3.1" -python_version = "2.7.4" +python_version = "3.3.1" +#python_version = "2.7.5" # Functions @@ -133,6 +133,12 @@ def requirements(environ='global'): local('pip freeze') +def syncdb(): + if not active_virtualenv(): + with prefix(env.activate): + local('python minecraftcodex/manage.py syncdb --noinput') + local('python minecraftcodex/manage.py loaddata ./config/development/admin.json') + # Easy-mode def prepare(): execute(create_virtualenv) @@ -146,9 +152,12 @@ def p(): def run(): if not active_virtualenv(): with prefix(env.activate): - environ['BACKEND_SETTINGS'] = 'config.development.backend_settings' - local('python app.py') - + path = getcwd() + with settings(hide('warnings', 'running'), + warn_only=True): + local('ln -s %s/config/development/local_settings.py %s/minecraftcodex/herobrine/local_settings.py' % (path, path)) + local('python minecraftcodex/manage.py runserver') + local('rm ./minecraftcodex/herobrine/local_settings.py') def test(): if not active_virtualenv(): diff --git a/minecraftcodex/herobrine/__init__.py b/minecraftcodex/herobrine/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/minecraftcodex/herobrine/local_settings.py b/minecraftcodex/herobrine/local_settings.py new file mode 120000 index 0000000..a7fe30f --- /dev/null +++ b/minecraftcodex/herobrine/local_settings.py @@ -0,0 +1 @@ +/Users/fmartin/Developer/minecraftcodex/config/development/local_settings.py \ No newline at end of file diff --git a/minecraftcodex/herobrine/settings.py b/minecraftcodex/herobrine/settings.py new file mode 100644 index 0000000..b63ca50 --- /dev/null +++ b/minecraftcodex/herobrine/settings.py @@ -0,0 +1,164 @@ +# Django settings for herobrine project. + +DEBUG = False +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( +# ('Felipe Martin', 'fmartingr@me.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '', # Or path to database file if using sqlite3. + # The following settings are not used with sqlite3: + 'USER': '', + 'PASSWORD': '', + 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. + 'PORT': '', # Set to empty string for default. + } +} + +# Hosts/domain names that are valid for this site; required if DEBUG is False +# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts +ALLOWED_HOSTS = [] + +# 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. +# In a Windows environment this must be set to your system time zone. +TIME_ZONE = 'Europe/Madrid' + +# 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 + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale. +USE_L10N = True + +# If you set this to False, Django will not use timezone-aware datetimes. +USE_TZ = True + +# Absolute filesystem path to the directory that will hold user-uploaded files. +# Example: "/var/www/example.com/media/" +MEDIA_ROOT = '' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +# Examples: "http://example.com/media/", "http://media.example.com/" +MEDIA_URL = '' + +# Absolute path to the directory static files should be collected to. +# Don't put anything in this directory yourself; store your static files +# in apps' "static/" subdirectories and in STATICFILES_DIRS. +# Example: "/var/www/example.com/static/" +STATIC_ROOT = '' + +# URL prefix for static files. +# Example: "http://example.com/static/", "http://static.example.com/" +STATIC_URL = '/static/' + +# Additional locations of static files +STATICFILES_DIRS = ( + # Put strings here, like "/home/html/static" or "C:/www/django/static". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +# 'django.contrib.staticfiles.finders.DefaultStorageFinder', +) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '1234567890' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'jingo.Loader', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +JINGO_INCLUDE_PATTERN = r'\.jinja2' + +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', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'herobrine.urls' + +# Python dotted path to the WSGI application used by Django's runserver. +WSGI_APPLICATION = 'herobrine.wsgi.application' + +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.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.admin', +) + +# A sample logging configuration. The only tangible logging +# performed by this configuration is to send an email to +# the site admins on every HTTP 500 error when DEBUG=False. +# See http://docs.djangoproject.com/en/dev/topics/logging for +# more details on how to customize your 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, + }, + } +} + +try: + LOCAL_SETTINGS +except NameError: + try: + from herobrine.local_settings import * + except ImportError as error: + print(error) + pass diff --git a/minecraftcodex/herobrine/urls.py b/minecraftcodex/herobrine/urls.py new file mode 100644 index 0000000..5d65b6f --- /dev/null +++ b/minecraftcodex/herobrine/urls.py @@ -0,0 +1,17 @@ +from django.conf.urls import patterns, include, url + +# Admin +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + # Examples: + # url(r'^$', 'herobrine.views.home', name='home'), + # url(r'^herobrine/', include('herobrine.foo.urls')), + + # Uncomment the admin/doc line below to enable admin documentation: + # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + url(r'^management/', include(admin.site.urls)), +) diff --git a/minecraftcodex/herobrine/wsgi.py b/minecraftcodex/herobrine/wsgi.py new file mode 100644 index 0000000..24fd54e --- /dev/null +++ b/minecraftcodex/herobrine/wsgi.py @@ -0,0 +1,32 @@ +""" +WSGI config for herobrine 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 + +# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks +# if running multiple sites in the same mod_wsgi process. To fix this, use +# mod_wsgi daemon mode with each site in its own daemon process, or use +# os.environ["DJANGO_SETTINGS_MODULE"] = "herobrine.settings" +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "herobrine.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/minecraftcodex/manage.py b/minecraftcodex/manage.py new file mode 100644 index 0000000..d371333 --- /dev/null +++ b/minecraftcodex/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "herobrine.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv)