mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
improve settings.py for server release
This commit is contained in:
74
settings.py
74
settings.py
@@ -1,6 +1,8 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Django settings for seahub project.
|
# Django settings for seahub project.
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
@@ -11,12 +13,8 @@ ADMINS = (
|
|||||||
|
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
DATABASE_ENGINE = 'sqlite3'
|
||||||
DATABASE_NAME = os.path.join(os.path.dirname(__file__), 'seahub.db') # Or path to database file if using sqlite3.
|
DATABASE_NAME = os.path.join(os.path.dirname(__file__), 'seahub.db')
|
||||||
DATABASE_USER = '' # Not used with sqlite3.
|
|
||||||
DATABASE_PASSWORD = '' # Not used with sqlite3.
|
|
||||||
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
@@ -196,30 +194,52 @@ SERVE_STATIC = True
|
|||||||
|
|
||||||
# Enalbe or disalbe registration on web.
|
# Enalbe or disalbe registration on web.
|
||||||
ENABLE_SIGNUP = False
|
ENABLE_SIGNUP = False
|
||||||
|
|
||||||
try:
|
|
||||||
import local_settings
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Import any symbols that begin with A-Z. Append to lists any symbols that
|
|
||||||
# begin with "EXTRA_".
|
|
||||||
import re
|
|
||||||
for attr in dir(local_settings):
|
|
||||||
match = re.search('^EXTRA_(\w+)', attr)
|
|
||||||
if match:
|
|
||||||
name = match.group(1)
|
|
||||||
value = getattr(local_settings, attr)
|
|
||||||
try:
|
|
||||||
globals()[name] += value
|
|
||||||
except KeyError:
|
|
||||||
globals()[name] = value
|
|
||||||
elif re.search('^[A-Z]', attr):
|
|
||||||
globals()[attr] = getattr(local_settings, attr)
|
|
||||||
|
|
||||||
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
||||||
|
|
||||||
SEAFILE_VERSION = '1.3.0'
|
SEAFILE_VERSION = '1.3.0'
|
||||||
|
|
||||||
USE_SUBDOMAIN = False
|
USE_SUBDOMAIN = False
|
||||||
|
|
||||||
|
def load_local_settings(module):
|
||||||
|
'''Import any symbols that begin with A-Z. Append to lists any symbols
|
||||||
|
that begin with "EXTRA_".
|
||||||
|
|
||||||
|
'''
|
||||||
|
for attr in dir(module):
|
||||||
|
match = re.search('^EXTRA_(\w+)', attr)
|
||||||
|
if match:
|
||||||
|
name = match.group(1)
|
||||||
|
value = getattr(module, attr)
|
||||||
|
try:
|
||||||
|
globals()[name] += value
|
||||||
|
except KeyError:
|
||||||
|
globals()[name] = value
|
||||||
|
elif re.search('^[A-Z]', attr):
|
||||||
|
globals()[attr] = getattr(module, attr)
|
||||||
|
|
||||||
|
# Load local_settngs.py
|
||||||
|
try:
|
||||||
|
import local_settings
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
load_local_settings(local_settings)
|
||||||
|
del local_settings
|
||||||
|
|
||||||
|
# Load seahub_settings.py in server release
|
||||||
|
try:
|
||||||
|
install_topdir = os.path.expanduser(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||||
|
sys.path.insert(0, install_topdir)
|
||||||
|
import seahub_settings
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# In server release, sqlite3 db file is <topdir>/seahub.db
|
||||||
|
DATABASE_NAME = os.path.join(install_topdir, 'seahub.db')
|
||||||
|
# In server release, gunicorn is used to deploy seahub
|
||||||
|
INSTALLED_APPS += ('gunicorn', )
|
||||||
|
load_local_settings(seahub_settings)
|
||||||
|
del seahub_settings
|
||||||
|
|
||||||
|
# Remove install_topdir from path
|
||||||
|
sys.path.pop()
|
||||||
|
Reference in New Issue
Block a user