31
31
Reference, ReferenceSet, Bool, Storm, Desc
32
32
from storm.exceptions import NotOneError, IntegrityError
35
34
from ivle.worksheet.rst import rst
37
36
__all__ = ['get_store',
51
50
% (self.__class__.__name__, k))
52
51
setattr(self, k, v)
54
def get_conn_string():
56
Returns the Storm connection string, generated from the conf file.
53
def get_conn_string(config):
54
"""Create a Storm connection string to the IVLE database
56
@param config: The IVLE configuration.
61
clusterstr += ivle.conf.db_user
62
if ivle.conf.db_password:
63
clusterstr += ':' + ivle.conf.db_password
60
if config['database']['username']:
61
clusterstr += config['database']['username']
62
if config['database']['password']:
63
clusterstr += ':' + config['database']['password']
66
host = ivle.conf.db_host or 'localhost'
67
port = ivle.conf.db_port or 5432
66
host = config['database']['host'] or 'localhost'
67
port = config['database']['port'] or 5432
69
69
clusterstr += '%s:%d' % (host, port)
71
return "postgres://%s/%s" % (clusterstr, ivle.conf.db_dbname)
75
Open a database connection and transaction. Return a storm.store.Store
76
instance connected to the configured IVLE database.
78
return Store(create_database(get_conn_string()))
71
return "postgres://%s/%s" % (clusterstr, config['database']['name'])
73
def get_store(config):
74
"""Create a Storm store connected to the IVLE database.
76
@param config: The IVLE configuration.
78
return Store(create_database(get_conn_string(config)))