Example #1
0
def get_django_stores():
    """Return a dictionary of configured stores for django."""
    settings = get_connection_settings()
    storm_stores = {}
    for key, cfg in settings.items():
        storm_stores[key] = get_postgres_uri(cfg)
    return storm_stores
Example #2
0
def _format_postgres_admin_uri(store_name):
    """Internal function that formats a URI for a local admin connection"""
    cfg = get_connection_settings()[store_name]
    #bypass username & password to get an admin config
    cfg['username'] = None
    cfg['password'] = None
    cfg['options'] = None
    return get_postgres_uri(cfg)
def _format_postgres_admin_uri(store_name):
    """Internal function that formats a URI for a local admin connection"""
    cfg = get_connection_settings()[store_name]
    #bypass username & password to get an admin config
    cfg['username'] = None
    cfg['password'] = None
    cfg['options'] = None
    return get_postgres_uri(cfg)
Example #4
0
 def test_get_connection_settings(self):
     """Test get_connection_settings."""
     self.assertEqual(dbconfig.conn_settings, None)
     conn = get_connection_settings()
     # the global gets set by this.
     self.assertEqual(dbconfig.conn_settings, conn)
     # some sanity checks:
     self.assertEqual(conn['storage']['database'], 'storage')
     self.assertEqual(conn['storage']['port'], 5433)
     self.assertEqual(conn['storage']['password'], '')
     self.assertEqual(conn['storage']['host'], 'fake.server.net')
     self.assertEqual(conn['shard0']['database'], 'shard0')
     self.assertEqual(conn['shard0']['port'], 5434)
     self.assertEqual(conn['shard0']['options'], 'isolation=serializable')
 def test_get_connection_settings(self):
     """Test get_connection_settings."""
     self.assertEqual(dbconfig.conn_settings, None)
     conn = get_connection_settings()
     # the global gets set by this.
     self.assertEqual(dbconfig.conn_settings, conn)
     # some sanity checks:
     self.assertEqual(conn['storage']['database'], 'storage')
     self.assertEqual(conn['storage']['port'], 5433)
     self.assertEqual(conn['storage']['password'], '')
     self.assertEqual(conn['storage']['host'], 'fake.server.net')
     self.assertEqual(conn['shard0']['database'], 'shard0')
     self.assertEqual(conn['shard0']['port'], 5434)
     self.assertEqual(conn['shard0']['options'], 'isolation=serializable')
Example #6
0
def get_store(store_name, zstorm=None):
    """Return the Storm.Store for the given schema"""
    if not zstorm:
        zstorm = account_zstorm
    settings = get_connection_settings()
    # get the current transaction and see if it has the ro_store flag set
    txn = zstorm.transaction_manager.get()
    if getattr(txn, 'use_ro_store', False):
        # only use it if there is a config for it.
        ro_store_name = 'ro-%s' % store_name
        if ro_store_name in settings:
            store_name = ro_store_name
    store_settings = settings[store_name]
    uri = get_postgres_uri(store_settings)
    return zstorm.get(store_name, default_uri=uri)