]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- relation() can accept a callable for its first argument,
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Mar 2008 00:59:51 +0000 (00:59 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Mar 2008 00:59:51 +0000 (00:59 +0000)
which returns the class to be related.  This is in place
to assist declarative packages to define relations without
classes yet being in place.

CHANGES
lib/sqlalchemy/orm/properties.py

diff --git a/CHANGES b/CHANGES
index 32355b56eeee3f695f9c837f30f76f4efa7afb52..d905bbc6dea54dff30cb0776d19109a8456663f1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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.:
index 8e17157da7bc2dbf36b674ad81db3d3206838a43..79c4ba63b0174ed6f30625c5e2ca8c141215db1d 100644 (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)))