コード例 #1
0
ファイル: queue.py プロジェクト: repoze/repoze.postoffice
def open_queue(db_or_uri, queue_name, path='postoffice'):
    if isinstance(db_or_uri, basestring):
        db = db_from_uri(db_or_uri)
        closer_db = db
    else:
        db = db_or_uri
        closer_db = None
    conn = db.open()
    closer = _Closer(closer_db, conn)
    return find_queue(conn.root(), queue_name, path), closer
コード例 #2
0
ファイル: queue.py プロジェクト: py361/repoze.postoffice
def open_queue(db_or_uri, queue_name, path='postoffice'):
    if isinstance(db_or_uri, basestring):
        db = db_from_uri(db_or_uri)
        closer_db = db
    else:
        db = db_or_uri
        closer_db = None
    conn = db.open()
    closer = _Closer(closer_db, conn)
    return find_queue(conn.root(), queue_name, path), closer
コード例 #3
0
 def __init__(self, uri, appmaker, cleanup=SimpleCleanup,
         connection_key=CONNECTION_KEY):
     self.uri = uri
     self.appmaker = appmaker
     self.connection_key = connection_key
     self.cleanup = cleanup
     if uri is None: # it will be None during *tests* only
         self.db = None
     else:
         self.db = db_from_uri(self.uri)
コード例 #4
0
ファイル: finder.py プロジェクト: repoze/repoze.zodbconn
 def _get_db(self):
     lock = self._db_lock
     lock.acquire()
     try:
         db = self._db
         if db is None:
             self._db = db = db_from_uri(self.uri)
         return db
     finally:
         lock.release()
コード例 #5
0
ファイル: finder.py プロジェクト: py361/repoze.zodbconn
 def _get_db(self):
     lock = self._db_lock
     lock.acquire()
     try:
         db = self._db
         if db is None:
             self._db = db = db_from_uri(self.uri)
         return db
     finally:
         lock.release()
コード例 #6
0
ファイル: queue.py プロジェクト: ctheune/repoze.postoffice
def open_queue(db_or_uri, queue_name, path='postoffice'):
    if isinstance(db_or_uri, basestring):
        db = db_from_uri(db_or_uri)
        closer_db = db
    else:
        db = db_or_uri
        closer_db = None
    conn = db.open()
    queues = conn.root()
    for name in path.strip('/').split('/'):
        queues = queues[name]
    closer = _Closer(closer_db, conn)
    return queues[queue_name], closer
コード例 #7
0
ファイル: connector.py プロジェクト: repoze/repoze.zodbconn
def make_app(next_app, global_conf, **local_conf):
    """Make a Connector app.  Expects keyword parameters:

    zodb_uri: The database URI or URIs (either a whitespace-delimited string
      or a list of strings).  Can be in the global configuration.

    connection_key: Optional; the name of the key to put in the WSGI
        environment containing the database connection.
    """
    uri = local_conf.get('zodb_uri')
    if uri is None:
        uri = global_conf.get('zodb_uri')
    connection_key = local_conf.get('connection_key', CONNECTION_KEY)
    db = db_from_uri(uri)
    return Connector(next_app, db, connection_key=connection_key)
コード例 #8
0
def make_app(next_app, global_conf, **local_conf):
    """Make a Connector app.  Expects keyword parameters:

    zodb_uri: The database URI or URIs (either a whitespace-delimited string
      or a list of strings).  Can be in the global configuration.

    connection_key: Optional; the name of the key to put in the WSGI
        environment containing the database connection.
    """
    uri = local_conf.get('zodb_uri')
    if uri is None:
        uri = global_conf.get('zodb_uri')
    connection_key = local_conf.get('connection_key', CONNECTION_KEY)
    db = db_from_uri(uri)
    return Connector(next_app, db, connection_key=connection_key)
コード例 #9
0
    def setUp(self):
        import tempfile
        import os.path
        from tutorial import main
        self.tmpdir = tempfile.mkdtemp()

        dbpath = os.path.join( self.tmpdir, 'test.db')
        from repoze.zodbconn.uri import db_from_uri
        db = db_from_uri('file://' + dbpath)
        settings = { 'zodb_uri' : None }

        app = main({}, **settings)
        from repoze.zodbconn.connector import Connector
        app = Connector(app, db)
        self.db = db
        from webtest import TestApp
        self.testapp = TestApp(app)
コード例 #10
0
ファイル: instance.py プロジェクト: reebalazs/karlserve
def _get_config(global_config, uri):
    db = db_from_uri(uri)
    conn = db.open()
    root = conn.root()

    config = default_config.copy()
    config.update(global_config)
    instance_config = root.get('instance_config', None)
    if instance_config is None:
        instance_config = PersistentMapping(default_instance_config)
        root['instance_config'] = instance_config
    config.update(instance_config)
    if 'envelope_from_addr' not in config:
        config['envelope_from_addr'] = (
            'karl@%s' % config['system_email_domain'])

    transaction.commit()
    conn.close()
    db.close()
    del db, conn, root

    return config
コード例 #11
0
 def _callFUT(self, uri):
     from repoze.zodbconn.uri import db_from_uri
     return db_from_uri(uri)
コード例 #12
0
ファイル: bootstrap.py プロジェクト: avnik/nanozope
def bootstrap_database_from_paster(zodb_uri, root_name):
    from repoze.zodbconn.uri import db_from_uri
    db = db_from_uri(zodb_uri)
    conn = db.open()
    bootstrap_database(conn, root_name)
    conn.close()