3. Settings Config File
This is a list of available settings that can be modified
to customize the behavior of your application.
3.1. Items
-
settings.APP_NAME
- The application name. The default is kay_main.
-
settings.DEFAULT_TIMEZONE
- The default local timezone in string, e.g: ‘Asia/Tokyo’. The default is Asia/Tokyo. If it’s not specified Kay automatically set UTC. You can get the valid TimeZone list by reffering to kay/lib/pytz/all_timezone.
-
settings.DEBUG
This attribute has different effect on local dev server and
appengine server.
Local environment:
If DEBUG is set to True, werkzeug’s debugger will come up on any
uncaught exception. Otherwise, it just displays 500 error, and
tracebacks will be printed on console.
Server environment:
If DEBUG is set to True, it displays tracebacks on your browser
on any uncaught exception. Otherwise, it displays a simple error
message to end users, and tracebacks will be sent to
administrators by email.
-
settings.PROFILE
- If set to True, a profiling information will be displayed on the
browser following normal application’s response. The default is False.
-
settings.PRINNT_CALLERS_ON_PROFILING
- If set to True, callers will displayed on the browser with profiling information. The default is False.
-
settings.PRINNT_CALLEES_ON_PROFILING
- If set to True, callees will displayed on the browser with profiling information. The default is False.
-
settings.SECRET_KEY
- The seed to generate a hash value. The default is ReplaceItWithSecretString. Please be sure to rewrite this.
-
settings.SESSION_PREFIX
- The prefix of session name. The default is gaesess:.
-
settings.COOKIE_AGE
- The cookie’s age. The default is 1209600 seconds (2 weeks).
-
settings.COOKIE_NAME
- The cookie’s name. The default is KAY_SESSION.
-
settings.SESSION_MEMCACHE_AGE
- The session information’s age. The default is 3600 seconds (1 hour).
-
settings.LANG_COOKIE_NAME
- The cookie’s name for the language. The default is hl.
If i18n is enabled, Kay will display pages in the language specified with this cookie.
Otherwise Kay identifies the language from Accept-Language setting of the browser.
-
settings.CACHE_MIDDLEWARE_SECONDS
- Specify how long to remain caches of HTML responses that views returned.
The default is 3600 (1 hour).
-
settings.CACHE_MIDDLEWARE_NAMESPACE
- The namespace of HTML response cache. The default is CACHE_MIDDLEWARE.
-
settings.CACHE_MIDDLEWARE_ANONYMOUS_ONLY
- If set to True, HTML response cache will remain only while user login. The default is True.
-
settings.ADD_APP_PREFIX_TO_KIND
- If set to True, you can add an application prefix to db.Model.kind() method.
The value of kind() will set to be applicationname_modelname (uncapitalized).
-
settings.FORMS_USE_XHTML
- If set to True, kay.utils.forms renders forms in an
xhtml comliant manner. The default is False.
-
settings.ROOT_URL_MODULE
- You can have another URL settings file other than urls.py of each application.
Specify the URL file’s module name here. The default is urls.
-
settings.MEDIA_URL
- The path to media files. The defautl is /media.
-
settings.INTERNAL_MEDIA_URL
- The path to media files directory that bundle applications (e.g. kay.auto ) use.
The default is /_media.
-
settings.ADMINS
Specify the administrator’s username and email address in this tuple.
If some exception occurs on the server, Kay send the traceback to this email address.
This function works when you disable Debug ( DEBUG=False ).
(setting example)
ADMINS = (
('John', 'john@example.com'),
('Mary', 'mary@example.com')
)
-
settings.TEMPLATE_DIRS
- Allows you to specify the directory where Kay will look for your
templates. This is a list of relative paths from your project root
to your template directories.
-
settings.USE_I18N
If set to True, i18n works. The default is True.
-
settings.INSTALLED_APPS
- This tupple must contain application names you want to
activate. Default value is an empty tupple.
-
settings.APP_MOUNT_POINTS
Specify the URL path to access each application in this dictionary.
The key is the applicaion and the value is the URL path.
If not specified, the URL path will be set /application's module name by default.
APP_MOUNT_POINTS = {
'bbs': '/',
'categories': '/c',
}
-
settings.CONTEXT_PROCESSORS
Specify the path of context processors in this tuple.
If you add context proccssors,
you can add contexts template engine use in rendering. The default as follows.
CONTEXT_PROCESSORS = (
'kay.context_processors.request',
'kay.context_processors.url_functions',
'kay.context_processors.media_url',
)
-
settings.JINJA2_FILTERS
- A dictionary of filter name to callable filters that are automatically
loaded into the Jinja2 environment.
-
settings.JINJA2_ENVIRONMENT_KWARGS
The keyword arguments passed to Jinja2 contructor. The default is following.
JINJA2_ENVIRONMENT_KWARGS = {
'autoescape': True,
}
-
settings.JINJA2_EXTENSIONS
- A list of Jinja2 extension classes. These are automatically
imported and loaded into the Jinja2 environment.
-
settings.SUBMOUNT_APPS
- If you’d like to run applications with entirely-differnt settings, you can set them here. The default is an empty tuple.
-
settings.MIDDLEWARE_CLASSES
Specify additional middlewares to this tuple.
MIDDLEWARE_CLASSES = (
'kay.auth.middleware.AuthenticationMiddleware',
)
-
settings.AUTH_USER_BACKEND
The backend class for user authentication. The default is kay.auth.backend.GoogleBackend.
-
settings.AUTH_USER_MODEL
The model class for saving the user data authenticated by the backend.
When you use the user class inherites from GoogleUser for authentication,
you have to set it here. The defautl is kay.auth.models.GoogleUser.
-
settings.USE_DB_HOOK
- If set to True, DB hook is enabled. DB hook is similar to Django’s signal.
You can run some processes when datastore is accessed.
If you are unfamiliar with DB hook, you should set this to False.
The default is False.