# Path: gengine/base/util.py
# class Proxy(object):
#     def __init__(self):
#         self.target = None
# 
#     def __getattr__(self, name):
#         return getattr(self.target, name)
# 
#     def __setattr__(self, name, value):
#         if name == "target":
#             return object.__setattr__(self, name, value)
#         else:
#             setattr(self.target, name, value)
# 
#     def __call__(self, *args, **kwargs):
#         return self.target(*args, **kwargs)


from sqlalchemy.orm.session import Session, sessionmaker
from sqlalchemy.orm.scoping import scoped_session
from sqlalchemy.sql.schema import MetaData
from zope.sqlalchemy.datamanager import ZopeTransactionExtension
from sqlalchemy.ext.declarative.api import declarative_base
from gengine.base.util import Proxy
import transaction



class MySession(Session):
    """This allow us to use the flask-admin sqla extension, which uses DBSession.commit() rather than transaction.commit()"""
    def commit(self,*args,**kw):
        transaction.commit(*args,**kw)

    def rollback(self, *args, **kw):
        transaction.abort(*args,**kw)


# Path: gengine/base/util.py
# class Proxy(object):
#     def __init__(self):
#         self.target = None
# 
#     def __getattr__(self, name):
#         return getattr(self.target, name)
# 
#     def __setattr__(self, name, value):
#         if name == "target":
#             return object.__setattr__(self, name, value)
#         else:
#             setattr(self.target, name, value)
# 
#     def __call__(self, *args, **kwargs):
#         return self.target(*args, **kwargs)


# Path: gengine/metadata.py
from sqlalchemy.orm.session import Session, sessionmaker
from sqlalchemy.orm.scoping import scoped_session
from sqlalchemy.sql.schema import MetaData
from zope.sqlalchemy.datamanager import ZopeTransactionExtension
from sqlalchemy.ext.declarative.api import declarative_base
from gengine.base.util import Proxy
import transaction




class MySession(Session):
    """This allow us to use the flask-admin sqla extension, which uses DBSession.commit() rather than transaction.commit()"""
    def commit(self,*args,**kw):
        transaction.commit(*args,**kw)

    def rollback(self, *args, **kw):
        transaction.abort(*args,**kw)


DBSession=Proxy()