from sqlalchemy.types import *
from sqlalchemy.sql import *
from sqlalchemy.schema import *
-from sqlalchemy.orm import *
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import default_metadata
-from sqlalchemy import mapper, util, Query, exceptions
+from sqlalchemy import util, exceptions
import types
+from sqlalchemy.orm import mapper, Query
def monkeypatch_query_method(ctx, class_, name):
def do(self, *args, **kwargs):
from sqlalchemy.util import ScopedRegistry
-from sqlalchemy.orm.mapper import MapperExtension, EXT_PASS
-from sqlalchemy.orm import create_session
+from sqlalchemy.orm import create_session, MapperExtension, EXT_PASS
__all__ = ['SessionContext', 'SessionContextExt']
object instances.
"""
-from sqlalchemy import util, engine, mapper
+from sqlalchemy import util, engine
from sqlalchemy.ext.sessioncontext import SessionContext
import sqlalchemy.ext.assignmapper as assignmapper
from sqlalchemy.orm.mapper import global_extensions
from sqlalchemy import exceptions
from sqlalchemy import util as sautil
-from sqlalchemy.orm.mapper import *
+from sqlalchemy.orm.mapper import Mapper, object_mapper, class_mapper, mapper_registry
+from sqlalchemy.orm.interfaces import SynonymProperty, MapperExtension, EXT_PASS, ExtensionOption
+from sqlalchemy.orm.properties import PropertyLoader, ColumnProperty, BackRef
from sqlalchemy.orm import mapper as mapperlib
from sqlalchemy.orm.query import Query
from sqlalchemy.orm.util import polymorphic_union
-from sqlalchemy.orm import properties, strategies, interfaces
from sqlalchemy.orm.session import Session as create_session
from sqlalchemy.orm.session import object_session, attribute_manager
__all__ = ['relation', 'column_property', 'backref', 'eagerload', 'lazyload', 'noload', 'deferred', 'defer', 'undefer', 'undefer_group', 'extension',
'mapper', 'clear_mappers', 'compile_mappers', 'clear_mapper', 'class_mapper', 'object_mapper', 'MapperExtension', 'Query',
- 'cascade_mappers', 'polymorphic_union', 'create_session', 'synonym', 'contains_alias', 'contains_eager', 'EXT_PASS', 'object_session'
+ 'polymorphic_union', 'create_session', 'synonym', 'contains_alias', 'contains_eager', 'EXT_PASS', 'object_session'
]
def relation(*args, **kwargs):
no direct correspondence to the mapped selectable will effectively be non-persisted
attributes.
"""
- return properties.ColumnProperty(*args, **kwargs)
+ return ColumnProperty(*args, **kwargs)
def _relation_loader(mapper, secondary=None, primaryjoin=None, secondaryjoin=None, lazy=True, **kwargs):
- return properties.PropertyLoader(mapper, secondary, primaryjoin, secondaryjoin, lazy=lazy, **kwargs)
+ return PropertyLoader(mapper, secondary, primaryjoin, secondaryjoin, lazy=lazy, **kwargs)
def backref(name, **kwargs):
"""Create a BackRef object with explicit arguments, which are the same arguments one
place of a string argument.
"""
- return properties.BackRef(name, **kwargs)
+ return BackRef(name, **kwargs)
def deferred(*columns, **kwargs):
"""Return a ``DeferredColumnProperty``, which indicates this
Used with the `properties` dictionary sent to ``mapper()``.
"""
- return properties.ColumnProperty(deferred=True, *columns, **kwargs)
+ return ColumnProperty(deferred=True, *columns, **kwargs)
def mapper(class_, table=None, *args, **params):
"""Return a new ``Mapper`` object.
Used with the `properties` dictionary sent to ``mapper()``.
"""
- return interfaces.SynonymProperty(name, proxy=proxy)
+ return SynonymProperty(name, proxy=proxy)
def compile_mappers():
"""Compile all mappers that have been defined.
"""
return strategies.UndeferGroupOption(name)
-def cascade_mappers(*classes_or_mappers):
- """Attempt to create a series of ``relations()`` between mappers
- automatically, via introspecting the foreign key relationships of
- the underlying tables.
-
- Given a list of classes and/or mappers, identify the foreign key
- relationships between the given mappers or corresponding class
- mappers, and create ``relation()`` objects representing those
- relationships, including a backreference. Attempt to find the
- *secondary* table in a many-to-many relationship as well.
-
- The names of the relations will be a lowercase version of the
- related class. In the case of one-to-many or many-to-many, the
- name will be *pluralized*, which currently is based on the English
- language (i.e. an 's' or 'es' added to it).
-
- NOTE: this method usually works poorly, and its usage is generally
- not advised.
- """
-
- table_to_mapper = {}
- for item in classes_or_mappers:
- if isinstance(item, Mapper):
- m = item
- else:
- klass = item
- m = class_mapper(klass)
- table_to_mapper[m.mapped_table] = m
-
- def pluralize(name):
- # oh crap, do we need locale stuff now
- if name[-1] == 's':
- return name + "es"
- else:
- return name + "s"
-
- for table,mapper in table_to_mapper.iteritems():
- for fk in table.foreign_keys:
- if fk.column.table is table:
- continue
- secondary = None
- try:
- m2 = table_to_mapper[fk.column.table]
- except KeyError:
- if len(fk.column.table.primary_key):
- continue
- for sfk in fk.column.table.foreign_keys:
- if sfk.column.table is table:
- continue
- m2 = table_to_mapper.get(sfk.column.table)
- secondary = fk.column.table
- if m2 is None:
- continue
- if secondary:
- propname = pluralize(m2.class_.__name__.lower())
- propname2 = pluralize(mapper.class_.__name__.lower())
- else:
- propname = m2.class_.__name__.lower()
- propname2 = pluralize(mapper.class_.__name__.lower())
- mapper.add_property(propname, relation(m2, secondary=secondary, backref=propname2))
from sqlalchemy import util, logging
+# returned by a MapperExtension method to indicate a "do nothing" response
+EXT_PASS = object()
+
+class MapperExtension(object):
+ """Base implementation for an object that provides overriding
+ behavior to various Mapper functions. For each method in
+ MapperExtension, a result of EXT_PASS indicates the functionality
+ is not overridden.
+ """
+
+
+ def init_instance(self, mapper, class_, instance, args, kwargs):
+ return EXT_PASS
+
+ def init_failed(self, mapper, class_, instance, args, kwargs):
+ return EXT_PASS
+
+ def get_session(self):
+ """Retrieve a contextual Session instance with which to
+ register a new object.
+
+ Note: this is not called if a session is provided with the
+ `__init__` params (i.e. `_sa_session`).
+ """
+
+ return EXT_PASS
+
+ def load(self, query, *args, **kwargs):
+ """Override the `load` method of the Query object.
+
+ The return value of this method is used as the result of
+ ``query.load()`` if the value is anything other than EXT_PASS.
+ """
+
+ return EXT_PASS
+
+ def get(self, query, *args, **kwargs):
+ """Override the `get` method of the Query object.
+
+ The return value of this method is used as the result of
+ ``query.get()`` if the value is anything other than EXT_PASS.
+ """
+
+ return EXT_PASS
+
+ def get_by(self, query, *args, **kwargs):
+ """Override the `get_by` method of the Query object.
+
+ The return value of this method is used as the result of
+ ``query.get_by()`` if the value is anything other than
+ EXT_PASS.
+ """
+
+ return EXT_PASS
+
+ def select_by(self, query, *args, **kwargs):
+ """Override the `select_by` method of the Query object.
+
+ The return value of this method is used as the result of
+ ``query.select_by()`` if the value is anything other than
+ EXT_PASS.
+ """
+
+ return EXT_PASS
+
+ def select(self, query, *args, **kwargs):
+ """Override the `select` method of the Query object.
+
+ The return value of this method is used as the result of
+ ``query.select()`` if the value is anything other than
+ EXT_PASS.
+ """
+
+ return EXT_PASS
+
+
+ def translate_row(self, mapper, context, row):
+ """Perform pre-processing on the given result row and return a
+ new row instance.
+
+ This is called as the very first step in the ``_instance()``
+ method.
+ """
+
+ return EXT_PASS
+
+ def create_instance(self, mapper, selectcontext, row, class_):
+ """Receive a row when a new object instance is about to be
+ created from that row.
+
+ The method can choose to create the instance itself, or it can
+ return None to indicate normal object creation should take
+ place.
+
+ mapper
+ The mapper doing the operation
+
+ selectcontext
+ SelectionContext corresponding to the instances() call
+
+ row
+ The result row from the database
+
+ class\_
+ The class we are mapping.
+ """
+
+ return EXT_PASS
+
+ def append_result(self, mapper, selectcontext, row, instance, result, **flags):
+ """Receive an object instance before that instance is appended
+ to a result list.
+
+ If this method returns EXT_PASS, result appending will proceed
+ normally. if this method returns any other value or None,
+ result appending will not proceed for this instance, giving
+ this extension an opportunity to do the appending itself, if
+ desired.
+
+ mapper
+ The mapper doing the operation.
+
+ selectcontext
+ SelectionContext corresponding to the instances() call.
+
+ row
+ The result row from the database.
+
+ instance
+ The object instance to be appended to the result.
+
+ result
+ List to which results are being appended.
+
+ \**flags
+ extra information about the row, same as criterion in
+ `create_row_processor()` method of [sqlalchemy.orm.interfaces#MapperProperty]
+ """
+
+ return EXT_PASS
+
+ def populate_instance(self, mapper, selectcontext, row, instance, **flags):
+ """Receive a newly-created instance before that instance has
+ its attributes populated.
+
+ The normal population of attributes is according to each
+ attribute's corresponding MapperProperty (which includes
+ column-based attributes as well as relationships to other
+ classes). If this method returns EXT_PASS, instance
+ population will proceed normally. If any other value or None
+ is returned, instance population will not proceed, giving this
+ extension an opportunity to populate the instance itself, if
+ desired.
+ """
+
+ return EXT_PASS
+
+ def before_insert(self, mapper, connection, instance):
+ """Receive an object instance before that instance is INSERTed
+ into its table.
+
+ This is a good place to set up primary key values and such
+ that aren't handled otherwise.
+ """
+
+ return EXT_PASS
+
+ def before_update(self, mapper, connection, instance):
+ """Receive an object instance before that instance is UPDATEed."""
+
+ return EXT_PASS
+
+ def after_update(self, mapper, connection, instance):
+ """Receive an object instance after that instance is UPDATEed."""
+
+ return EXT_PASS
+
+ def after_insert(self, mapper, connection, instance):
+ """Receive an object instance after that instance is INSERTed."""
+
+ return EXT_PASS
+
+ def before_delete(self, mapper, connection, instance):
+ """Receive an object instance before that instance is DELETEed."""
+
+ return EXT_PASS
+
+ def after_delete(self, mapper, connection, instance):
+ """Receive an object instance after that instance is DELETEed."""
+
+ return EXT_PASS
+
class MapperProperty(object):
"""Manage the relationship of a ``Mapper`` to a single class
attribute, as well as that attribute as it appears on individual
def set_parent(self, parent):
self.parent = parent
+ def get_sub_mapper(self):
+ raise NotImplementedError()
+
def init(self, key, parent):
"""Called after all mappers are compiled to assemble
relationships between mappers, establish instrumented class
raise NotImplementedError()
-class SynonymProperty(MapperProperty):
- def __init__(self, name, proxy=False):
- self.name = name
- self.proxy = proxy
-
- def setup(self, querycontext, **kwargs):
- pass
- def create_row_processor(self, selectcontext, mapper, row):
- return (None, None)
-
- def do_init(self):
- if not self.proxy:
- return
- class SynonymProp(object):
- def __set__(s, obj, value):
- setattr(obj, self.name, value)
- def __delete__(s, obj):
- delattr(obj, self.name)
- def __get__(s, obj, owner):
- if obj is None:
- return s
- return getattr(obj, self.name)
- setattr(self.parent.class_, self.key, SynonymProp())
-
- def merge(self, session, source, dest, _recursive):
- pass
class StrategizedProperty(MapperProperty):
"""A MapperProperty which uses selectable strategies to affect
def process_query(self, query):
pass
+class ExtensionOption(MapperOption):
+ """a MapperOption that applies a MapperExtension to a query operation."""
+
+ def __init__(self, ext):
+ self.ext = ext
+
+ def process_query(self, query):
+ query.extension.append(self.ext)
+
+class SynonymProperty(MapperProperty):
+ def __init__(self, name, proxy=False):
+ self.name = name
+ self.proxy = proxy
+
+ def setup(self, querycontext, **kwargs):
+ pass
+
+ def get_sub_mapper(self):
+ return self.parent.props[self.name].get_sub_mapper()
+
+ def create_row_processor(self, selectcontext, mapper, row):
+ return (None, None)
+
+ def do_init(self):
+ if not self.proxy:
+ return
+ class SynonymProp(object):
+ def __set__(s, obj, value):
+ setattr(obj, self.name, value)
+ def __delete__(s, obj):
+ delattr(obj, self.name)
+ def __get__(s, obj, owner):
+ if obj is None:
+ return s
+ return getattr(obj, self.name)
+ setattr(self.parent.class_, self.key, SynonymProp())
+
+ def merge(self, session, source, dest, _recursive):
+ pass
+
class PropertyOption(MapperOption):
"""A MapperOption that is applied to a property off the mapper or
one of its child mappers, identified by a dot-separated key.
from sqlalchemy import sql, schema, util, exceptions, logging
from sqlalchemy import sql_util as sqlutil
from sqlalchemy.orm import util as mapperutil
+from sqlalchemy.orm.util import ExtensionCarrier
from sqlalchemy.orm import sync
-from sqlalchemy.orm.interfaces import MapperProperty, MapperOption, OperationContext
+from sqlalchemy.orm.interfaces import MapperProperty, MapperOption, OperationContext, EXT_PASS, MapperExtension
import weakref
-__all__ = ['Mapper', 'MapperExtension', 'class_mapper', 'object_mapper', 'EXT_PASS', 'mapper_registry', 'ExtensionOption']
+__all__ = ['Mapper', 'class_mapper', 'object_mapper', 'mapper_registry']
# a dictionary mapping classes to their primary mappers
mapper_registry = weakref.WeakKeyDictionary()
# column
NO_ATTRIBUTE = object()
-# returned by a MapperExtension method to indicate a "do nothing" response
-EXT_PASS = object()
# lock used to synchronize the "mapper compile" step
_COMPILE_MUTEX = util.threading.Lock()
for ext_obj in util.to_list(extension):
extlist.add(ext_obj)
- self.extension = _ExtensionCarrier()
+ self.extension = ExtensionCarrier()
for ext in extlist:
self.extension.append(ext)
Mapper.logger = logging.class_logger(Mapper)
-class MapperExtension(object):
- """Base implementation for an object that provides overriding
- behavior to various Mapper functions. For each method in
- MapperExtension, a result of EXT_PASS indicates the functionality
- is not overridden.
- """
-
- def init_instance(self, mapper, class_, instance, args, kwargs):
- return EXT_PASS
-
- def init_failed(self, mapper, class_, instance, args, kwargs):
- return EXT_PASS
-
- def get_session(self):
- """Retrieve a contextual Session instance with which to
- register a new object.
-
- Note: this is not called if a session is provided with the
- `__init__` params (i.e. `_sa_session`).
- """
-
- return EXT_PASS
-
- def load(self, query, *args, **kwargs):
- """Override the `load` method of the Query object.
-
- The return value of this method is used as the result of
- ``query.load()`` if the value is anything other than EXT_PASS.
- """
-
- return EXT_PASS
-
- def get(self, query, *args, **kwargs):
- """Override the `get` method of the Query object.
-
- The return value of this method is used as the result of
- ``query.get()`` if the value is anything other than EXT_PASS.
- """
-
- return EXT_PASS
-
- def get_by(self, query, *args, **kwargs):
- """Override the `get_by` method of the Query object.
-
- The return value of this method is used as the result of
- ``query.get_by()`` if the value is anything other than
- EXT_PASS.
- """
-
- return EXT_PASS
-
- def select_by(self, query, *args, **kwargs):
- """Override the `select_by` method of the Query object.
-
- The return value of this method is used as the result of
- ``query.select_by()`` if the value is anything other than
- EXT_PASS.
- """
-
- return EXT_PASS
-
- def select(self, query, *args, **kwargs):
- """Override the `select` method of the Query object.
-
- The return value of this method is used as the result of
- ``query.select()`` if the value is anything other than
- EXT_PASS.
- """
-
- return EXT_PASS
-
-
- def translate_row(self, mapper, context, row):
- """Perform pre-processing on the given result row and return a
- new row instance.
-
- This is called as the very first step in the ``_instance()``
- method.
- """
-
- return EXT_PASS
-
- def create_instance(self, mapper, selectcontext, row, class_):
- """Receive a row when a new object instance is about to be
- created from that row.
-
- The method can choose to create the instance itself, or it can
- return None to indicate normal object creation should take
- place.
-
- mapper
- The mapper doing the operation
-
- selectcontext
- SelectionContext corresponding to the instances() call
-
- row
- The result row from the database
-
- class\_
- The class we are mapping.
- """
-
- return EXT_PASS
-
- def append_result(self, mapper, selectcontext, row, instance, result, **flags):
- """Receive an object instance before that instance is appended
- to a result list.
-
- If this method returns EXT_PASS, result appending will proceed
- normally. if this method returns any other value or None,
- result appending will not proceed for this instance, giving
- this extension an opportunity to do the appending itself, if
- desired.
-
- mapper
- The mapper doing the operation.
-
- selectcontext
- SelectionContext corresponding to the instances() call.
-
- row
- The result row from the database.
-
- instance
- The object instance to be appended to the result.
-
- result
- List to which results are being appended.
-
- \**flags
- extra information about the row, same as criterion in
- `create_row_processor()` method of [sqlalchemy.orm.interfaces#MapperProperty]
- """
-
- return EXT_PASS
-
- def populate_instance(self, mapper, selectcontext, row, instance, **flags):
- """Receive a newly-created instance before that instance has
- its attributes populated.
-
- The normal population of attributes is according to each
- attribute's corresponding MapperProperty (which includes
- column-based attributes as well as relationships to other
- classes). If this method returns EXT_PASS, instance
- population will proceed normally. If any other value or None
- is returned, instance population will not proceed, giving this
- extension an opportunity to populate the instance itself, if
- desired.
- """
-
- return EXT_PASS
-
- def before_insert(self, mapper, connection, instance):
- """Receive an object instance before that instance is INSERTed
- into its table.
-
- This is a good place to set up primary key values and such
- that aren't handled otherwise.
- """
-
- return EXT_PASS
-
- def before_update(self, mapper, connection, instance):
- """Receive an object instance before that instance is UPDATEed."""
-
- return EXT_PASS
-
- def after_update(self, mapper, connection, instance):
- """Receive an object instance after that instance is UPDATEed."""
-
- return EXT_PASS
-
- def after_insert(self, mapper, connection, instance):
- """Receive an object instance after that instance is INSERTed."""
-
- return EXT_PASS
-
- def before_delete(self, mapper, connection, instance):
- """Receive an object instance before that instance is DELETEed."""
-
- return EXT_PASS
- def after_delete(self, mapper, connection, instance):
- """Receive an object instance after that instance is DELETEed."""
-
- return EXT_PASS
-
-class _ExtensionCarrier(MapperExtension):
- def __init__(self):
- self.__elements = []
-
- def __iter__(self):
- return iter(self.__elements)
-
- def insert(self, extension):
- """Insert a MapperExtension at the beginning of this ExtensionCarrier's list."""
-
- self.__elements.insert(0, extension)
-
- def append(self, extension):
- """Append a MapperExtension at the end of this ExtensionCarrier's list."""
-
- self.__elements.append(extension)
-
- def _create_do(funcname):
- def _do(self, *args, **kwargs):
- for elem in self.__elements:
- ret = getattr(elem, funcname)(*args, **kwargs)
- if ret is not EXT_PASS:
- return ret
- else:
- return EXT_PASS
- return _do
-
- init_instance = _create_do('init_instance')
- init_failed = _create_do('init_failed')
- dispose_class = _create_do('dispose_class')
- get_session = _create_do('get_session')
- load = _create_do('load')
- get = _create_do('get')
- get_by = _create_do('get_by')
- select_by = _create_do('select_by')
- select = _create_do('select')
- translate_row = _create_do('translate_row')
- create_instance = _create_do('create_instance')
- append_result = _create_do('append_result')
- populate_instance = _create_do('populate_instance')
- before_insert = _create_do('before_insert')
- before_update = _create_do('before_update')
- after_update = _create_do('after_update')
- after_insert = _create_do('after_insert')
- before_delete = _create_do('before_delete')
- after_delete = _create_do('after_delete')
-
-
-class ExtensionOption(MapperOption):
- def __init__(self, ext):
- self.ext = ext
-
- def process_query(self, query):
- query.extension.append(self.ext)
class ClassKey(object):
"""Key a class and an entity name to a mapper, via the mapper_registry."""
import sets, random
from sqlalchemy.orm.interfaces import *
+__all__ = ['ColumnProperty', 'PropertyLoader', 'BackRef']
+
class ColumnProperty(StrategizedProperty):
"""Describes an object attribute that corresponds to a table column."""
else:
return strategies.ColumnLoader(self)
+ def get_sub_mapper(self):
+ return None
+
def getattr(self, object):
return getattr(object, self.key)
mapper.ColumnProperty = ColumnProperty
+
+
class PropertyLoader(StrategizedProperty):
"""Describes an object property that holds a single item or list
of items that correspond to a related database table.
private = property(lambda s:s.cascade.delete_orphan)
+ def get_sub_mapper(self):
+ return self.mapper
+
def create_strategy(self):
if self.lazy:
return strategies.LazyLoader(self)
from sqlalchemy import sql, util, exceptions, sql_util, logging, schema
from sqlalchemy.orm import mapper, class_mapper, object_mapper
from sqlalchemy.orm.interfaces import OperationContext, SynonymProperty
+from sqlalchemy.orm.util import ExtensionCarrier
__all__ = ['Query', 'QueryContext', 'SelectionContext']
self.select_mapper = self.mapper.get_select_mapper().compile()
self.always_refresh = kwargs.pop('always_refresh', self.mapper.always_refresh)
self.lockmode = lockmode
- self.extension = mapper._ExtensionCarrier()
+ self.extension = ExtensionCarrier()
if extension is not None:
self.extension.append(extension)
self.extension.append(self.mapper.extension)
q._session = self.session
q.is_polymorphic = self.is_polymorphic
q.lockmode = self.lockmode
- q.extension = mapper._ExtensionCarrier()
- for ext in self.extension:
- q.extension.append(ext)
+ q.extension = self.extension.copy()
q._offset = self._offset
q._limit = self._limit
q._group_by = self._group_by
"""sqlalchemy.orm.interfaces.LoaderStrategy implementations, and related MapperOptions."""
from sqlalchemy import sql, schema, util, exceptions, sql_util, logging
-from sqlalchemy.orm import mapper, query
+from sqlalchemy.orm import mapper
from sqlalchemy.orm.interfaces import *
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm import session as sessionlib
# determine if our "lazywhere" clause is the same as the mapper's
# get() clause. then we can just use mapper.get()
+ from sqlalchemy.orm import query
self.use_get = not self.uselist and query.Query(self.mapper)._get_clause.compare(self.lazywhere)
if self.use_get:
self.logger.info(str(self.parent_property) + " will use query.get() to optimize instance loads")
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from sqlalchemy import sql, util, exceptions
+from sqlalchemy.orm.interfaces import MapperExtension, EXT_PASS
all_cascades = util.Set(["delete", "delete-orphan", "all", "merge",
"expunge", "save-update", "refresh-expire", "none"])
def setdefault(self, col, value):
return super(TranslatingDict, self).setdefault(self.__translate_col(col), value)
+class ExtensionCarrier(MapperExtension):
+ def __init__(self, _elements=None):
+ self.__elements = _elements or []
+
+ def copy(self):
+ return ExtensionCarrier(list(self.__elements))
+
+ def __iter__(self):
+ return iter(self.__elements)
+
+ def insert(self, extension):
+ """Insert a MapperExtension at the beginning of this ExtensionCarrier's list."""
+
+ self.__elements.insert(0, extension)
+
+ def append(self, extension):
+ """Append a MapperExtension at the end of this ExtensionCarrier's list."""
+
+ self.__elements.append(extension)
+
+ def _create_do(funcname):
+ def _do(self, *args, **kwargs):
+ for elem in self.__elements:
+ ret = getattr(elem, funcname)(*args, **kwargs)
+ if ret is not EXT_PASS:
+ return ret
+ else:
+ return EXT_PASS
+ return _do
+
+ init_instance = _create_do('init_instance')
+ init_failed = _create_do('init_failed')
+ dispose_class = _create_do('dispose_class')
+ get_session = _create_do('get_session')
+ load = _create_do('load')
+ get = _create_do('get')
+ get_by = _create_do('get_by')
+ select_by = _create_do('select_by')
+ select = _create_do('select')
+ translate_row = _create_do('translate_row')
+ create_instance = _create_do('create_instance')
+ append_result = _create_do('append_result')
+ populate_instance = _create_do('populate_instance')
+ before_insert = _create_do('before_insert')
+ before_update = _create_do('before_update')
+ after_update = _create_do('after_update')
+ after_insert = _create_do('after_insert')
+ before_delete = _create_do('before_delete')
+ after_delete = _create_do('after_delete')
+
class BinaryVisitor(sql.ClauseVisitor):
def __init__(self, func):
self.func = func
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
class AssociationTest(testbase.PersistTest):
from sqlalchemy.ext.sessioncontext import SessionContext
from sqlalchemy import *
+from sqlalchemy.orm import *
class O2MCascadeTest(testbase.AssertMixin):
def tearDown(self):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
+
class CompileTest(testbase.AssertMixin):
"""test various mapper compilation scenarios"""
from testbase import PersistTest, AssertMixin, ORMTest
import unittest, sys, os
from sqlalchemy import *
+from sqlalchemy.orm import *
import StringIO
import testbase
import testbase
import unittest, sys, os
from sqlalchemy import *
+from sqlalchemy.orm import *
import datetime
class EagerTest(AssertMixin):
import testbase
import unittest, sys, os
from sqlalchemy import *
+from sqlalchemy.orm import *
import datetime
from sqlalchemy.ext.sessioncontext import SessionContext
from testbase import PersistTest, AssertMixin
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
from sqlalchemy.ext.selectresults import SelectResults
import random
from testbase import PersistTest, AssertMixin
import unittest
from sqlalchemy import *
+from sqlalchemy.orm import *
import testbase
from sqlalchemy.ext.sessioncontext import SessionContext
import tables
from sqlalchemy import *
+from sqlalchemy.orm import *
from sqlalchemy import exceptions
class Foo(object):
from sqlalchemy import *
+from sqlalchemy.orm import *
+
from sqlalchemy.orm.sync import ONETOMANY, MANYTOONE
import testbase
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
class O2MTest(testbase.ORMTest):
from sqlalchemy import *
+from sqlalchemy.orm import *
import testbase
class ConcreteTest1(testbase.ORMTest):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
+
class BaseObject(object):
def __init__(self, *args, **kwargs):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
class InheritTest(testbase.ORMTest):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
class PolymorphicCircularTest(testbase.ORMTest):
keep_mappers = True
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
+
import sets
# tests basic polymorphic mapper loading/saving, minimal relations
from sqlalchemy import *
+from sqlalchemy.orm import *
+
import testbase
class AttrSettable(object):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
+
from datetime import datetime
class InheritTest(testbase.ORMTest):
from sqlalchemy import *
+from sqlalchemy.orm import *
+
import testbase
class SingleInheritanceTest(testbase.AssertMixin):
import testbase
import unittest, sys, os
from sqlalchemy import *
+from sqlalchemy.orm import *
import datetime
class LazyTest(AssertMixin):
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
import string
class Place(object):
import testbase
import unittest, sys, os
from sqlalchemy import *
+from sqlalchemy.orm import *
import sqlalchemy.exceptions as exceptions
from sqlalchemy.ext.sessioncontext import SessionContext, SessionContextExt
from tables import *
from sqlalchemy import *
+from sqlalchemy.orm import *
from sqlalchemy.orm import mapperlib, session, unitofwork, attributes
Mapper = mapperlib.Mapper
import gc
from testbase import PersistTest, AssertMixin
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
from tables import *
import tables
import testbase
from sqlalchemy import *
+from sqlalchemy.orm import *
from sqlalchemy.ext.sessioncontext import SessionContext
class Jack(object):
#db.
from sqlalchemy import *
+from sqlalchemy.orm import *
class RelationTest(testbase.PersistTest):
db = testbase.db
from sqlalchemy import *
+from sqlalchemy.orm import *
class SessionTest(AssertMixin):
from sqlalchemy.ext.sessioncontext import SessionContext
from sqlalchemy.orm.session import object_session, Session
from sqlalchemy import *
+from sqlalchemy.orm import *
+
import testbase
metadata = MetaData()
from testbase import PersistTest, AssertMixin
from sqlalchemy import *
+from sqlalchemy.orm import *
import testbase
import pickleable
from sqlalchemy.orm.mapper import global_extensions