update django generate local settings os that it copies over internally generated values from the project files rather than directly connecting. this means ALL projects need to be updated wihenever project configuraiton settings are changed
This commit is contained in:
parent
8cc2e9a101
commit
16f43982a0
3 changed files with 99 additions and 52 deletions
|
|
@ -328,6 +328,51 @@ def generate_scripts(template_name, make_copy=False):
|
||||||
project_name=project_name)
|
project_name=project_name)
|
||||||
build_name = "%s.py" % project_branch
|
build_name = "%s.py" % project_branch
|
||||||
|
|
||||||
|
# add extra local specfic context variables
|
||||||
|
# NOTE:
|
||||||
|
# if you change project settings, you MUST run generate
|
||||||
|
|
||||||
|
context['paths_django_templates'] = \
|
||||||
|
configuration.paths.django.templates
|
||||||
|
|
||||||
|
context['server_database_backend'] = \
|
||||||
|
configuration.server.database.backend
|
||||||
|
|
||||||
|
context['server_database_name'] = configuration.server.database.name
|
||||||
|
context['server_database_user'] = configuration.server.database.user
|
||||||
|
|
||||||
|
context['server_database_password'] = \
|
||||||
|
configuration.server.database.password
|
||||||
|
|
||||||
|
context['server_database_host'] = configuration.server.database.host
|
||||||
|
context['server_database_port'] = configuration.server.database.port
|
||||||
|
|
||||||
|
context['paths_server_media_static'] = \
|
||||||
|
configuration.paths.server.media.static
|
||||||
|
|
||||||
|
context['paths_server_media_dynamic'] = \
|
||||||
|
configuration.paths.server.media.dynamic
|
||||||
|
|
||||||
|
context['paths_project_root'] = configuration.paths.project.root
|
||||||
|
|
||||||
|
context['project_django_allowedhosts'] = \
|
||||||
|
configuration.project.django.allowedhosts
|
||||||
|
|
||||||
|
# convenience variable naming, otherwise it's too long to deal with
|
||||||
|
file_debug_handler = configuration.logging.django.handlers.file_debug
|
||||||
|
|
||||||
|
context['file_debug_handler__name_project'] = \
|
||||||
|
file_debug_handler.name.project
|
||||||
|
|
||||||
|
context['file_debug_handler__path_project'] = \
|
||||||
|
file_debug_handler.path.project
|
||||||
|
|
||||||
|
context['file_debug_handler__name_server'] = \
|
||||||
|
file_debug_handler.name.server
|
||||||
|
|
||||||
|
context['file_debug_handler__path_server'] = \
|
||||||
|
file_debug_handler.path.server
|
||||||
|
|
||||||
copy_full_path = "{copy_path}/{build_name}".format(
|
copy_full_path = "{copy_path}/{build_name}".format(
|
||||||
copy_path=copy_path, build_name=build_name)
|
copy_path=copy_path, build_name=build_name)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
|
# this file contains settings that are automatically generated
|
||||||
|
# put custom commands/ imports in a separate file!
|
||||||
|
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
BRANCH = '{{ project_branch }}'
|
BRANCH = '{{ project_branch }}'
|
||||||
|
|
||||||
from {{ project_name }}.settings import *
|
from {{ project_name }}.settings import *
|
||||||
|
|
||||||
from modules import initialize
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||||
|
|
||||||
configuration = initialize.environment(BRANCH)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
SITE_ID = 1
|
||||||
|
|
||||||
TEMPLATES[0]['DIRS'].append(configuration.paths.django.templates)
|
TEMPLATES[0]['DIRS'].append(
|
||||||
|
"{{paths_django_templates}}")
|
||||||
|
|
||||||
#
|
#
|
||||||
# NOTE: a lot of the code in these local settings files are automated and you
|
# NOTE: a lot of the code in these local settings files are automated and you
|
||||||
|
|
@ -26,16 +27,13 @@ TEMPLATES[0]['DIRS'].append(configuration.paths.django.templates)
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.{db_backend}'.format(
|
'ENGINE': 'django.db.backends.{db_backend}'.format(
|
||||||
db_backend=configuration.server.database.backend),
|
db_backend='{{server_database_backend}}'),
|
||||||
|
|
||||||
'NAME': '{db_name}'.format(db_name=configuration.server.database.name),
|
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||||
'USER': '{db_user}'.format(db_user=configuration.server.database.user),
|
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||||
|
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||||
'PASSWORD': '{db_pass}'.format(
|
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||||
db_pass=configuration.server.database.password),
|
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||||
|
|
||||||
'HOST': '{db_host}'.format(db_host=configuration.server.database.host),
|
|
||||||
'PORT': '{db_port}'.format(db_port=configuration.server.database.port),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,15 +49,15 @@ DATABASES = {
|
||||||
# MEDIA_ROOT is the dynamic media information that the web server, user or
|
# MEDIA_ROOT is the dynamic media information that the web server, user or
|
||||||
# admin # will be adding and taking out. It's why I call it "dynamic"
|
# admin # will be adding and taking out. It's why I call it "dynamic"
|
||||||
|
|
||||||
STATIC_ROOT = configuration.paths.server.media.static
|
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||||
MEDIA_ROOT = configuration.paths.server.media.dynamic
|
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||||
|
|
||||||
# directories from which we search for static files to place in STATIC_ROOT
|
# directories from which we search for static files to place in STATIC_ROOT
|
||||||
# these static files are located within the project root as opposed to the
|
# these static files are located within the project root as opposed to the
|
||||||
# server root location
|
# server root location
|
||||||
|
|
||||||
STATICFILES_DIRS = (
|
STATICFILES_DIRS = (
|
||||||
os.path.join(configuration.paths.project.root, "share", "media"),
|
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# debug and debug toolbar settings
|
# debug and debug toolbar settings
|
||||||
|
|
@ -70,14 +68,11 @@ USE_DEBUG_TOOLBAR = DEBUG
|
||||||
# allow template debug outputs on {{ project_branch }} environment
|
# allow template debug outputs on {{ project_branch }} environment
|
||||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||||
|
|
||||||
ALLOWED_HOSTS = configuration.project.django.allowedhosts
|
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||||
|
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
# Debug logging to the console
|
# Debug logging to the console
|
||||||
|
|
||||||
# convenience variable naming, otherwise it's too long to deal with
|
|
||||||
file_debug_handler = configuration.logging.django.handlers.file_debug
|
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
'formatters': {
|
'formatters': {
|
||||||
|
|
@ -94,17 +89,23 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'handlers': {
|
'handlers': {
|
||||||
file_debug_handler.name.project: {
|
'{{ file_debug_handler__name_project }}': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
'filename': file_debug_handler.path.project,
|
|
||||||
|
'filename':
|
||||||
|
'{{file_debug_handler__path_project}}',
|
||||||
|
|
||||||
'formatter': 'code'
|
'formatter': 'code'
|
||||||
},
|
},
|
||||||
|
|
||||||
file_debug_handler.name.server: {
|
'{{ file_debug_handler__name_server }}': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
'filename': file_debug_handler.path.server,
|
|
||||||
|
'filename':
|
||||||
|
'{{file_debug_handler__path_server}}',
|
||||||
|
|
||||||
'formatter': 'code'
|
'formatter': 'code'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -124,8 +125,8 @@ LOGGING = {
|
||||||
'handlers':
|
'handlers':
|
||||||
[
|
[
|
||||||
'console',
|
'console',
|
||||||
file_debug_handler.name.project,
|
'{{ file_debug_handler__name_project }}',
|
||||||
file_debug_handler.name.server
|
'{{ file_debug_handler__name_server }}',
|
||||||
],
|
],
|
||||||
|
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
|
# this file contains settings that are automatically generated
|
||||||
|
# put custom commands/ imports in a separate file!
|
||||||
|
|
||||||
LOCAL_SETTINGS = True # avoid recursive imports
|
LOCAL_SETTINGS = True # avoid recursive imports
|
||||||
BRANCH = '{{ project_branch }}'
|
BRANCH = '{{ project_branch }}'
|
||||||
|
|
||||||
from {{ project_name }}.settings import *
|
from {{ project_name }}.settings import *
|
||||||
|
|
||||||
from modules import initialize
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||||
|
|
||||||
configuration = initialize.environment(BRANCH)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
SITE_ID = 1
|
||||||
|
|
||||||
TEMPLATES[0]['DIRS'].append(configuration.paths.django.templates)
|
TEMPLATES[0]['DIRS'].append(
|
||||||
|
"{{paths_django_templates}}")
|
||||||
|
|
||||||
#
|
#
|
||||||
# NOTE: a lot of the code in these local settings files are automated and you
|
# NOTE: a lot of the code in these local settings files are automated and you
|
||||||
|
|
@ -26,16 +27,13 @@ TEMPLATES[0]['DIRS'].append(configuration.paths.django.templates)
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.{db_backend}'.format(
|
'ENGINE': 'django.db.backends.{db_backend}'.format(
|
||||||
db_backend=configuration.server.database.backend),
|
db_backend='{{server_database_backend}}'),
|
||||||
|
|
||||||
'NAME': '{db_name}'.format(db_name=configuration.server.database.name),
|
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||||
'USER': '{db_user}'.format(db_user=configuration.server.database.user),
|
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||||
|
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||||
'PASSWORD': '{db_pass}'.format(
|
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||||
db_pass=configuration.server.database.password),
|
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||||
|
|
||||||
'HOST': '{db_host}'.format(db_host=configuration.server.database.host),
|
|
||||||
'PORT': '{db_port}'.format(db_port=configuration.server.database.port),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,15 +49,15 @@ DATABASES = {
|
||||||
# MEDIA_ROOT is the dynamic media information that the web server, user or
|
# MEDIA_ROOT is the dynamic media information that the web server, user or
|
||||||
# admin # will be adding and taking out. It's why I call it "dynamic"
|
# admin # will be adding and taking out. It's why I call it "dynamic"
|
||||||
|
|
||||||
STATIC_ROOT = configuration.paths.server.media.static
|
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||||
MEDIA_ROOT = configuration.paths.server.media.dynamic
|
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||||
|
|
||||||
# directories from which we search for static files to place in STATIC_ROOT
|
# directories from which we search for static files to place in STATIC_ROOT
|
||||||
# these static files are located within the project root as opposed to the
|
# these static files are located within the project root as opposed to the
|
||||||
# server root location
|
# server root location
|
||||||
|
|
||||||
STATICFILES_DIRS = (
|
STATICFILES_DIRS = (
|
||||||
os.path.join(configuration.paths.project.root, "share", "media"),
|
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# debug and debug toolbar settings
|
# debug and debug toolbar settings
|
||||||
|
|
@ -70,14 +68,11 @@ USE_DEBUG_TOOLBAR = DEBUG
|
||||||
# allow template debug outputs on {{ project_branch }} environment
|
# allow template debug outputs on {{ project_branch }} environment
|
||||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||||
|
|
||||||
ALLOWED_HOSTS = configuration.project.allowedhosts
|
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||||
|
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
# Debug logging to the console
|
# Debug logging to the console
|
||||||
|
|
||||||
# convenience variable naming, otherwise it's too long to deal with
|
|
||||||
file_debug_handler = configuration.logging.django.handlers.file_debug
|
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
'formatters': {
|
'formatters': {
|
||||||
|
|
@ -94,17 +89,23 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'handlers': {
|
'handlers': {
|
||||||
file_debug_handler.name.project: {
|
'{{ file_debug_handler__name_project }}': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
'filename': file_debug_handler.path.project,
|
|
||||||
|
'filename':
|
||||||
|
'{{file_debug_handler__path_project}}',
|
||||||
|
|
||||||
'formatter': 'code'
|
'formatter': 'code'
|
||||||
},
|
},
|
||||||
|
|
||||||
file_debug_handler.name.server: {
|
'{{ file_debug_handler__name_server }}': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
'filename': file_debug_handler.path.server,
|
|
||||||
|
'filename':
|
||||||
|
'{{file_debug_handler__path_server}}',
|
||||||
|
|
||||||
'formatter': 'code'
|
'formatter': 'code'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -124,8 +125,8 @@ LOGGING = {
|
||||||
'handlers':
|
'handlers':
|
||||||
[
|
[
|
||||||
'console',
|
'console',
|
||||||
file_debug_handler.name.project,
|
'{{ file_debug_handler__name_project }}',
|
||||||
file_debug_handler.name.server
|
'{{ file_debug_handler__name_server }}',
|
||||||
],
|
],
|
||||||
|
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue