Permalink
Browse files

Reorganize setting files.

Now settings are semantically split over several .conf files. A sample
configuration file with settings that are likely to be customized is
provided as 90-local.conf.sample.

This fixes bug 2246.
  • Loading branch information...
1 parent a3f29b1 commit a36f2df9cf202cd98076cb3887125b2a2cf7427f @julen julen committed Jun 25, 2012
View
2 pootle/settings.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import os.path
+import os
import glob
from install_dirs import *
View
230 pootle/settings/10-base.conf
@@ -1,72 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-#
-# Copyright 2008-2012 Zuza Software Foundation
-#
-# This file is part of Pootle.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-"""This is a standard module defining some Django settings, as well as some
-settings specific to Pootle.
+"""Base configuration settings."""
-Note that some of this can also be specified in localsettings.py in order to have a
-configuration override outside of the code."""
-
-import logging
-import os
-
-from pootle.install_dirs import *
-
-INTERNAL_IPS = ('127.0.0.1',)
-ADMINS = (
- # ('Your Name', 'your_email@domain.com'),
-)
-
-MANAGERS = ADMINS
-
-# dummy translate function so we can extract text
+# Dummy translate function so we can extract text
_ = lambda x: x
TITLE = _("Pootle Demo")
-#l10n: Change the language code (en) to your language code, and replace ltr with rtl if you language is written from right to left.
+#l10n: Change the language code (en) to your language code, and replace
+# ltr with rtl if you language is written from right to left.
DESCRIPTION = _("""<div dir="ltr" lang="en">
<h2 class="title">This is a demo installation of Pootle.</h2>
<p class="about">You can also visit the official <a class="external" href="http://pootle.locamotion.org">Pootle server</a>. The server administrator has not provided contact information or a description of this server. If you are the administrator for this server, edit this description in your preference file or in the administration interface.</p>
</div>""")
+
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
-TIME_ZONE = 'Africa/Johannesburg'
+TIME_ZONE = 'UTC'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
-SITE_ID = 1
-
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
+
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = data_path('static')+'/'
+MEDIA_ROOT = data_path('static') + '/'
+
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
@@ -80,184 +49,3 @@ ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
# TODO: We should find a way to reset this for new installations.
SECRET_KEY = '^&4$dlpce2_pnronsi289xd7-9ke10q_%wa@9srm@zaa!ig@1k'
-
-MIDDLEWARE_CLASSES = (
- 'pootle_misc.middleware.baseurl.BaseUrlMiddleware', # resolves paths
- 'django.middleware.transaction.TransactionMiddleware', # needs to be before anything that writes to the db
- 'pootle_misc.middleware.siteconfig.SiteConfigMiddleware', # must be early to detect the need to install or update schema, but must precede the cache middleware
- 'django.middleware.cache.UpdateCacheMiddleware', # must be as high as possible (see above)
- 'django.middleware.http.ConditionalGetMiddleware', # support for e-tag
- 'django.middleware.gzip.GZipMiddleware', # compress responses
- 'django.middleware.csrf.CsrfViewMiddleware', # protection against cross-site request forgery
- 'django.contrib.sessions.middleware.SessionMiddleware', # must be before authentication
- 'django.contrib.auth.middleware.AuthenticationMiddleware', # must be before anything user-related
- 'django.middleware.locale.LocaleMiddleware', # user-related
- 'pootle.middleware.setlocale.SetLocale', # sets Python's locale based on request's locale for sorting, etc.
- 'pootle_misc.middleware.errorpages.ErrorPagesMiddleware', # nice 500 and 403 pages (must be after locale to have translated versions)
- 'django.middleware.common.CommonMiddleware',
- #'pootle.middleware.check_cookies.CheckCookieMiddleware',
- 'pootle.middleware.captcha.CaptchaMiddleware', # must be early in the response cycle (close to bottom)
- #'pootle.middleware.profile.ProfilerMiddleware',
- 'django.middleware.cache.FetchFromCacheMiddleware' # must be last in the request cycle (at the bottom)
-)
-
-CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
-
-ROOT_URLCONF = 'pootle.urls'
-
-TEMPLATE_CONTEXT_PROCESSORS = (
- "django.contrib.auth.context_processors.auth",
- "django.core.context_processors.i18n",
- "django.core.context_processors.media",
- "django.core.context_processors.request",
- "pootle_misc.context_processors.pootle_context",
-)
-
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
- data_path('local_templates'),
- data_path('templates'),
-)
-
-INSTALLED_APPS = (
- 'django.contrib.sessions',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sites',
- 'django.contrib.admin',
- # Pootle-specific
- 'pootle_app',
- 'pootle_misc',
- 'pootle_store',
- 'pootle_language',
- 'pootle_project',
- 'pootle_translationproject',
- 'pootle_profile',
- 'pootle_statistics',
- 'pootle_notifications',
- 'pootle_autonotices',
- 'pootle_terminology',
- 'legalpages',
- # External apps
- 'registration',
- 'profiles',
- 'djblets.siteconfig',
- 'djblets.util',
- 'contact_form_i18n',
- 'django_assets',
- 'voting',
-)
-
-AUTH_PROFILE_MODULE = "pootle_profile.PootleProfile"
-
-# number of rows in top contributors table
-TOPSTAT_SIZE = 5
-
-# django-registration configs
-ACCOUNT_ACTIVATION_DAYS = 10
-
-# keep stats cache for roughly a month
-OBJECT_CACHE_TIMEOUT = 2500000
-
-# terminology config
-MIN_AUTOTERMS = 60
-MAX_AUTOTERMS = 600
-
-# defaults for localsettings vars
-CONTACT_EMAIL = None
-USE_CAPTCHA = True
-AUTOSYNC = False
-MT_BACKENDS = ()
-LOOKUP_BACKENDS = ()
-CAN_CONTACT = True
-LIVE_TRANSLATION = False
-PODIRECTORY = working_path('po')
-DEBUG = False
-
-# By default Pootle sends only text emails. If your organization would
-# prefer to send mixed HTML/TEXT emails, set this to True, and update
-# activation_email.txt and activation_email.html in the templates/registration/
-# directory.
-# NOTE: Password reset emails will still be sent in plain text. This is a limitation
-# of the underlying system.
-EMAIL_SEND_HTML = False
-
-if CONTACT_EMAIL:
- MANAGERS += (('CONTACT', CONTACT_EMAIL),)
-
-if LIVE_TRANSLATION:
- # Look for localization files under PODIRECTORY/pootle
- LOCALE_PATHS = (os.path.join(PODIRECTORY, "pootle"), )
-else:
- # look for localization files under mo directory
- LOCALE_PATHS = (data_path("mo"), )
-
-from pootle.i18n import override, gettext_live, gettext
-from django.utils import translation
-from django.utils.translation import trans_real
-
-LANGUAGES = override.find_languages(LOCALE_PATHS[0])
-
-def hijack_translation():
- """sabotage django's fascist linguistical regime"""
- # override functions that check if language if language is
- # known to Django
- translation.check_for_language = lambda lang_code: True
- trans_real.check_for_language = lambda lang_code: True
- translation.get_language_from_request = override.get_language_from_request
-
- # override django's inadequate bidi detection
- translation.get_language_bidi = override.get_language_bidi
-
- if LIVE_TRANSLATION:
- trans_real.translation = override.translation_dummy
- override.override_gettext(gettext_live)
- else:
- # even when live translation is not enabled we hijack
- # gettext functions to install the safe variable
- # formatting override
- override.override_gettext(gettext)
-
-hijack_translation()
-
-
-# setup a tempdir inside the PODIRECTORY heirarchy, this way we have
-# reasonable guarantee that temp files will be created on the same
-# filesystem as translation files (required for save operations).
-import tempfile
-tempfile.tempdir = os.path.join(PODIRECTORY, ".tmp")
-# ensure that temp dir exists
-if not os.path.exists(tempfile.tempdir):
- os.mkdir(tempfile.tempdir)
-
-TEMPLATE_DEBUG = DEBUG
-if TEMPLATE_DEBUG:
- TEMPLATE_CONTEXT_PROCESSORS += ("django.core.context_processors.debug",)
-
-if DEBUG:
- TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
- )
-else:
- # We should only enable caching with DEBUG = False
- TEMPLATE_LOADERS = (
- ('django.template.loaders.cached.Loader', (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
- )),
- )
-
-if DEBUG:
- logging.basicConfig(
- level=logging.DEBUG,
- format='%(asctime)s %(levelname)s %(message)s',
- )
-else:
- # Will log only CRITICAL errors to the console
- logging.basicConfig(
- level=logging.INFO,
- format='%(asctime)s %(levelname)s %(message)s',
- )
View
52 pootle/settings/20-backends.conf
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Data-base and caching configuration settings."""
+
+
+# Database backend settings
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': working_path('dbs/pootle.db'),
+ 'USER': '',
+ 'PASSWORD': '',
+ 'HOST': '',
+ 'PORT': '',
+ }
+}
+
+
+# Cache Backend settings
+#
+# By default we use Django's database cache which is only suitable
+# for small deployments. memcached is preferred. For more info, check
+# http://docs.djangoproject.com/en/dev/topics/cache/#setting-up-the-cache
+CACHE_BACKEND = 'db://pootlecache?max_entries=65536&cull_frequency=16'
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
+ 'LOCATION': 'pootlecache',
+ 'TIMEOUT': 60,
+ 'OPTIONS': {
+ 'MAX_ENTRIES': 65536,
+ 'CULL_FREQUENCY': 16,
+ }
+ }
+}
+
+# Using memcached to store sessions improves performance for anonymous
+# users. For more info, check
+# http://docs.djangoproject.com/en/dev/topics/http/sessions/#configuring-the-session-engine
+# Uncomment this if you're using memcached as CACHE_BACKEND
+SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
+
+# To improve performance, non-logged users get cached copies of most pages.
+# This variable is the number of seconds for which a page will be reused from
+# cache. If you have a small server where more real-time statistics is
+# important, you can make this lower.
+CACHE_MIDDLEWARE_SECONDS = 600
+CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
+
+# Keep stats cache for roughly a month
+OBJECT_CACHE_TIMEOUT = 2500000
View
38 pootle/settings/30-site.conf
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Site-specific settings."""
+
+
+SITE_ID = 1
+
+INTERNAL_IPS = ('127.0.0.1',)
+
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+DEBUG = False
+
+
+# Set this to False to disable user registration, admins will still be
+# able to create user accounts.
+CAN_REGISTER = True
+
+# Address used for messages sent by Pootle.
+DEFAULT_FROM_EMAIL = 'info@YOUR_DOMAIN.com'
+
+# Address to receive messages sent by contact form.
+CONTACT_EMAIL = 'info@YOUR_DOMAIN.com'
+CAN_CONTACT = True
+
+# By default Pootle uses SMTP server on localhost, if the server is
+# not configured for sending emails use these settings to setup an
+# external outgoing SMTP server.
+EMAIL_HOST_USER = ''
+EMAIL_HOST_PASSWORD = ''
+EMAIL_HOST = ''
+EMAIL_PORT = 587
+EMAIL_USE_TLS = True
View
60 pootle/settings/40-apps.conf
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Configuration settings for applications used by Pootle."""
+
+#
+# Pootle
+#
+
+# Number of rows in top contributors table
+TOPSTAT_SIZE = 5
+
+# Terminology config
+MIN_AUTOTERMS = 60
+MAX_AUTOTERMS = 600
+
+# Two-tuple defining the markup filter to apply in certain textareas.
+# - Accepted values for the first element are 'textile', 'markdown',
+# 'restructuredtext' and None
+# - The second element should be a dictionary of keyword arguments that
+# will be passed to the markup function
+#
+# Examples:
+# MARKUP_FILTER = (None, {})
+# MARKUP_FILTER = ('markdown', {'safe_mode': True})
+# MARKUP_FILTER = ('restructuredtext', {})
+MARKUP_FILTER = (None, {})
+
+# Set this to True to enable spam prevention through captcha, only
+# useful for public Pootle instances.
+USE_CAPTCHA = True
+
+
+#
+# webassets
+#
+
+# Whether to debug assets or not. Set to False in production environments
+# for better performance, but make sure 'cssmin' is installed.
+# Valid options are True, False, and "merge".
+# You can set more configuration options for webassets if needed.
+# Read its documentation for further details:
+# http://elsdoerfer.name/docs/webassets/django/settings.html
+ASSETS_DEBUG = DEBUG
+
+
+#
+# django-registration
+#
+
+# Number of days users will have to activate their accounts after registering
+ACCOUNT_ACTIVATION_DAYS = 10
+
+# By default Pootle sends only text emails. If your organization would
+# prefer to send mixed HTML/TEXT emails, set this to True, and update
+# activation_email.txt and activation_email.html in the templates/registration/
+# directory.
+# NOTE: Password reset emails will still be sent in plain text. This is a limitation
+# of the underlying system.
+EMAIL_SEND_HTML = False
View
209 pootle/settings/50-old_local.conf
@@ -1,209 +0,0 @@
-# This file contains the configuration settings for the Pootle server.
-#
-# It is in Python syntax. Everything after '#' is ignored as comments.
-
-# Mail settings
-
-# Address used for messages sent by Pootle.
-#DEFAULT_FROM_EMAIL = 'info@YOUR_DOMAIN.com'
-
-# Address to receive messages sent by contact form.
-#CONTACT_EMAIL = 'info@YOUR_DOMAIN.com'
-
-
-# Mail server settings
-
-# By default Pootle uses SMTP server on localhost, if the server is
-# not configured for sending emails use these settings to setup an
-# external outgoing SMTP server.
-
-# Example for Google as an external SMTP server
-#EMAIL_HOST_USER = 'USER@YOUR_DOMAIN.com'
-#EMAIL_HOST_PASSWORD = 'YOUR_PASSWORD'
-#EMAIL_HOST = 'smtp.gmail.com'
-#EMAIL_PORT = 587
-#EMAIL_USE_TLS = True
-
-
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- # Replace 'sqlite3' with 'postgresql_psycopg2', 'mysql' or 'oracle'.
- 'NAME': working_path('dbs/pootle.db'),
- # Database name or path to database file if using sqlite3.
- 'USER': '', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
- }
-}
-
-
-# The directory where the translation files are kept
-PODIRECTORY = working_path('po')
-
-# Live translation means that the project called "Pootle" is used to provide
-# the localised versions of Pootle. Set this to True to enable live translation
-# of pootle UI. This is a good way to learn how to use Pootle, but it has high
-# impact on performance.
-LIVE_TRANSLATION = False
-
-
-# File parse pool settings
-#
-# To avoid rereading and reparsing translation files from disk on
-# every request, Pootle keeps a pool of already parsed files in memory.
-#
-# Larger pools will offer better performance, but higher memory usage
-# (per server process). When the pool fills up, 1/PARSE_POOL_CULL_FREQUENCY
-# number of files will be removed from the pool.
-
-# DEFAULT: 40
-PARSE_POOL_SIZE = 40
-# DEFAULT: 4
-PARSE_POOL_CULL_FREQUENCY = 4
-
-
-# Cache Backend settings
-#
-# By default we use Django's database cache which is only suitable
-# for small deployments. memcached is preferred. For more info, check
-# http://docs.djangoproject.com/en/dev/topics/cache/#setting-up-the-cache
-CACHE_BACKEND = 'db://pootlecache?max_entries=65536&cull_frequency=16'
-CACHES = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
- 'LOCATION': 'pootlecache',
- 'TIMEOUT': 60,
- 'OPTIONS': {
- 'MAX_ENTRIES': 65536,
- 'CULL_FREQUENCY': 16,
- }
- }
-}
-
-# Uncomment to use memcached for caching
-#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
-#CACHES = {
-# 'default': {
-# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
-# 'LOCATION': '127.0.0.1:11211',
-# 'KEY_PREFIX': '',
-# }
-#}
-
-# Using memcached to store sessions improves performance for anonymous
-# users. For more info, check
-# http://docs.djangoproject.com/en/dev/topics/http/sessions/#configuring-the-session-engine
-# Uncomment this if you're using memcached as CACHE_BACKEND
-SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
-
-# To improve performance, non-logged users get cached copies of most pages.
-# This variable is the number of seconds for which a page will be reused from
-# cache. If you have a small server where more real-time statistics is
-# important, you can make this lower.
-# DEFAULT: 600
-CACHE_MIDDLEWARE_SECONDS = 600
-
-
-# Set this to False. DEBUG mode is only needed when testing betas or
-# hacking Pootle.
-DEBUG = False
-
-
-# Whether to debug assets or not. Set to False in production environments
-# for better performance, but make sure 'cssmin' is installed.
-# Valid options are True, False, and "merge".
-# You can set more configuration options for webassets if needed.
-# Read its documentation for further details:
-# http://elsdoerfer.name/docs/webassets/django/settings.html
-ASSETS_DEBUG = DEBUG
-
-
-# Two-tuple defining the markup filter to apply in certain textareas.
-# - Accepted values for the first element are 'textile', 'markdown',
-# 'restructuredtext' and None
-# - The second element should be a dictionary of keyword arguments that
-# will be passed to the markup function
-#
-# Examples:
-# MARKUP_FILTER = (None, {})
-# MARKUP_FILTER = ('markdown', {'safe_mode': True})
-# MARKUP_FILTER = ('restructuredtext', {})
-MARKUP_FILTER = (None, {})
-
-
-# Use the commented definition to authenticate first with an LDAP system and
-# then to fall back to Django's authentication system.
-#AUTHENTICATION_BACKENDS = ('pootle.auth.ldap_backend.LdapBackend', 'django.contrib.auth.backends.ModelBackend',)
-AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
-
-# LDAP Setup
-# The LDAP server. Format: protocol://hostname:port
-AUTH_LDAP_SERVER = ''
-# Anonymous Credentials
-AUTH_LDAP_ANON_DN = ''
-AUTH_LDAP_ANON_PASS = ''
-# Base DN to search
-AUTH_LDAP_BASE_DN = ''
-# What are we filtering on? %s will be the username, for example 'sn=%s', or 'uid=%s'.
-AUTH_LDAP_FILTER = ''
-# This is a mapping of Pootle field names to LDAP fields. The key is Pootle's name, the value should be your LDAP field name. If you don't use the field
-# or don't want to automatically retrieve these fields from LDAP comment them out. The only required field is 'dn'.
-AUTH_LDAP_FIELDS = {
- 'dn': 'dn',
- #'first_name':'',
- #'last_name':'',
- #'email':''
- }
-
-# Set this to False to disable user registration, admins will still be
-# able to create user accounts.
-CAN_REGISTER = True
-
-# Set this to True to enable spam prevention through captcha, only
-# useful for public Pootle instances.
-USE_CAPTCHA = True
-
-# Set this to True if you want translation files to be updated
-# immediatly.
-# Note that this negatively affects performance and
-# should be avoided unless another application needs direct access to
-# the files.
-AUTOSYNC = False
-
-# Set the backends you want to use to enable translation suggestions through
-# several online services. To disable this feature completely just comment all
-# the lines to set an empty list [] to the MT_BACKENDS setting.
-#
-# The second parameter for each backend option is the API key, which will
-# be used in case the service supports using an API key.
-#
-# Available options are:
-# 'APERTIUM': Apertium service.
-# For this service you need to set the API key.
-# Get your key at http://api.apertium.org/register.jsp
-# 'GOOGLE_TRANSLATE': Google Translate service.
-# For this service you need to set the API key.
-# Note that Google Translate API is a paid service
-# See more at http://code.google.com/apis/language/translate/v2/pricing.html
-#
-MT_BACKENDS = [
-# ('APERTIUM', ''),
-# ('GOOGLE_TRANSLATE', ''),
-]
-
-# Set the backends you want to use to allow web-based lookup. To disable this
-# feature completely just comment all the lines to set an empty list [] to the
-# LOOKUP_BACKENDS setting.
-LOOKUP_BACKENDS = [
-# 'wikipedia',
-]
-
-# URL used for the amaGama TM server.
-# The global amaGama service should work fine, but if your language/project
-# has a better server, or you want to use your own, you can define here
-# its URL.
-# This URL must point to the public API URL which returns JSON. Don't forget
-# the trailing slash.
-AMAGAMA_URL = 'http://amagama.locamotion.org/tmserver/'
View
98 pootle/settings/50-project.conf
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Pootle project-level configuration settings."""
+
+
+MIDDLEWARE_CLASSES = (
+ #: Resolves paths
+ 'pootle_misc.middleware.baseurl.BaseUrlMiddleware',
+ #: Needs to be before anything that writes to the db
+ 'django.middleware.transaction.TransactionMiddleware',
+ #: Must be early to detect the need to install or update schema,
+ #: but must precede the cache middleware
+ 'pootle_misc.middleware.siteconfig.SiteConfigMiddleware',
+ #: Must be as high as possible (see above)
+ 'django.middleware.cache.UpdateCacheMiddleware',
+ #: Support for e-tag
+ 'django.middleware.http.ConditionalGetMiddleware',
+ #: Compress responses
+ 'django.middleware.gzip.GZipMiddleware',
+ #: Protection against cross-site request forgery
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ #: Must be before authentication
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ #: Must be before anything user-related
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ #: User-related
+ 'django.middleware.locale.LocaleMiddleware',
+ #: Sets Python's locale based on request's locale for sorting, etc.
+ 'pootle.middleware.setlocale.SetLocale',
+ #: Nice 500 and 403 pages (must be after locale to have translated versions)
+ 'pootle_misc.middleware.errorpages.ErrorPagesMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ #'pootle.middleware.check_cookies.CheckCookieMiddleware',
+ #: Must be early in the response cycle (close to bottom)
+ 'pootle.middleware.captcha.CaptchaMiddleware',
+ #'pootle.middleware.profile.ProfilerMiddleware',
+ #: Must be last in the request cycle (at the bottom)
+ 'django.middleware.cache.FetchFromCacheMiddleware',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+ "django.contrib.auth.context_processors.auth",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.media",
+ "django.core.context_processors.request",
+ "pootle_misc.context_processors.pootle_context",
+)
+
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or
+ # "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+ data_path('local_templates'),
+ data_path('templates'),
+)
+
+
+INSTALLED_APPS = (
+ 'django.contrib.sessions',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ # Pootle-specific
+ 'pootle_app',
+ 'pootle_misc',
+ 'pootle_store',
+ 'pootle_language',
+ 'pootle_project',
+ 'pootle_translationproject',
+ 'pootle_profile',
+ 'pootle_statistics',
+ 'pootle_notifications',
+ 'pootle_autonotices',
+ 'pootle_terminology',
+ 'legalpages',
+ # External apps
+ 'registration',
+ 'profiles',
+ 'djblets.siteconfig',
+ 'djblets.util',
+ 'contact_form_i18n',
+ 'django_assets',
+ 'voting',
+)
+
+AUTHENTICATION_BACKENDS = (
+ #: Uncomment the following line for enabling LDAP authentication
+ #'pootle.auth.ldap_backend.LdapBackend',
+ 'django.contrib.auth.backends.ModelBackend',
+)
+
+ROOT_URLCONF = 'pootle.urls'
+
+AUTH_PROFILE_MODULE = "pootle_profile.PootleProfile"
View
27 pootle/settings/51-ldap.conf
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Optional LDAP configuration settings."""
+
+
+#: The LDAP server. Format: protocol://hostname:port
+AUTH_LDAP_SERVER = ''
+#: Anonymous Credentials
+AUTH_LDAP_ANON_DN = ''
+AUTH_LDAP_ANON_PASS = ''
+#: Base DN to search
+AUTH_LDAP_BASE_DN = ''
+#: What are we filtering on? %s will be the username,
+#: for example 'sn=%s', or 'uid=%s'.
+AUTH_LDAP_FILTER = ''
+
+# This is a mapping of Pootle field names to LDAP fields.
+# The key is Pootle's name, the value should be your LDAP field name.
+# If you don't use the field or don't want to automatically retrieve these
+# fields from LDAP comment them out. The only required field is ``dn``.
+AUTH_LDAP_FIELDS = {
+ 'dn': 'dn',
+ #'first_name': '',
+ #'last_name': '',
+ #'email': '',
+}
View
69 pootle/settings/60-translation.conf
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Translation environment configuration settings."""
+
+
+# The directory where the translation files are kept
+PODIRECTORY = working_path('po')
+
+
+# Live translation means that the project called "Pootle" is used to provide
+# the localised versions of Pootle. Set this to True to enable live translation
+# of pootle UI. This is a good way to learn how to use Pootle, but it has high
+# impact on performance.
+LIVE_TRANSLATION = False
+
+# Set this to True if you want translation files to be updated
+# immediatly.
+# Note that this negatively affects performance and
+# should be avoided unless another application needs direct access to
+# the files.
+AUTOSYNC = False
+
+# File parse pool settings
+#
+# To avoid rereading and reparsing translation files from disk on
+# every request, Pootle keeps a pool of already parsed files in memory.
+#
+# Larger pools will offer better performance, but higher memory usage
+# (per server process). When the pool fills up, 1/PARSE_POOL_CULL_FREQUENCY
+# number of files will be removed from the pool.
+PARSE_POOL_SIZE = 40
+PARSE_POOL_CULL_FREQUENCY = 4
+
+
+# Set the backends you want to use to enable translation suggestions through
+# several online services. To disable this feature completely just comment all
+# the lines to set an empty list [] to the MT_BACKENDS setting.
+#
+# The second parameter for each backend option is the API key, which will
+# be used in case the service supports using an API key.
+#
+# Available options are:
+# 'APERTIUM': Apertium service.
+# For this service you need to set the API key.
+# Get your key at http://api.apertium.org/register.jsp
+# 'GOOGLE_TRANSLATE': Google Translate service.
+# For this service you need to set the API key.
+# Note that Google Translate API is a paid service
+# See more at http://code.google.com/apis/language/translate/v2/pricing.html
+#
+MT_BACKENDS = [
+# ('APERTIUM', ''),
+# ('GOOGLE_TRANSLATE', ''),
+]
+
+# Set the backends you want to use to allow web-based lookup. To disable this
+# feature completely just comment all the lines to set an empty list [] to the
+# LOOKUP_BACKENDS setting.
+LOOKUP_BACKENDS = [
+# 'wikipedia',
+]
+
+# URL used for the amaGama TM server.
+# The global amaGama service should work fine, but if your language/project
+# has a better server, or you want to use your own, you can edit this setting.
+# This URL must point to the public API URL which returns JSON. Don't forget
+# the trailing slash.
+AMAGAMA_URL = 'http://amagama.locamotion.org/tmserver/'
View
144 pootle/settings/90-local.conf.sample
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Sample configuration file.
+
+This file includes the settings that administrators will likely change.
+You can find the defaults in the ``*.conf`` files for more advanced settings.
+
+In order for this configuration changes to take effect, bear in mind that you
+need to change the extension of this file from ``.conf.sample`` to ``.conf``.
+"""
+
+
+#
+# Base
+#
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'UTC'
+
+
+#
+# Backends
+#
+
+# Database backend settings
+DATABASES = {
+ 'default': {
+ # Replace 'sqlite3' with 'postgresql_psycopg2', 'mysql' or 'oracle'.
+ 'ENGINE': 'django.db.backends.sqlite3',
+ # Database name or path to database file if using sqlite3.
+ 'NAME': working_path('dbs/pootle.db'),
+ # Not used with sqlite3.
+ 'USER': '',
+ # Not used with sqlite3.
+ 'PASSWORD': '',
+ # Set to empty string for localhost. Not used with sqlite3.
+ 'HOST': '',
+ # Set to empty string for default. Not used with sqlite3.
+ 'PORT': '',
+ }
+}
+
+
+# Cache Backend settings
+
+# We use memcached for better performance. For more info, check
+# http://docs.djangoproject.com/en/dev/topics/cache/#setting-up-the-cache
+CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+ 'LOCATION': '127.0.0.1:11211',
+ 'KEY_PREFIX': '',
+ }
+}
+
+
+#
+# Site
+#
+
+# This Pootle server admins
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
+
+# Set this to False to disable user registration, admins will still be
+# able to create user accounts.
+CAN_REGISTER = True
+
+# Mail settings
+
+# Address used for messages sent by Pootle.
+DEFAULT_FROM_EMAIL = 'info@YOUR_DOMAIN.com'
+
+# Address to receive messages sent by contact form.
+CONTACT_EMAIL = 'info@YOUR_DOMAIN.com'
+CAN_CONTACT = True
+
+# Mail server settings
+
+# By default Pootle uses SMTP server on localhost, if the server is
+# not configured for sending emails use these settings to setup an
+# external outgoing SMTP server.
+
+# Example for Google as an external SMTP server
+EMAIL_HOST_USER = 'USER@YOUR_DOMAIN.com'
+EMAIL_HOST_PASSWORD = 'YOUR_PASSWORD'
+EMAIL_HOST = 'smtp.gmail.com'
+EMAIL_PORT = 587
+EMAIL_USE_TLS = True
+
+
+#
+# Translation
+#
+
+# The directory where the translation files are kept
+PODIRECTORY = working_path('po')
+
+# Two-tuple defining the markup filter to apply in certain textareas.
+# - Accepted values for the first element are 'textile', 'markdown',
+# 'restructuredtext' and None
+# - The second element should be a dictionary of keyword arguments that
+# will be passed to the markup function
+#
+# Examples:
+# MARKUP_FILTER = (None, {})
+# MARKUP_FILTER = ('markdown', {'safe_mode': True})
+# MARKUP_FILTER = ('restructuredtext', {})
+MARKUP_FILTER = (None, {})
+
+# Set the backends you want to use to enable translation suggestions through
+# several online services. To disable this feature completely just comment all
+# the lines to set an empty list [] to the MT_BACKENDS setting.
+#
+# The second parameter for each backend option is the API key, which will
+# be used in case the service supports using an API key.
+#
+# Available options are:
+# 'APERTIUM': Apertium service.
+# For this service you need to set the API key.
+# Get your key at http://api.apertium.org/register.jsp
+# 'GOOGLE_TRANSLATE': Google Translate service.
+# For this service you need to set the API key.
+# Note that Google Translate API is a paid service
+# See more at http://code.google.com/apis/language/translate/v2/pricing.html
+#
+MT_BACKENDS = [
+# ('APERTIUM', ''),
+# ('GOOGLE_TRANSLATE', ''),
+]
+
+# Set the backends you want to use to allow web-based lookup. To disable this
+# feature completely just comment all the lines to set an empty list [] to the
+# LOOKUP_BACKENDS setting.
+LOOKUP_BACKENDS = [
+# 'wikipedia',
+]
View
84 pootle/settings/95-outro.conf
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Setup things that depend on other settings."""
+
+import logging
+
+
+if CONTACT_EMAIL:
+ MANAGERS += (('CONTACT', CONTACT_EMAIL),)
+
+if LIVE_TRANSLATION:
+ # Look for localization files under PODIRECTORY/pootle
+ LOCALE_PATHS = (os.path.join(PODIRECTORY, "pootle"), )
+else:
+ # look for localization files under mo directory
+ LOCALE_PATHS = (data_path("mo"), )
+
+from pootle.i18n import override, gettext_live, gettext
+from django.utils import translation
+from django.utils.translation import trans_real
+
+LANGUAGES = override.find_languages(LOCALE_PATHS[0])
+
+def hijack_translation():
+ """Sabotage django's fascist linguistical regime."""
+ # Override functions that check if language if language is known to Django
+ translation.check_for_language = lambda lang_code: True
+ trans_real.check_for_language = lambda lang_code: True
+ translation.get_language_from_request = override.get_language_from_request
+
+ # Override django's inadequate bidi detection
+ translation.get_language_bidi = override.get_language_bidi
+
+ if LIVE_TRANSLATION:
+ trans_real.translation = override.translation_dummy
+ override.override_gettext(gettext_live)
+ else:
+ # Even when live translation is not enabled we hijack
+ # gettext functions to install the safe variable formatting override
+ override.override_gettext(gettext)
+
+hijack_translation()
+
+
+# Setup a tempdir inside the ``PODIRECTORY`` hierarchy, this way we have
+# reasonable guarantee that temp files will be created on the same
+# filesystem as translation files (required for save operations).
+import tempfile
+tempfile.tempdir = os.path.join(PODIRECTORY, ".tmp")
+# Ensure that temp dir exists
+if not os.path.exists(tempfile.tempdir):
+ os.mkdir(tempfile.tempdir)
+
+
+TEMPLATE_DEBUG = DEBUG
+if TEMPLATE_DEBUG:
+ TEMPLATE_CONTEXT_PROCESSORS += ("django.core.context_processors.debug",)
+
+if DEBUG:
+ TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ )
+else:
+ # We should only enable caching with DEBUG = False
+ TEMPLATE_LOADERS = (
+ ('django.template.loaders.cached.Loader', (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ )),
+ )
+
+if DEBUG:
+ logging.basicConfig(
+ level=logging.DEBUG,
+ format='%(asctime)s %(levelname)s %(message)s',
+ )
+else:
+ # Will log only CRITICAL errors to the console
+ logging.basicConfig(
+ level=logging.INFO,
+ format='%(asctime)s %(levelname)s %(message)s',
+ )

0 comments on commit a36f2df

Please sign in to comment.