]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- mapper _get_col_to_prop private method used
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Sep 2010 15:28:43 +0000 (11:28 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Sep 2010 15:28:43 +0000 (11:28 -0400)
by the versioning example is deprecated;
now use mapper.get_property_by_column() which
will remain the public method for this.
- turned TODO in the history example into an assertion
with a descriptive reason

CHANGES
examples/versioning/history_meta.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/test/testing.py

diff --git a/CHANGES b/CHANGES
index 2fe9bbe57eb345c32f8f47aba3a4a5b0eeeb89fb..43b6336811291864078724a3dc046936013e5e1d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -160,6 +160,11 @@ CHANGES
     with significant (~90%) runtime mapper.py call count reduction
     in heavily polymorphic mapping configurations.
 
+  - mapper _get_col_to_prop private method used 
+    by the versioning example is deprecated; 
+    now use mapper.get_property_by_column() which 
+    will remain the public method for this.
+    
 - sql
   - Added basic math expression coercion for 
     Numeric->Integer,
index c2b283f1a04541c5d1dbe7ea5b411660652b38e3..d2d7c124774898cf78d383da886d1fd7daf6cd6d 100644 (file)
@@ -123,7 +123,7 @@ def create_version(obj, session, deleted = False):
             # mapped column.  this will allow usage of MapperProperties
             # that have a different keyname than that of the mapped column.
             try:
-                prop = obj_mapper._get_col_to_prop(obj_col)
+                prop = obj_mapper.get_property_by_column(obj_col)
             except UnmappedColumnError:
                 # in the case of single table inheritance, there may be 
                 # columns on the mapped table intended for the subclass only.
@@ -144,7 +144,9 @@ def create_version(obj, session, deleted = False):
             elif u:
                 attr[hist_col.key] = u[0]
             else:
-                raise Exception("TODO: what makes us arrive here ?")
+                assert False, "Attribute had no previous state. "\
+                            "This indicates active_history isn't "\
+                            "working as expected."
                 
     if not obj_changed and not deleted:            
         return
index f03dd6377223b4caffed8163e59626db4d0f7583..7d487ff2cdc80aaee213d43f0fed7c9f5d8d7856 100644 (file)
@@ -931,7 +931,19 @@ class Mapper(object):
                         "Mapper '%s' has no property '%s'" % (self, key))
                 else:
                     return None
+    
+    @util.deprecated('0.7',
+                     'Call to deprecated function mapper._get_col_to_pr'
+                     'op(). Use mapper.get_property_by_column()')
+    def _get_col_to_prop(self, col):
+        return self._columntoproperty[col]
+        
+    def get_property_by_column(self, column):
+        """Given a :class:`.Column` object, return the
+        :class:`.MapperProperty` which maps this column."""
 
+        return self._columntoproperty[column]
+        
     @property
     def iterate_properties(self):
         """return an iterator of all MapperProperty objects."""
index 78cd74d22c9df300c74c59eb68cf94ac9f5942b2..d09621dc8b5108c661ad23145acf1803d0e1d713 100644 (file)
@@ -398,6 +398,7 @@ def uses_deprecated(*messages):
     verbiage emitted by the sqlalchemy.util.deprecated decorator.
     """
 
+    
     def decorate(fn):
         def safe(*args, **kw):
             # todo: should probably be strict about this, too