summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-11 12:21:36 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-11 12:21:36 -0400
commit2d7cc7f996579703baac12ff97995465f0e06091 (patch)
tree467e9a928c70d43455f4f8a8ddda363784119ebe /lib/sqlalchemy
parent9e50f119e9344d180768ffe2523eb169682e2957 (diff)
downloadsqlalchemy-2d7cc7f996579703baac12ff97995465f0e06091.tar.gz
move factory function to classmethod
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/dependency.py21
-rw-r--r--lib/sqlalchemy/orm/properties.py3
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py
index b84794699..731b21549 100644
--- a/lib/sqlalchemy/orm/dependency.py
+++ b/lib/sqlalchemy/orm/dependency.py
@@ -13,15 +13,6 @@ import sqlalchemy.exceptions as sa_exc
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
@@ -41,7 +32,11 @@ class DependencyProcessor(object):
"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
@@ -1010,3 +1005,9 @@ class ManyToManyDP(DependencyProcessor):
self.parent,
self.prop.synchronize_pairs)
+_direction_to_processor = {
+ ONETOMANY : OneToManyDP,
+ MANYTOONE: ManyToOneDP,
+ MANYTOMANY : ManyToManyDP,
+}
+
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 8f9cb8525..41a8877bf 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -1194,7 +1194,8 @@ class RelationshipProperty(StrategizedProperty):
self.uselist = self.direction is not MANYTOONE
if not self.viewonly:
- self._dependency_processor = dependency.create_dependency_processor(self)
+ self._dependency_processor = \
+ dependency.DependencyProcessor.from_relationship(self)
@util.memoized_property
def _use_get(self):