How to use the relstorage.storage.RelStorage.ex_cursor function in RelStorage

To help you get started, we’ve selected a few RelStorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newtdb / db / src / newt / db / _ook.py View on Github external
import relstorage.storage
import ZODB.Connection

# Monkey patches, ook
def _ex_cursor(self, name=None):
    if self._stale_error is not None:
        raise self._stale_error

    with self._lock:
        self._before_load()
        return self._load_conn.cursor(name)

relstorage.storage.RelStorage.ex_cursor = _ex_cursor

def _ex_connect(self):
    return self._adapter.connmanager.open()

relstorage.storage.RelStorage.ex_connect = _ex_connect

def _ex_get(self, oid, ghost_pickle):
    """Return the persistent object with oid 'oid'."""
    if self.opened is None:
        raise ConnectionStateError("The database connection is closed")

    obj = self._cache.get(oid, None)
    if obj is not None:
        return obj
    obj = self._added.get(oid, None)
    if obj is not None: