djangofloor.conf.callables

Callables settings

Dynamic

class djangofloor.conf.callables.DefaultListenAddress(value)[source]
get_value(merger, provider_name: str, setting_name: str)[source]
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']
process_django_allauth(settings_dict)[source]
process_third_parties(settings_dict)[source]
required_settings = ['ALLAUTH_PROVIDER_APPS', 'USE_ALL_AUTH', 'USE_DEBUG_TOOLBAR', 'USE_PIPELINE', 'USE_REST_FRAMEWORK', 'USE_PAM_AUTHENTICATION', 'RAVEN_DSN']
social_apps = {'allauth.socialaccount.providers.edmodo', 'allauth.socialaccount.providers.stripe', 'allauth.socialaccount.providers.twitter', 'allauth.socialaccount.providers.vimeo', 'allauth.socialaccount.providers.draugiem', 'allauth.socialaccount.providers.openid', 'allauth.socialaccount.providers.spotify', 'allauth.socialaccount.providers.persona', 'allauth.socialaccount.providers.linkedin', 'allauth.socialaccount.providers.orcid', 'allauth.socialaccount.providers.shopify', 'allauth.socialaccount.providers.line', 'allauth.socialaccount.providers.soundcloud', 'allauth.socialaccount.providers.untappd', 'allauth.socialaccount.providers.discord', 'allauth.socialaccount.providers.pinterest', 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.flickr', 'allauth.socialaccount.providers.twentythreeandme', 'allauth.socialaccount.providers.gitlab', 'allauth.socialaccount.providers.odnoklassniki', 'allauth.socialaccount.providers.foursquare', 'allauth.socialaccount.providers.robinhood', 'allauth.socialaccount.providers.kakao', 'allauth.socialaccount.providers.stackexchange', 'allauth.socialaccount.providers.bitly', 'allauth.socialaccount.providers.bitbucket', 'allauth.socialaccount.providers.reddit', 'allauth.socialaccount.providers.xing', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.windowslive', 'allauth.socialaccount.providers.asana', 'allauth.socialaccount.providers.bitbucket_oauth2', 'allauth.socialaccount.providers.fxa', 'allauth.socialaccount.providers.slack', 'allauth.socialaccount.providers.mailru', 'allauth.socialaccount.providers.basecamp', 'allauth.socialaccount.providers.digitalocean', 'allauth.socialaccount.providers.paypal', 'allauth.socialaccount.providers.angellist', 'allauth.socialaccount.providers.baidu', 'allauth.socialaccount.providers.weibo', 'allauth.socialaccount.providers.twitch', 'allauth.socialaccount.providers.instagram', 'allauth.socialaccount.providers.eveonline', 'allauth.socialaccount.providers.vk', 'allauth.socialaccount.providers.feedly', 'allauth.socialaccount.providers.auth0', 'allauth.socialaccount.providers.naver', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.coinbase', 'allauth.socialaccount.providers.evernote', 'allauth.socialaccount.providers.hubic', 'allauth.socialaccount.providers.tumblr', 'allauth.socialaccount.providers.mailchimp', 'allauth.socialaccount.providers.amazon', 'allauth.socialaccount.providers.douban', 'allauth.socialaccount.providers.linkedin_oauth2', 'allauth.socialaccount.providers.weixin'}
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.allauth_provider_apps(settings_dict)[source]
djangofloor.conf.callables.allowed_hosts(settings_dict)[source]
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.generate_secret_key(django_ready, length=60)[source]
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.secure_hsts_seconds(settings_dict)[source]
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.template_setting(settings_dict)[source]
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