updated generate so it creates a generated local file that is imported by the normal local file
This commit is contained in:
parent
0211723fe9
commit
b961dad932
6 changed files with 287 additions and 261 deletions
|
|
@ -323,11 +323,22 @@ def generate_scripts(template_name, make_copy=False):
|
|||
project_name=project_name)
|
||||
|
||||
if template_name == 'local':
|
||||
|
||||
copy_path = "{project_path}/{project_name}/_settings".format(
|
||||
project_path=project_path,
|
||||
project_name=project_name)
|
||||
build_name = "%s.py" % project_branch
|
||||
|
||||
# generate the local generate scripts
|
||||
generate('local.generated', make_copy)
|
||||
|
||||
elif template_name == 'local.generated':
|
||||
|
||||
copy_path = "{project_path}/{project_name}/_settings".format(
|
||||
project_path=project_path,
|
||||
project_name=project_name)
|
||||
build_name = "%s_generated.py" % project_branch
|
||||
|
||||
# add extra local specfic context variables
|
||||
# NOTE:
|
||||
# if you change project settings, you MUST run generate
|
||||
|
|
@ -451,7 +462,7 @@ def generate(param="help", make_copy=False):
|
|||
make_copy must be set to True if you want it to actually do anthing
|
||||
"""
|
||||
|
||||
SCRIPT_LIST = ['settings', 'local', 'wsgi']
|
||||
SCRIPT_LIST = ['settings', 'local', 'local.generated', 'wsgi']
|
||||
PARAM_LIST = list(SCRIPT_LIST)
|
||||
PARAM_LIST.append('gunicorn')
|
||||
|
||||
|
|
|
|||
|
|
@ -396,6 +396,7 @@ def get_config(branchname):
|
|||
|
||||
add_template(dataobject, layout, config, "django", "settings")
|
||||
add_template(dataobject, layout, config, "django", "local")
|
||||
add_template(dataobject, layout, config, "django", "local.generated")
|
||||
add_template(dataobject, layout, config, "django", "wsgi")
|
||||
|
||||
#
|
||||
|
|
|
|||
136
share/templates/conf/django/files/local.generated.jinja2
Normal file
136
share/templates/conf/django/files/local.generated.jinja2
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
# this file contains settings that are automatically generated
|
||||
# put custom commands/ imports in a separate file!
|
||||
|
||||
LOCAL_SETTINGS = True # avoid recursive imports
|
||||
BRANCH = '{{ project_branch }}'
|
||||
|
||||
from {{ project_name }}.settings import *
|
||||
|
||||
import logging
|
||||
|
||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
TEMPLATES[0]['DIRS'].append(
|
||||
"{{paths_django_templates}}")
|
||||
|
||||
#
|
||||
# NOTE: a lot of the code in these local settings files are automated and you
|
||||
# might be inclined to take them out and move them into the main settings.py
|
||||
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
|
||||
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
|
||||
# Once I set that file, THEN all the rest of the information can be automated.
|
||||
# So all these automated info needs to be here.
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': '{{server_database_backend}}',
|
||||
|
||||
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# directory from which we serve static files
|
||||
#
|
||||
# NOTE: both STATIC and MEDIA roots are getting their values from the
|
||||
# initialization files that are set up above. Also, MEDIA_ROOT is being set
|
||||
# to something called "paths.server.media.dynamic" - the names are different,
|
||||
# but it means the same thing.
|
||||
#
|
||||
# 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"
|
||||
|
||||
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||
|
||||
# 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
|
||||
# server root location
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||
)
|
||||
|
||||
# debug and debug toolbar settings
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
USE_DEBUG_TOOLBAR = DEBUG
|
||||
|
||||
# allow template debug outputs on {{ project_branch }} environment
|
||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||
|
||||
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||
|
||||
# -----------------------------------------
|
||||
# Debug logging to the console
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
|
||||
" %(thread)d %(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
|
||||
'code': {
|
||||
'format': "%(module)s:%(funcName)s - %(message)s"
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'{{ file_debug_handler__name_project }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_project}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'{{ file_debug_handler__name_server }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_server}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple'
|
||||
},
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.debug': {
|
||||
# use the console for logging
|
||||
'handlers':
|
||||
[
|
||||
'console',
|
||||
'{{ file_debug_handler__name_project }}',
|
||||
'{{ file_debug_handler__name_server }}',
|
||||
],
|
||||
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,138 +1,9 @@
|
|||
# this file contains settings that are automatically generated
|
||||
# put custom commands/ imports in a separate file!
|
||||
|
||||
LOCAL_SETTINGS = True # avoid recursive imports
|
||||
BRANCH = '{{ project_branch }}'
|
||||
|
||||
from {{ project_name }}.settings import *
|
||||
from {{ project_name }}._settings.{{ project_branch }}_generated import *
|
||||
|
||||
import logging
|
||||
|
||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
TEMPLATES[0]['DIRS'].append(
|
||||
"{{paths_django_templates}}")
|
||||
|
||||
#
|
||||
# NOTE: a lot of the code in these local settings files are automated and you
|
||||
# might be inclined to take them out and move them into the main settings.py
|
||||
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
|
||||
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
|
||||
# Once I set that file, THEN all the rest of the information can be automated.
|
||||
# So all these automated info needs to be here.
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': '{{server_database_backend}}',
|
||||
|
||||
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# directory from which we serve static files
|
||||
#
|
||||
# NOTE: both STATIC and MEDIA roots are getting their values from the
|
||||
# initialization files that are set up above. Also, MEDIA_ROOT is being set
|
||||
# to something called "paths.server.media.dynamic" - the names are different,
|
||||
# but it means the same thing.
|
||||
#
|
||||
# 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"
|
||||
|
||||
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||
|
||||
# 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
|
||||
# server root location
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||
)
|
||||
|
||||
# debug and debug toolbar settings
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
USE_DEBUG_TOOLBAR = DEBUG
|
||||
|
||||
# allow template debug outputs on {{ project_branch }} environment
|
||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||
|
||||
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||
|
||||
# -----------------------------------------
|
||||
# Debug logging to the console
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
|
||||
" %(thread)d %(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
|
||||
'code': {
|
||||
'format': "%(module)s:%(funcName)s - %(message)s"
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'{{ file_debug_handler__name_project }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_project}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'{{ file_debug_handler__name_server }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_server}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple'
|
||||
},
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.debug': {
|
||||
# use the console for logging
|
||||
'handlers':
|
||||
[
|
||||
'console',
|
||||
'{{ file_debug_handler__name_project }}',
|
||||
'{{ file_debug_handler__name_server }}',
|
||||
],
|
||||
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
# import this AFTER all the above
|
||||
from {{ project_name }}._settings.{{ project_branch }}_custom import *
|
||||
|
|
|
|||
136
share/templates/conf/gunicorn/files/local.generated.jinja2
Normal file
136
share/templates/conf/gunicorn/files/local.generated.jinja2
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
# this file contains settings that are automatically generated
|
||||
# put custom commands/ imports in a separate file!
|
||||
|
||||
LOCAL_SETTINGS = True # avoid recursive imports
|
||||
BRANCH = '{{ project_branch }}'
|
||||
|
||||
from {{ project_name }}.settings import *
|
||||
|
||||
import logging
|
||||
|
||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
TEMPLATES[0]['DIRS'].append(
|
||||
"{{paths_django_templates}}")
|
||||
|
||||
#
|
||||
# NOTE: a lot of the code in these local settings files are automated and you
|
||||
# might be inclined to take them out and move them into the main settings.py
|
||||
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
|
||||
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
|
||||
# Once I set that file, THEN all the rest of the information can be automated.
|
||||
# So all these automated info needs to be here.
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': '{{server_database_backend}}',
|
||||
|
||||
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# directory from which we serve static files
|
||||
#
|
||||
# NOTE: both STATIC and MEDIA roots are getting their values from the
|
||||
# initialization files that are set up above. Also, MEDIA_ROOT is being set
|
||||
# to something called "paths.server.media.dynamic" - the names are different,
|
||||
# but it means the same thing.
|
||||
#
|
||||
# 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"
|
||||
|
||||
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||
|
||||
# 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
|
||||
# server root location
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||
)
|
||||
|
||||
# debug and debug toolbar settings
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
USE_DEBUG_TOOLBAR = DEBUG
|
||||
|
||||
# allow template debug outputs on {{ project_branch }} environment
|
||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||
|
||||
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||
|
||||
# -----------------------------------------
|
||||
# Debug logging to the console
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
|
||||
" %(thread)d %(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
|
||||
'code': {
|
||||
'format': "%(module)s:%(funcName)s - %(message)s"
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'{{ file_debug_handler__name_project }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_project}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'{{ file_debug_handler__name_server }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_server}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple'
|
||||
},
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.debug': {
|
||||
# use the console for logging
|
||||
'handlers':
|
||||
[
|
||||
'console',
|
||||
'{{ file_debug_handler__name_project }}',
|
||||
'{{ file_debug_handler__name_server }}',
|
||||
],
|
||||
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,138 +1,9 @@
|
|||
# this file contains settings that are automatically generated
|
||||
# put custom commands/ imports in a separate file!
|
||||
|
||||
LOCAL_SETTINGS = True # avoid recursive imports
|
||||
BRANCH = '{{ project_branch }}'
|
||||
|
||||
from {{ project_name }}.settings import *
|
||||
from {{ project_name }}._settings.{{ project_branch }}_generated import *
|
||||
|
||||
import logging
|
||||
|
||||
LOCAL_LOGGING_PREFIX = "%s %%(message)s" % BRANCH
|
||||
logging.basicConfig(format=LOCAL_LOGGING_PREFIX, level=logging.DEBUG)
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
TEMPLATES[0]['DIRS'].append(
|
||||
"{{paths_django_templates}}")
|
||||
|
||||
#
|
||||
# NOTE: a lot of the code in these local settings files are automated and you
|
||||
# might be inclined to take them out and move them into the main settings.py
|
||||
# file. That would be a mistake. These automatic files AT THE VERY LEAST have
|
||||
# one variable, and that is WHICH BRANCH CONFIGURATION FILE ARE WE LOOKING AT.
|
||||
# Once I set that file, THEN all the rest of the information can be automated.
|
||||
# So all these automated info needs to be here.
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': '{{server_database_backend}}',
|
||||
|
||||
'NAME': '{db_name}'.format(db_name='{{server_database_name}}'),
|
||||
'USER': '{db_user}'.format(db_user='{{server_database_user}}'),
|
||||
'PASSWORD': '{db_pass}'.format(db_pass='{{server_database_password}}'),
|
||||
'HOST': '{db_host}'.format(db_host='{{server_database_host}}'),
|
||||
'PORT': '{db_port}'.format(db_port='{{server_database_port}}'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# directory from which we serve static files
|
||||
#
|
||||
# NOTE: both STATIC and MEDIA roots are getting their values from the
|
||||
# initialization files that are set up above. Also, MEDIA_ROOT is being set
|
||||
# to something called "paths.server.media.dynamic" - the names are different,
|
||||
# but it means the same thing.
|
||||
#
|
||||
# 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"
|
||||
|
||||
STATIC_ROOT = '{{paths_server_media_static}}'
|
||||
MEDIA_ROOT = '{{paths_server_media_dynamic}}'
|
||||
|
||||
# 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
|
||||
# server root location
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join("{{paths_project_root}}", "share", "media"),
|
||||
)
|
||||
|
||||
# debug and debug toolbar settings
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
USE_DEBUG_TOOLBAR = DEBUG
|
||||
|
||||
# allow template debug outputs on {{ project_branch }} environment
|
||||
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
|
||||
|
||||
ALLOWED_HOSTS = {{ project_django_allowedhosts }}
|
||||
|
||||
# -----------------------------------------
|
||||
# Debug logging to the console
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': "%(levelname)s %(asctime)s %(module)s %(process)d"
|
||||
" %(thread)d %(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '%(levelname)s %(message)s'
|
||||
},
|
||||
|
||||
'code': {
|
||||
'format': "%(module)s:%(funcName)s - %(message)s"
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'{{ file_debug_handler__name_project }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_project}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'{{ file_debug_handler__name_server }}': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
|
||||
'filename':
|
||||
'{{file_debug_handler__path_server}}',
|
||||
|
||||
'formatter': 'code'
|
||||
},
|
||||
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple'
|
||||
},
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.debug': {
|
||||
# use the console for logging
|
||||
'handlers':
|
||||
[
|
||||
'console',
|
||||
'{{ file_debug_handler__name_project }}',
|
||||
'{{ file_debug_handler__name_server }}',
|
||||
],
|
||||
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
# import this AFTER all the above
|
||||
from {{ project_name }}._settings.{{ project_branch }}_custom import *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue