from sqlalchemy.orm import attributes, exc, sync, unitofwork, util as mapperutil
from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE, MANYTOMANY
-
-def create_dependency_processor(prop):
- types = {
- ONETOMANY : OneToManyDP,
- MANYTOONE: ManyToOneDP,
- MANYTOMANY : ManyToManyDP,
- }
- return types[prop.direction](prop)
-
class DependencyProcessor(object):
def __init__(self, prop):
self.prop = prop
"No target attributes to populate between parent and "
"child are present" %
self.prop)
-
+
+ @classmethod
+ def from_relationship(cls, prop):
+ return _direction_to_processor[prop.direction](prop)
+
def hasparent(self, state):
"""return True if the given object instance has a parent,
according to the ``InstrumentedAttribute`` handled by this
self.parent,
self.prop.synchronize_pairs)
+_direction_to_processor = {
+ ONETOMANY : OneToManyDP,
+ MANYTOONE: ManyToOneDP,
+ MANYTOMANY : ManyToManyDP,
+}
+