Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
orm
/
📁
..
📄
__init__.py
(7.9 KB)
📄
__init__.pyc
(9.31 KB)
📄
__init__.pyo
(9.31 KB)
📄
attributes.py
(55.94 KB)
📄
attributes.pyc
(55.59 KB)
📄
attributes.pyo
(55.32 KB)
📄
base.py
(14.32 KB)
📄
base.pyc
(15.11 KB)
📄
base.pyo
(15.11 KB)
📄
collections.py
(51.18 KB)
📄
collections.pyc
(62.31 KB)
📄
collections.pyo
(62.1 KB)
📄
dependency.py
(45.11 KB)
📄
dependency.pyc
(28.68 KB)
📄
dependency.pyo
(28.59 KB)
📄
deprecated_interfaces.py
(17.83 KB)
📄
deprecated_interfaces.pyc
(21.11 KB)
📄
deprecated_interfaces.pyo
(21.11 KB)
📄
descriptor_props.py
(24.95 KB)
📄
descriptor_props.pyc
(28.1 KB)
📄
descriptor_props.pyo
(28.1 KB)
📄
dynamic.py
(12.84 KB)
📄
dynamic.pyc
(14.42 KB)
📄
dynamic.pyo
(14.42 KB)
📄
evaluator.py
(4.7 KB)
📄
evaluator.pyc
(7.19 KB)
📄
evaluator.pyo
(7.19 KB)
📄
events.py
(83.09 KB)
📄
events.pyc
(91.58 KB)
📄
events.pyo
(91.58 KB)
📄
exc.py
(5.31 KB)
📄
exc.pyc
(7.75 KB)
📄
exc.pyo
(7.75 KB)
📄
identity.py
(10.01 KB)
📄
identity.pyc
(14.76 KB)
📄
identity.pyo
(14.76 KB)
📄
instrumentation.py
(17.1 KB)
📄
instrumentation.pyc
(20.65 KB)
📄
instrumentation.pyo
(20.57 KB)
📄
interfaces.py
(21.56 KB)
📄
interfaces.pyc
(26.11 KB)
📄
interfaces.pyo
(26.11 KB)
📄
loading.py
(25.29 KB)
📄
loading.pyc
(15.28 KB)
📄
loading.pyo
(15.28 KB)
📄
mapper.py
(116.54 KB)
📄
mapper.pyc
(92.81 KB)
📄
mapper.pyo
(92.66 KB)
📄
path_registry.py
(7.57 KB)
📄
path_registry.pyc
(12.58 KB)
📄
path_registry.pyo
(12.58 KB)
📄
persistence.py
(52.41 KB)
📄
persistence.pyc
(41.25 KB)
📄
persistence.pyo
(41.25 KB)
📄
properties.py
(10.21 KB)
📄
properties.pyc
(11.3 KB)
📄
properties.pyo
(11.3 KB)
📄
query.py
(150.98 KB)
📄
query.pyc
(143.06 KB)
📄
query.pyo
(143.02 KB)
📄
relationships.py
(115.47 KB)
📄
relationships.pyc
(100.36 KB)
📄
relationships.pyo
(100.33 KB)
📄
scoping.py
(6.27 KB)
📄
scoping.pyc
(7.5 KB)
📄
scoping.pyo
(7.5 KB)
📄
session.py
(117.07 KB)
📄
session.pyc
(110.77 KB)
📄
session.pyo
(110.6 KB)
📄
state.py
(26.85 KB)
📄
state.pyc
(28.61 KB)
📄
state.pyo
(28.61 KB)
📄
strategies.py
(60.93 KB)
📄
strategies.pyc
(45.88 KB)
📄
strategies.pyo
(45.54 KB)
📄
strategy_options.py
(35.07 KB)
📄
strategy_options.pyc
(36.87 KB)
📄
strategy_options.pyo
(36.87 KB)
📄
sync.py
(5.32 KB)
📄
sync.pyc
(4.48 KB)
📄
sync.pyo
(4.48 KB)
📄
unitofwork.py
(23.43 KB)
📄
unitofwork.pyc
(23.57 KB)
📄
unitofwork.pyo
(23.49 KB)
📄
util.py
(37.64 KB)
📄
util.pyc
(38.09 KB)
📄
util.pyo
(37.94 KB)
Editing: scoping.py
# orm/scoping.py # Copyright (C) 2005-2017 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from .. import exc as sa_exc from ..util import ScopedRegistry, ThreadLocalRegistry, warn from . import class_mapper, exc as orm_exc from .session import Session __all__ = ['scoped_session'] class scoped_session(object): """Provides scoped management of :class:`.Session` objects. See :ref:`unitofwork_contextual` for a tutorial. """ session_factory = None """The `session_factory` provided to `__init__` is stored in this attribute and may be accessed at a later time. This can be useful when a new non-scoped :class:`.Session` or :class:`.Connection` to the database is needed.""" def __init__(self, session_factory, scopefunc=None): """Construct a new :class:`.scoped_session`. :param session_factory: a factory to create new :class:`.Session` instances. This is usually, but not necessarily, an instance of :class:`.sessionmaker`. :param scopefunc: optional function which defines the current scope. If not passed, the :class:`.scoped_session` object assumes "thread-local" scope, and will use a Python ``threading.local()`` in order to maintain the current :class:`.Session`. If passed, the function should return a hashable token; this token will be used as the key in a dictionary in order to store and retrieve the current :class:`.Session`. """ self.session_factory = session_factory if scopefunc: self.registry = ScopedRegistry(session_factory, scopefunc) else: self.registry = ThreadLocalRegistry(session_factory) def __call__(self, **kw): r"""Return the current :class:`.Session`, creating it using the :attr:`.scoped_session.session_factory` if not present. :param \**kw: Keyword arguments will be passed to the :attr:`.scoped_session.session_factory` callable, if an existing :class:`.Session` is not present. If the :class:`.Session` is present and keyword arguments have been passed, :exc:`~sqlalchemy.exc.InvalidRequestError` is raised. """ if kw: scope = kw.pop('scope', False) if scope is not None: if self.registry.has(): raise sa_exc.InvalidRequestError( "Scoped session is already present; " "no new arguments may be specified.") else: sess = self.session_factory(**kw) self.registry.set(sess) return sess else: return self.session_factory(**kw) else: return self.registry() def remove(self): """Dispose of the current :class:`.Session`, if present. This will first call :meth:`.Session.close` method on the current :class:`.Session`, which releases any existing transactional/connection resources still being held; transactions specifically are rolled back. The :class:`.Session` is then discarded. Upon next usage within the same scope, the :class:`.scoped_session` will produce a new :class:`.Session` object. """ if self.registry.has(): self.registry().close() self.registry.clear() def configure(self, **kwargs): """reconfigure the :class:`.sessionmaker` used by this :class:`.scoped_session`. See :meth:`.sessionmaker.configure`. """ if self.registry.has(): warn('At least one scoped session is already present. ' ' configure() can not affect sessions that have ' 'already been created.') self.session_factory.configure(**kwargs) def query_property(self, query_cls=None): """return a class property which produces a :class:`.Query` object against the class and the current :class:`.Session` when called. e.g.:: Session = scoped_session(sessionmaker()) class MyClass(object): query = Session.query_property() # after mappers are defined result = MyClass.query.filter(MyClass.name=='foo').all() Produces instances of the session's configured query class by default. To override and use a custom implementation, provide a ``query_cls`` callable. The callable will be invoked with the class's mapper as a positional argument and a session keyword argument. There is no limit to the number of query properties placed on a class. """ class query(object): def __get__(s, instance, owner): try: mapper = class_mapper(owner) if mapper: if query_cls: # custom query class return query_cls(mapper, session=self.registry()) else: # session's configured query class return self.registry().query(mapper) except orm_exc.UnmappedClassError: return None return query() ScopedSession = scoped_session """Old name for backwards compatibility.""" def instrument(name): def do(self, *args, **kwargs): return getattr(self.registry(), name)(*args, **kwargs) return do for meth in Session.public_methods: setattr(scoped_session, meth, instrument(meth)) def makeprop(name): def set(self, attr): setattr(self.registry(), name, attr) def get(self): return getattr(self.registry(), name) return property(get, set) for prop in ('bind', 'dirty', 'deleted', 'new', 'identity_map', 'is_active', 'autoflush', 'no_autoflush', 'info'): setattr(scoped_session, prop, makeprop(prop)) def clslevel(name): def do(cls, *args, **kwargs): return getattr(Session, name)(*args, **kwargs) return classmethod(do) for prop in ('close_all', 'object_session', 'identity_key'): setattr(scoped_session, prop, clslevel(prop))
Upload File
Create Folder