23
'get_dbname', 'dbhost', 'dbuser', 'isZopeless', 'initZopeless',
21
'isZopeless', 'initZopeless',
26
# SQLObject compatibility - dbname, dbhost and dbuser are DEPRECATED.
28
# Allow override by environment variables for backwards compatibility.
29
# This was needed to allow tests to propagate settings to spawned processes.
30
# However, now we just have a single environment variable (LAUNCHPAD_CONF)
31
# which specifies which section of the config file to use instead,
32
# Note that an empty host is different to 'localhost', as the latter
33
# connects via TCP/IP instead of a Unix domain socket. Also note that
34
# if the host is empty it can be overridden by the standard PostgreSQL
35
# environment variables, this feature currently required by Async's
37
dbhost = os.environ.get('LP_DBHOST', None)
38
dbuser = os.environ.get('LP_DBUSER', None)
39
dbport = os.environ.get('LP_DBPORT', None)
40
dbname_override = os.environ.get('LP_DBNAME', None)
44
"""Get the DB Name for scripts: deprecated.
46
:return: The dbname for scripts.
48
if dbname_override is not None:
49
return dbname_override
50
dbname = ConnectionString(dbconfig.main_master).dbname
51
assert dbname is not None, 'Invalid main_master connection string'
56
dbhost = ConnectionString(dbconfig.main_master).host
58
dbport = ConnectionString(dbconfig.main_master).port
61
dbuser = dbconfig.dbuser
65
26
"""Returns True if we are running in the Zopeless environment"""
67
28
return ZopelessTransactionManager._installed is not None
73
def initZopeless(dbname=None, dbhost=None, dbuser=None,
74
isolation=ISOLATION_LEVEL_DEFAULT):
31
def initZopeless(dbuser=None, isolation=ISOLATION_LEVEL_DEFAULT):
75
32
"""Initialize the Zopeless environment."""
77
# Nothing calling initZopeless should be connecting as the
78
# 'launchpad' user, which is the default.
79
# StuartBishop 20050923
81
# "Passing dbuser parameter to initZopeless will soon "
82
# "be mandatory", DeprecationWarning, stacklevel=2
84
pass # Disabled. Bug #3050
88
dbhost = globals()['dbhost']
90
dbuser = globals()['dbuser']
35
ConnectionString(dbconfig.main_master).user or dbconfig.dbuser)
92
37
return ZopelessTransactionManager.initZopeless(
93
dbname=dbname, dbhost=dbhost, dbuser=dbuser, isolation=isolation)
38
dbuser=dbuser, isolation=isolation)