]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
logging of syncrules
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 8 Oct 2006 20:38:03 +0000 (20:38 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 8 Oct 2006 20:38:03 +0000 (20:38 +0000)
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/sync.py

index 84ff75a795a8670cff64bd50cc71f694e247ae7f..9a4fd68cb13d17ce0c6139135ac4a2e36f80f777 100644 (file)
@@ -895,6 +895,8 @@ class Mapper(object):
                     mapper._postfetch(connection, table, obj, c, c.last_inserted_params())
                     
                     # synchronize newly inserted ids from one table to the next
+                    # TODO: this fires off more than needed, try to organize syncrules
+                    # per table
                     def sync(mapper):
                         inherit = mapper.inherits
                         if inherit is not None:
index c43bd69e0aaa5e7eb6169a3f255ccb85c13815b1..91def73619090f08d874d4ff0052b97020b5f004 100644 (file)
@@ -9,6 +9,8 @@
 import sqlalchemy.sql as sql
 import sqlalchemy.schema as schema
 from sqlalchemy.exceptions import *
+from sqlalchemy import logging
+import util as mapperutil
 
 """contains the ClauseSynchronizer class, which is used to map attributes between two objects
 in a manner corresponding to a SQL clause that compares column values."""
@@ -121,8 +123,11 @@ class SyncRule(object):
         if isinstance(dest, dict):
             dest[self.dest_column.key] = value
         else:
-            #print "SYNC VALUE", value, "TO", dest, self.source_column, self.dest_column
+            if logging.is_debug_enabled(self.logger):
+                self.logger.debug("execute() instances: %s(%s)->%s(%s) ('%s')" % (mapperutil.instance_str(source), str(self.source_column), mapperutil.instance_str(dest), str(self.dest_column), value))
             self.dest_mapper._setattrbycolumn(dest, self.dest_column, value)
+
+SyncRule.logger = logging.class_logger(SyncRule)
             
 class BinaryVisitor(sql.ClauseVisitor):
     def __init__(self, func):