djangofloor.conf.callables
¶
Callables settings¶
Dynamic
-
class
djangofloor.conf.callables.
ExcludedDjangoCommands
[source]¶ -
required_settings
= ['DEVELOPMENT', 'USE_CELERY', 'DEBUG']¶
-
-
class
djangofloor.conf.callables.
InstalledApps
[source]¶ Provide a complete INSTALLED_APPS list, transparently adding common third-party packages. Specifically handle apps required by django-allauth (one by allowed method).
-
common_third_parties
= OrderedDict([('USE_DEBUG_TOOLBAR', 'debug_toolbar'), ('USE_PIPELINE', 'pipeline'), ('USE_REST_FRAMEWORK', 'rest_framework'), ('USE_PAM_AUTHENTICATION', 'django_pam'), ('RAVEN_DSN', 'raven.contrib.django.raven_compat')])¶
-
default_apps
= ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.humanize', 'django.contrib.sitemaps', 'django.contrib.sites', ExpandIterable('DF_INSTALLED_APPS'), 'bootstrap3', 'djangofloor', 'django.contrib.staticfiles', 'django.contrib.admin']¶
-
required_settings
= ['ALLAUTH_PROVIDER_APPS', 'USE_ALL_AUTH', 'USE_DEBUG_TOOLBAR', 'USE_PIPELINE', 'USE_REST_FRAMEWORK', 'USE_PAM_AUTHENTICATION', 'RAVEN_DSN']¶
-
-
class
djangofloor.conf.callables.
RedisSmartSetting
(prefix='', env_variable='REDIS_URL', fmt='url', extra_values=None)[source]¶ Handle values required for Redis configuration, as well as Heroku’s standard environment variables. Can be used as
djangofloor.conf.config_values.CallableSetting
.-
config_values
= ['PROTOCOL', 'HOST', 'PORT', 'DB', 'PASSWORD']¶
-
-
djangofloor.conf.callables.
cache_setting
(settings_dict)[source]¶ - Automatically compute cache settings:
- if debug mode is set, then caching is disabled
- if django_redis is available, then Redis is used for caching
- else memory is used
Parameters: settings_dict – Returns:
-
djangofloor.conf.callables.
database_engine
(settings_dict)[source]¶ Allow to use aliases for database engines, as well as the default dotted name
-
djangofloor.conf.callables.
databases
(settings_dict)[source]¶ Build a complete DATABASES setting, taking into account the DATABASE_URL environment variable if present (used on the Heroku platform).
-
djangofloor.conf.callables.
project_name
(settings_dict)[source]¶ Transform the base module name into a nicer project name
>>> project_name({'DF_MODULE_NAME': 'my_project'}) 'My Project'
Parameters: settings_dict – Returns:
-
djangofloor.conf.callables.
required_packages
(settings_dict)[source]¶ Return a sorted list of the Python packages required by the current project (with their dependencies). A warning is added for each missing package.
Parameters: settings_dict – Returns:
-
djangofloor.conf.callables.
smart_hostname
(settings_dict)[source]¶ By default, use the listen address and port as server name. Use the “HEROKU_APP_NAME” environment variable if present.
Parameters: settings_dict – Returns:
-
djangofloor.conf.callables.
url_parse_prefix
(settings_dict)[source]¶ Return the public URL prefix, given the public base URL
>>> url_parse_prefix({'SERVER_BASE_URL': 'https://demo.example.org/demo/'}) '/demo/' >>> url_parse_prefix({'SERVER_BASE_URL': 'http://demo.example.org/'}) '/' >>> url_parse_prefix({'SERVER_BASE_URL': 'https://demo.example.org:8010'}) '/'
-
djangofloor.conf.callables.
url_parse_server_name
(settings_dict)[source]¶ Return the public hostname, given the public base URL
>>> url_parse_server_name({'SERVER_BASE_URL': 'https://demo.example.org/'}) 'demo.example.org'
-
djangofloor.conf.callables.
url_parse_server_port
(settings_dict)[source]¶ Return the public port, given the public base URL
>>> url_parse_server_port({'SERVER_BASE_URL': 'https://demo.example.org/', 'USE_SSL': True}) 443 >>> url_parse_server_port({'SERVER_BASE_URL': 'http://demo.example.org/', 'USE_SSL': False}) 80 >>> url_parse_server_port({'SERVER_BASE_URL': 'https://demo.example.org:8010/', 'USE_SSL': True}) 8010
-
djangofloor.conf.callables.
url_parse_server_protocol
(settings_dict)[source]¶ Return the public HTTP protocol, given the public base URL
>>> url_parse_server_protocol({'USE_SSL': True}) 'https'
>>> url_parse_server_protocol({'USE_SSL': False}) 'http'
-
djangofloor.conf.callables.
url_parse_ssl
(settings_dict)[source]¶ Return True if the public URL uses https
>>> url_parse_ssl({'SERVER_BASE_URL': 'https://demo.example.org/demo/'}) True >>> url_parse_ssl({'SERVER_BASE_URL': 'http://demo.example.org/'}) False
-
djangofloor.conf.callables.
use_x_forwarded_for
(settings_dict)[source]¶ Return True if this server is assumed to be behind a reverse proxy. Heuristic: the external port (in SERVER_PORT) is different from the actually listened port (in LISTEN_ADDRESS).
>>> use_x_forwarded_for({'SERVER_PORT': 8000, 'LISTEN_ADDRESS': 'localhost:8000'}) False >>> use_x_forwarded_for({'SERVER_PORT': 443, 'LISTEN_ADDRESS': 'localhost:8000'}) True