separate keys and

host specific info into separate config files
onedrive
eric 2019-04-20 14:34:53 -04:00
parent ce088ebd90
commit 50361e9cc9
3 changed files with 96 additions and 9 deletions

83
CherryPy.conf Normal file
View File

@ -0,0 +1,83 @@
[global]
# CherryPyApp.conf
# These parameters get over-written by values in ~/.autocat3 or /etc/autocat3.conf
# any sensetive parameters such as keys should be stored there
environment: 'production'
pidfile: '/var/run/autocat/autocat3.pid'
server.socket_host: '::'
server.socket_port: 8000
server.socket_queue_size: 10
server.thread_pool: 20
server.thread_pool_max: 20
# change host params in .autocat3 or /etc/autocat3.conf files
pghost: 'localhost'
pgport: 5432
pgdatabase: 'gutenberg'
pguser: 'postgres'
host: 'www.gutenberg.org'
host_mobile: 'm.gutenberg.org'
file_host: 'www.gutenberg.org'
sqlalchemy.pool_size: 20
sqlalchemy.max_overflow: 0
sqlalchemy.timeout: 3
facebook_app_id: '115319388529183'
dropbox_client_id: '6s833cia5ndi4b5'
dropbox_client_secret: 'add secret in .autocat3 or /etc/autocat3.conf files'
gdrive_client_id: '586299000268.apps.googleusercontent.com'
gdrive_client_secret: 'add secret in .autocat3 or /etc/autocat3.conf files'
msdrive_client_id: '0000000044111115'
msdrive_client_secret: 'add secret in .autocat3 or /etc/autocat3.conf files'
recaptcha_public_key: '6Lf0cpkUAAAAAIHB6OW_6H0SIqt5O2xmgsnF4Is8'
recaptcha_private_key: 'add secret in .autocat or /etc/autocat3.conf files'
log.screen: False
log.error_file: CherryPyApp.install_dir + '/log/error.log'
log.access_file: CherryPyApp.install_dir + '/log/access.log'
log.rot_max_bytes: 104857600
log.rot_backup_count: 2
tools.log_headers.on: False
tools.log_tracebacks.on: True
document_root: 'https://www.gutenberg.org'
[/]
tools.proxy.on: True
tools.proxy.local: 'X-Forwarded-Host'
tools.encode.on: True
tools.encode.encoding: 'utf-8'
tools.gzip.on: True
tools.gzip.mime_types: ['text/html', 'application/xhtml+xml', 'application/atom+xml']
tools.I18nTool.on: True
tools.I18nTool.default: 'en_US'
tools.I18nTool.mo_dir: CherryPyApp.install_dir + '/i18n'
tools.I18nTool.domain: 'messages'
tools.sessions.on: True
#tools.sessions.storage_type = "postgres"
tools.sessions.table_name = "cherrypy.sessions"
tools.sessions.timeout: 30
tools.sessions.path: '/'
# change host in .autocat3 or /etc/autocat3.conf files
tools.sessions.domain: 'gutenberg.org'
tools.expires.on: True
tools.expires.secs: 0
tools.expires.force: True
tools.staticfile.on: True
tools.staticfile.filename: CherryPyApp.install_dir + '/templates/index.html'

View File

@ -51,12 +51,13 @@ import Formatters
import Timer
plugins.Timer = Timer.TimerPlugin
install_dir = os.path.dirname (os.path.abspath (__file__))
if six.PY3:
CHERRYPY_CONFIG = (os.path.expanduser ('~/.autocat3'), '/etc/autocat3.conf')
# CCHERRYPY_CONFIG = ('/etc/autocat3.conf')
else:
CHERRYPY_CONFIG = ('/etc/autocat.conf', os.path.expanduser ('~/.autocat'))
CHERRYPY_CONFIG = os.path.join(install_dir, 'CherryPy.conf')
LOCAL_CONFIG = (
os.path.join(install_dir, 'CherryPy.conf'),
os.path.expanduser('~/.autocat3'), '/etc/autocat3.conf'
)
class MyRoutesDispatcher (cherrypy.dispatch.RoutesDispatcher):
""" Dispatcher that tells us the matched route.
@ -81,8 +82,7 @@ def main ():
'uid': 0,
'gid': 0,
'server_name': 'localhost',
'genshi.template_dir': os.path.join (
os.path.dirname (os.path.abspath (__file__)), 'templates'),
'genshi.template_dir': os.path.join (install_dir, 'templates'),
'daemonize': False,
'pidfile': None,
'host': 'localhost',
@ -91,7 +91,8 @@ def main ():
})
config_filename = None
for config_filename in CHERRYPY_CONFIG:
cherrypy.config.update (CHERRYPY_CONFIG)
for config_filename in LOCAL_CONFIG:
try:
cherrypy.config.update (config_filename)
break

View File

@ -9,7 +9,10 @@ import CherryPyApp
class TestInstantiation(unittest.TestCase):
def setUp(self):
CherryPyApp.CHERRYPY_CONFIG = [os.path.join(os.path.dirname(__file__), 'test.conf')]
CherryPyApp.CHERRYPY_CONFIG = os.path.join(
os.path.dirname(os.path.abspath (__file__)),
'test.conf'
)
def test_main(self):
CherryPyApp.main()