Source

graphalchemy / graphalchemy / sessions.py

Full commit
# -*- coding: utf-8 -*-
'''graph sessions'''

from graphalchemy.core import octopus, reextend, call

__all__ = ['Session']
conf = octopus.G


class Session(octopus.workflow.Session):

    '''graph session'''

    # link manager
    links = reextend(conf.direct.worker.link, conf.directs)
    # node monager
    nodes = reextend(conf.model.worker.node, conf.models)
    # transaction monager
    transaction = call(conf.transaction, conf.backends, conf.key.db)

    def __init__(self, manager):
        super(Session, self).__init__(manager)
        self._db = manager._db

    def __exit__(self, e, b, c):
        # wrap in database transaction
        with self.transaction:
            self.commit()