コード例 #1
0
ファイル: mapper.py プロジェクト: gizm0bill/Ally-Py
from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.orm.properties import ColumnProperty
from sqlalchemy.schema import Table, MetaData, Column, ForeignKey
from sqlalchemy.sql.expression import Executable, ClauseElement, Join
from sqlalchemy.types import String
import logging

# --------------------------------------------------------------------

log = logging.getLogger(__name__)

INDEX_PROP_FK = indexAfter('propFk', INDEX_PROP)
# Index for foreign key properties

# --------------------------------------------------------------------

class MappingError(Exception):
    '''
    Provides the exception used whenever a mapping issue occurs.
    '''

# --------------------------------------------------------------------

def mapperSimple(clazz, sql, **keyargs):
    '''
    Maps a table to a ally REST model. Use this instead of the classical SQL alchemy mapper since this will
    also provide to the model additional information extracted from the SQL alchemy configurations.
コード例 #2
0
ファイル: session.py プロジェクト: ahilles107/Superdesk
from sqlalchemy.exc import InvalidRequestError
from sqlalchemy.orm.session import Session
import logging

# --------------------------------------------------------------------

log = logging.getLogger(__name__)

ATTR_SESSION_CREATE = AttributeOnThread(__name__, 'session_create', deque)
# Attribute used for storing the session creator on the thread
ATTR_SESSION = AttributeOnThread(__name__, 'session', dict)
# Attribute used for storing the session on the thread
ATTR_KEEP_ALIVE = AttributeOnThread(__name__, 'session_alive', bool)
# Attribute used for storing the flag that indicates if a session should be closed or kept alive after a call. 

INDEX_SESSION_BEGIN = indexAfter('sql_session_begin', INDEX_LOCK_BEGIN)
# The sql session begin index.
INDEX_SESSION_END = indexBefore('sql_session_end', INDEX_LOCK_END)
# The sql session end index.

# --------------------------------------------------------------------

class SessionSupport:
    '''
    Class that provides for the services that use SQLAlchemy the session support.
    All services that use SQLAlchemy have to extend this class in order to provide the sql alchemy session
    of the request, the session will be automatically handled by the session processor.
    '''

    session = Session
コード例 #3
0
ファイル: mapper.py プロジェクト: adityaathalye/Ally-Py
from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.orm.properties import ColumnProperty
from sqlalchemy.schema import Table, MetaData, Column, ForeignKey
from sqlalchemy.sql.expression import Join
from sqlalchemy.types import String
import logging

# --------------------------------------------------------------------

log = logging.getLogger(__name__)

INDEX_PROP_FK = indexAfter("propFk", INDEX_PROP)
# Index for foreign key properties

# --------------------------------------------------------------------


class MappingError(Exception):
    """
    Provides the exception used whenever a mapping issue occurs.
    """


# --------------------------------------------------------------------


def mapperSimple(clazz, sql, **keyargs):