Added support for database hostname and ssl mode in configuration file.
This commit is contained in:
parent
fd5e8c5f0a
commit
20995d3b2e
3
NEWS
3
NEWS
|
@ -1,3 +1,6 @@
|
|||
1.3.29: May 16, 2008
|
||||
* Added support for database hostname and ssl mode in configuration file.
|
||||
|
||||
1.3.28: May 14, 2008
|
||||
* Updated the pricing page with more info about each feature.
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ settings = {
|
|||
"luminotes.https_url": "",
|
||||
"luminotes.http_proxy_ip": "127.0.0.1",
|
||||
"luminotes.https_proxy_ip": "127.0.0.2",
|
||||
"luminotes.db_host": "localhost",
|
||||
"luminotes.db_ssl_mode": "allow", # "disallow", "allow", "prefer", or "require"
|
||||
"luminotes.support_email": "",
|
||||
"luminotes.payment_email": "",
|
||||
"luminotes.rate_plans": [
|
||||
|
|
|
@ -21,7 +21,7 @@ class Database( object ):
|
|||
ID_BITS = 128 # number of bits within an id
|
||||
ID_DIGITS = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
def __init__( self, connection = None, cache = None ):
|
||||
def __init__( self, connection = None, cache = None, host = None, ssl_mode = None ):
|
||||
"""
|
||||
Create a new database and return it.
|
||||
|
||||
|
@ -53,7 +53,11 @@ class Database( object ):
|
|||
self.__pool = PersistentConnectionPool(
|
||||
1, # minimum connections
|
||||
50, # maximum connections
|
||||
"dbname=luminotes user=luminotes password=%s" % os.getenv( "PGPASSWORD", "dev" ),
|
||||
"host=%s sslmode=%s dbname=luminotes user=luminotes password=%s" % (
|
||||
host or "localhost",
|
||||
ssl_mode or "allow",
|
||||
os.getenv( "PGPASSWORD", "dev" )
|
||||
),
|
||||
)
|
||||
|
||||
self.__cache = cache
|
||||
|
|
|
@ -12,7 +12,6 @@ SOCKET_TIMEOUT_SECONDS = 60
|
|||
|
||||
def main( args ):
|
||||
socket.setdefaulttimeout( SOCKET_TIMEOUT_SECONDS )
|
||||
database = Database()
|
||||
|
||||
cherrypy.config.update( Common.settings )
|
||||
|
||||
|
@ -25,6 +24,11 @@ def main( args ):
|
|||
|
||||
cherrypy.config.update( settings )
|
||||
|
||||
database = Database(
|
||||
host = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_host" ),
|
||||
ssl_mode = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_ssl_mode" ),
|
||||
)
|
||||
|
||||
cherrypy.lowercase_api = True
|
||||
root = Root( database, cherrypy.config.configMap )
|
||||
cherrypy.root = root
|
||||
|
|
Reference in New Issue