Advertisement
Guest User

settings.py

a guest
Mar 21st, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 14.04 KB | None | 0 0
  1. from __future__ import absolute_import, unicode_literals
  2.  
  3. ######################
  4. # MEZZANINE SETTINGS #
  5. ######################
  6.  
  7. # The following settings are already defined with default values in
  8. # the ``defaults.py`` module within each of Mezzanine's apps, but are
  9. # common enough to be put here, commented out, for convenient
  10. # overriding. Please consult the settings documentation for a full list
  11. # of settings Mezzanine implements:
  12. # http://mezzanine.jupo.org/docs/configuration.html#default-settings
  13.  
  14. # Controls the ordering and grouping of the admin menu.
  15. #
  16. # ADMIN_MENU_ORDER = (
  17. #     ("Content", ("pages.Page", "blog.BlogPost",
  18. #        "generic.ThreadedComment", ("Media Library", "fb_browse"),)),
  19. #     ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
  20. #     ("Users", ("auth.User", "auth.Group",)),
  21. # )
  22.  
  23. # A three item sequence, each containing a sequence of template tags
  24. # used to render the admin dashboard.
  25. #
  26. # DASHBOARD_TAGS = (
  27. #     ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
  28. #     ("comment_tags.recent_comments",),
  29. #     ("mezzanine_tags.recent_actions",),
  30. # )
  31.  
  32. # A sequence of templates used by the ``page_menu`` template tag. Each
  33. # item in the sequence is a three item sequence, containing a unique ID
  34. # for the template, a label for the template, and the template path.
  35. # These templates are then available for selection when editing which
  36. # menus a page should appear in. Note that if a menu template is used
  37. # that doesn't appear in this setting, all pages will appear in it.
  38.  
  39. # PAGE_MENU_TEMPLATES = (
  40. #     (1, "Top navigation bar", "pages/menus/dropdown.html"),
  41. #     (2, "Left-hand tree", "pages/menus/tree.html"),
  42. #     (3, "Footer", "pages/menus/footer.html"),
  43. # )
  44.  
  45. # A sequence of fields that will be injected into Mezzanine's (or any
  46. # library's) models. Each item in the sequence is a four item sequence.
  47. # The first two items are the dotted path to the model and its field
  48. # name to be added, and the dotted path to the field class to use for
  49. # the field. The third and fourth items are a sequence of positional
  50. # args and a dictionary of keyword args, to use when creating the
  51. # field instance. When specifying the field class, the path
  52. # ``django.models.db.`` can be omitted for regular Django model fields.
  53. #
  54. # EXTRA_MODEL_FIELDS = (
  55. #     (
  56. #         # Dotted path to field.
  57. #         "mezzanine.blog.models.BlogPost.image",
  58. #         # Dotted path to field class.
  59. #         "somelib.fields.ImageField",
  60. #         # Positional args for field class.
  61. #         ("Image",),
  62. #         # Keyword args for field class.
  63. #         {"blank": True, "upload_to": "blog"},
  64. #     ),
  65. #     # Example of adding a field to *all* of Mezzanine's content types:
  66. #     (
  67. #         "mezzanine.pages.models.Page.another_field",
  68. #         "IntegerField", # 'django.db.models.' is implied if path is omitted.
  69. #         ("Another name",),
  70. #         {"blank": True, "default": 1},
  71. #     ),
  72. # )
  73.  
  74. # Setting to turn on featured images for blog posts. Defaults to False.
  75. #
  76. # BLOG_USE_FEATURED_IMAGE = True
  77.  
  78. # If True, the south application will be automatically added to the
  79. # INSTALLED_APPS setting.
  80. USE_SOUTH = True
  81.  
  82.  
  83. ########################
  84. # MAIN DJANGO SETTINGS #
  85. ########################
  86.  
  87. # People who get code error notifications.
  88. # In the format (('Full Name', 'email@example.com'),
  89. #                ('Full Name', 'anotheremail@example.com'))
  90. ADMINS = (
  91.     # ('Your Name', 'your_email@domain.com'),
  92. )
  93. MANAGERS = ADMINS
  94.  
  95. # Hosts/domain names that are valid for this site; required if DEBUG is False
  96. # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
  97. ALLOWED_HOSTS = []
  98.  
  99. # Local time zone for this installation. Choices can be found here:
  100. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  101. # although not all choices may be available on all operating systems.
  102. # On Unix systems, a value of None will cause Django to use the same
  103. # timezone as the operating system.
  104. # If running in a Windows environment this must be set to the same as your
  105. # system time zone.
  106. TIME_ZONE = None
  107.  
  108. # If you set this to True, Django will use timezone-aware datetimes.
  109. USE_TZ = True
  110.  
  111. # Language code for this installation. All choices can be found here:
  112. # http://www.i18nguy.com/unicode/language-identifiers.html
  113. LANGUAGE_CODE = "en"
  114.  
  115. # Supported languages
  116. _ = lambda s: s
  117. LANGUAGES = (
  118.     ('en', _('English')),
  119. )
  120.  
  121. # A boolean that turns on/off debug mode. When set to ``True``, stack traces
  122. # are displayed for error pages. Should always be set to ``False`` in
  123. # production. Best set to ``True`` in local_settings.py
  124. DEBUG = False
  125.  
  126. # Whether a user's session cookie expires when the Web browser is closed.
  127. SESSION_EXPIRE_AT_BROWSER_CLOSE = True
  128.  
  129. SITE_ID = 1
  130.  
  131. # If you set this to False, Django will make some optimizations so as not
  132. # to load the internationalization machinery.
  133. USE_I18N = False
  134.  
  135. # Tuple of IP addresses, as strings, that:
  136. #   * See debug comments, when DEBUG is true
  137. #   * Receive x-headers
  138. INTERNAL_IPS = ("127.0.0.1",)
  139.  
  140. # List of callables that know how to import templates from various sources.
  141. TEMPLATE_LOADERS = (
  142.     "django.template.loaders.filesystem.Loader",
  143.     "django.template.loaders.app_directories.Loader",
  144. )
  145.  
  146. AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
  147.  
  148. # List of finder classes that know how to find static files in
  149. # various locations.
  150. STATICFILES_FINDERS = (
  151.     "django.contrib.staticfiles.finders.FileSystemFinder",
  152.     "django.contrib.staticfiles.finders.AppDirectoriesFinder",
  153. #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
  154. )
  155.  
  156. # The numeric mode to set newly-uploaded files to. The value should be
  157. # a mode you'd pass directly to os.chmod.
  158. FILE_UPLOAD_PERMISSIONS = 0o644
  159.  
  160.  
  161. #############
  162. # DATABASES #
  163. #############
  164. import os
  165. import urlparse
  166.  
  167. DATABASES = {}
  168. if 'OPENSHIFT_MYSQL_DB_URL' in os.environ:
  169.     url = urlparse.urlparse(os.environ.get('OPENSHIFT_MYSQL_DB_URL'))
  170.    
  171.     DATABASES['default'] = {
  172.         'ENGINE' : 'django.db.backends.mysql',
  173.         'NAME': os.environ['OPENSHIFT_APP_NAME'],
  174.         'USER': url.username,
  175.         'PASSWORD': url.password,
  176.         'HOST': url.hostname,
  177.         'PORT': url.port,
  178.     }
  179.  
  180. elif 'OPENSHIFT_POSTGRESQL_DB_URL' in os.environ:
  181.     url = urlparse.urlparse(os.environ.get('OPENSHIFT_POSTGRESQL_DB_URL'))
  182.    
  183.     DATABASES['default'] = {
  184.         'ENGINE' : 'django.db.backends.postgresql_psycopg2',
  185.         'NAME' : os.environ['OPENSHIFT_APP_NAME'],
  186.         'USER': url.username,
  187.         'PASSWORD': url.password,
  188.         'HOST': url.hostname,
  189.         'PORT': url.port,
  190.     }
  191.  
  192. else:
  193.     DATABASES['default'] = {
  194.         'ENGINE' : 'django.db.backends.sqllite3',
  195.         'NAME' : 'dev.db',
  196.         'USER' : '',
  197.         'PASSWORD' : '',
  198.         'HOST' : '',
  199.         'PORT' : '',
  200.     }
  201.  
  202. # DATABASES = {
  203. #     "default": {
  204. #         # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
  205. #         "ENGINE": "django.db.backends.",
  206. #         # DB name or path to database file if using sqlite3.
  207. #         "NAME": "",
  208. #         # Not used with sqlite3.
  209. #         "USER": "",
  210. #         # Not used with sqlite3.
  211. #         "PASSWORD": "",
  212. #         # Set to empty string for localhost. Not used with sqlite3.
  213. #         "HOST": "",
  214. #         # Set to empty string for default. Not used with sqlite3.
  215. #         "PORT": "",
  216. #     }
  217. # }
  218.  
  219.  
  220. #########
  221. # PATHS #
  222. #########
  223.  
  224. import os
  225.  
  226. # Full filesystem path to the project.
  227. PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
  228.  
  229. # Name of the directory for the project.
  230. PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]
  231.  
  232. # Every cache key will get prefixed with this value - here we set it to
  233. # the name of the directory the project is in to try and use something
  234. # project specific.
  235. CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_DIRNAME
  236.  
  237. # URL prefix for static files.
  238. # Example: "http://media.lawrence.com/static/"
  239. STATIC_URL = "/static/"
  240.  
  241. # Absolute path to the directory static files should be collected to.
  242. # Don't put anything in this directory yourself; store your static files
  243. # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  244. # Example: "/home/media/media.lawrence.com/static/"
  245. if 'OPENSHIFT_REPO_DIR' in os.environ:
  246.     STATIC_ROOT = os.path.join(os.environ.get('OPENSHIFT_REPO_DIR'), 'wsgi', 'static')
  247. else:
  248.     STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
  249.  
  250. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  251. # trailing slash.
  252. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
  253. MEDIA_URL = STATIC_URL + "media/"
  254.  
  255. # Absolute filesystem path to the directory that will hold user-uploaded files.
  256. # Example: "/home/media/media.lawrence.com/media/"
  257. if 'OPENSHIFT_DATA_DIR' in os.environ:
  258.     MEDIA_ROOT = os.path.join(os.environ.get('OPENSHIFT_DATA_DIR', 'media'))
  259. else:
  260.     MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
  261.  
  262. # Package/module name to import the root urlpatterns from for the project.
  263. ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME
  264.  
  265. # Put strings here, like "/home/html/django_templates"
  266. # or "C:/www/django/templates".
  267. # Always use forward slashes, even on Windows.
  268. # Don't forget to use absolute paths, not relative paths.
  269. TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)
  270.  
  271.  
  272. ################
  273. # APPLICATIONS #
  274. ################
  275.  
  276. INSTALLED_APPS = (
  277.     "django.contrib.admin",
  278.     "django.contrib.auth",
  279.     "django.contrib.contenttypes",
  280.     "django.contrib.redirects",
  281.     "django.contrib.sessions",
  282.     "django.contrib.sites",
  283.     "django.contrib.sitemaps",
  284.     "django.contrib.staticfiles",
  285.     "mezzanine.boot",
  286.     "mezzanine.conf",
  287.     "mezzanine.core",
  288.     "mezzanine.generic",
  289.     "mezzanine.blog",
  290.     "mezzanine.forms",
  291.     "mezzanine.pages",
  292.     "mezzanine.galleries",
  293.     "mezzanine.twitter",
  294.     #"mezzanine.accounts",
  295.     #"mezzanine.mobile",
  296. )
  297.  
  298. # List of processors used by RequestContext to populate the context.
  299. # Each one should be a callable that takes the request object as its
  300. # only parameter and returns a dictionary to add to the context.
  301. TEMPLATE_CONTEXT_PROCESSORS = (
  302.     "django.contrib.auth.context_processors.auth",
  303.     "django.contrib.messages.context_processors.messages",
  304.     "django.core.context_processors.debug",
  305.     "django.core.context_processors.i18n",
  306.     "django.core.context_processors.static",
  307.     "django.core.context_processors.media",
  308.     "django.core.context_processors.request",
  309.     "django.core.context_processors.tz",
  310.     "mezzanine.conf.context_processors.settings",
  311. )
  312.  
  313. # List of middleware classes to use. Order is important; in the request phase,
  314. # these middleware classes will be applied in the order given, and in the
  315. # response phase the middleware will be applied in reverse order.
  316. MIDDLEWARE_CLASSES = (
  317.     "mezzanine.core.middleware.UpdateCacheMiddleware",
  318.     "django.contrib.sessions.middleware.SessionMiddleware",
  319.     "django.middleware.locale.LocaleMiddleware",
  320.     "django.contrib.auth.middleware.AuthenticationMiddleware",
  321.     "django.middleware.common.CommonMiddleware",
  322.     "django.middleware.csrf.CsrfViewMiddleware",
  323.     "django.contrib.messages.middleware.MessageMiddleware",
  324.     "mezzanine.core.request.CurrentRequestMiddleware",
  325.     "mezzanine.core.middleware.RedirectFallbackMiddleware",
  326.     "mezzanine.core.middleware.TemplateForDeviceMiddleware",
  327.     "mezzanine.core.middleware.TemplateForHostMiddleware",
  328.     "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
  329.     "mezzanine.core.middleware.SitePermissionMiddleware",
  330.     # Uncomment the following if using any of the SSL settings:
  331.     # "mezzanine.core.middleware.SSLRedirectMiddleware",
  332.     "mezzanine.pages.middleware.PageMiddleware",
  333.     "mezzanine.core.middleware.FetchFromCacheMiddleware",
  334. )
  335.  
  336. # Store these package names here as they may change in the future since
  337. # at the moment we are using custom forks of them.
  338. PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
  339. PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
  340.  
  341. #########################
  342. # OPTIONAL APPLICATIONS #
  343. #########################
  344.  
  345. # These will be added to ``INSTALLED_APPS``, only if available.
  346. OPTIONAL_APPS = (
  347.     "debug_toolbar",
  348.     "django_extensions",
  349.     "compressor",
  350.     PACKAGE_NAME_FILEBROWSER,
  351.     PACKAGE_NAME_GRAPPELLI,
  352. )
  353.  
  354. DEBUG_TOOLBAR_CONFIG = {"INTERCEPT_REDIRECTS": False}
  355.  
  356. ###################
  357. # DEPLOY SETTINGS #
  358. ###################
  359.  
  360. # These settings are used by the default fabfile.py provided.
  361. # Check fabfile.py for defaults.
  362.  
  363. #FABRIC = {
  364. #     "SSH_USER": "", # SSH username
  365. #     "SSH_PASS":  "", # SSH password (consider key-based authentication)
  366. #     "SSH_KEY_PATH":  "", # Local path to SSH key file, for key-based auth
  367. #     "HOSTS": [], # List of hosts to deploy to
  368. #     "VIRTUALENV_HOME":  "", # Absolute remote path for virtualenvs
  369. #     "PROJECT_NAME": "", # Unique identifier for project
  370. #     "REQUIREMENTS_PATH": "", # Path to pip requirements, relative to project
  371. #     "GUNICORN_PORT": 8000, # Port gunicorn will listen on
  372. #     "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8"
  373. #     "LIVE_HOSTNAME": "www.example.com", # Host for public site.
  374. #     "REPO_URL": "", # Git or Mercurial remote repo URL for the project
  375. #     "DB_PASS": "", # Live database password
  376. #     "ADMIN_PASS": "", # Live admin user password
  377. #     "SECRET_KEY": SECRET_KEY
  378. #     "NEVERCACHE_KEY": NEVERCACHE_KEY,
  379. }
  380.  
  381.  
  382. ##################
  383. # LOCAL SETTINGS #
  384. ##################
  385.  
  386. # Allow any settings to be defined in local_settings.py which should be
  387. # ignored in your version control system allowing for settings to be
  388. # defined per machine.
  389. try:
  390.     from local_settings import *
  391. except ImportError:
  392.     pass
  393.  
  394.  
  395. ####################
  396. # DYNAMIC SETTINGS #
  397. ####################
  398.  
  399. # set_dynamic_settings() will rewrite globals based on what has been
  400. # defined so far, in order to provide some better defaults where
  401. # applicable. We also allow this settings module to be imported
  402. # without Mezzanine installed, as the case may be when using the
  403. # fabfile, where setting the dynamic settings below isn't strictly
  404. # required.
  405. try:
  406.     from mezzanine.utils.conf import set_dynamic_settings
  407. except ImportError:
  408.     pass
  409. else:
  410.     set_dynamic_settings(globals())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement