- relation() can accept a callable for its first argument,

which returns the class to be related.  This is in place
to assist declarative packages to define relations without
classes yet being in place.
This commit is contained in:
Mike Bayer
2008-03-10 00:59:51 +00:00
parent 4bd956b50f
commit 9d3216d3f3
2 changed files with 9 additions and 1 deletions
+6 -1
View File
@@ -77,7 +77,12 @@ CHANGES
- deprecated Query methods apply_sum(), apply_max(), apply_min(),
apply_avg(). Better methodologies are coming....
- relation() can accept a callable for its first argument,
which returns the class to be related. This is in place
to assist declarative packages to define relations without
classes yet being in place.
- Added a new "higher level" operator called "of_type()": used
in join() as well as with any() and has(), qualifies the
subclass which will be used in filter criterion, e.g.:
+3
View File
@@ -468,6 +468,9 @@ class PropertyLoader(StrategizedProperty):
self.mapper = mapper.class_mapper(self.argument, entity_name=self.entity_name, compile=False)
elif isinstance(self.argument, mapper.Mapper):
self.mapper = self.argument
elif callable(self.argument):
# accept a callable to suit various deferred-configurational schemes
self.mapper = mapper.class_mapper(self.argument(), entity_name=self.entity_name, compile=False)
else:
raise exceptions.ArgumentError("relation '%s' expects a class or a mapper argument (received: %s)" % (self.key, type(self.argument)))