Every Gizmo(QP) site provides a SitePublisher class, that is a subclass of
gz.pub.publisher.Publisher, that defines a configuration class
attribute, that is a dict object. The configuration dict items control
many aspects of the site, such as scgi port, durus database server,
max number of child web processes, etc.
An application is free to add its own custom items, to use as it needs.
Configuration items are accessed with Publisher.get(key, default).
It is recommended that a dedicated configuration.py file is used to define
a site’s configuration.
Managing configuration for dev and live deployments
When Publisher.is_live_host() is True, the method
Publisher.set_live_configuration() gets called.
To specify any configuration modifications for live deployment it is only
necessary to supply a definition of this method — this demo uses the
combination of this method (see the Demo SitePublisher
source) and a second dictionary, here called configuration_live,
to update from.
Python source : demo site configuration dictionary | configuration.py#code |
from os.path import join, dirname
import gz.gizmo
configuration = dict(
durus_address=(‘127.0.0.1’, 6075),
scgi_address=(‘127.0.0.1′, 7075),
http_address=(”, 8075),
live_host=’ks39074.kimsufi.com’, # from socket import getfqdn; getfqdn()
webmaster_address=’[email protected]’,
is_email_enabled=True,
display_exceptions=True,
secure=False,
doctype=’XHTML_10_Transitional’,
robotstxt=’User-agent: *\nDisallow: /\n’,
static_cache_time=60,
# SiteRoot-relative URL Paths, by name :
# – The basekey parameter of Publisher.get_url_path_for(basekey, filename)
# must be one of the keys of this dictionary.
# – Actual path value used at runtime is
# common.script_name_path(url_paths[name]), i.e. as returned by
# Publisher.get_url_path_for(name).
# – The value for url_paths[None] determines behaviour of
# Publisher.get_url_path_for(None).
url_paths = {
None: None,
‘assets’: ‘/assets/’,
‘gza’: ‘/gza/’,
‘login’: ‘/login/’,
‘logout’: ‘/login/logout’,
‘register’: ‘/register/’,
},
# File System paths, by name :
# – The basekey parameter of Publisher.get_file_path_for(basekey, filename)
# must be one of the keys of this dictionary.
# – Values must be absolute, or relative to site.get_package_directory().
# – The value for file_paths[None] determines behaviour of
# Publisher.get_file_path_for(None).
file_paths = {
None: dirname(__file__),
‘demo’: dirname(__file__), # evoque template collection
‘gz’: dirname(gz.__file__), # evoque template collection
‘favicon’: ‘static/favicon.png’,
‘assets’: ‘static’,
‘gza’: join(dirname(gz.gizmo.__file__), ‘assets’),
‘pages’: ‘pages’, # evoque template collection
‘templates’: ‘templates’, # evoque default template collection
},
# Used by User Admin facility, gz.fill.admin_users
permissions=[
‘administrator’,
],
realms=[
‘gzdemo’, # [0] is default realm
],
)
”’
If Publisher.is_live_host(), then the Site configuration is (recursively)
updated from the following dict, i.e. attributes that are dicts are also
respectively updated (not overwritten).
”’
configuration_live = dict(
scgi_address=(‘127.0.0.1’, 7075),
# Uncomment line below to cuase redirect of all pages requiring login to https
#https_address=(‘demo.gizmojo.org’, 443),
max_children=2,
# False => error page response is delegated to Publisher.hide_exception()
display_exceptions=False,
# True => will cause redirect to https on requests to pages that should
# only be served encrypted (such as login page) — if https is available.
secure=True,
# Allow robots full access on live site
robotstxt=’User-agent: *\nDisallow: \n’,
# Cache time for static files
static_cache_time=6000,
)