]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix broken orm debug logging
authorPhilip Jenvey <pjenvey@underboss.org>
Wed, 29 Jul 2009 00:41:26 +0000 (00:41 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Wed, 29 Jul 2009 00:41:26 +0000 (00:41 +0000)
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/strategies.py

index aac271efecfbfc4c19fb25967aa0d5073e42068b..d53faacf711ee04610a25e37b7a4dae521c49d01 100644 (file)
@@ -1271,8 +1271,8 @@ class Mapper(object):
                             (state_str(state), instance_key, state_str(existing)))
                     if self._should_log_debug:
                         self._log_debug(
-                            "detected row switch for identity %s.  will update %s, remove %s from transaction", 
-                            instance_key, state_str(state), state_str(existing))
+                            "detected row switch for identity %s.  will update %s, remove %s from "
+                            "transaction" % (instance_key, state_str(state), state_str(existing)))
                             
                     # remove the "delete" flag from the existing element
                     uowtransaction.set_row_switch(existing)
@@ -1291,7 +1291,8 @@ class Mapper(object):
                 pks = mapper._pks_by_table[table]
                 
                 if self._should_log_debug:
-                    self._log_debug("_save_obj() table '%s' instance %s identity %s" % (table.name, state_str(state), str(instance_key)))
+                    self._log_debug("_save_obj() table '%s' instance %s identity %s" %
+                                    (table.name, state_str(state), str(instance_key)))
 
                 isinsert = not has_identity and not postupdate and state not in row_switches
                 
@@ -1305,7 +1306,9 @@ class Mapper(object):
                             params[col.key] = 1
                         elif mapper.polymorphic_on and mapper.polymorphic_on.shares_lineage(col):
                             if self._should_log_debug:
-                                self._log_debug("Using polymorphic identity '%s' for insert column '%s'" % (mapper.polymorphic_identity, col.key))
+                                self._log_debug(
+                                    "Using polymorphic identity '%s' for insert column '%s'" %
+                                    (mapper.polymorphic_identity, col.key))
                             value = mapper.polymorphic_identity
                             if ((col.default is None and
                                  col.server_default is None) or
@@ -1623,8 +1626,8 @@ class Mapper(object):
                 dict_ = attributes.instance_dict(instance)
 
                 if self._should_log_debug:
-                    self._log_debug("_instance(): using existing instance %s identity %s",
-                                        instance_str(instance), identitykey)
+                    self._log_debug("_instance(): using existing instance %s identity %s" %
+                                    (instance_str(instance), identitykey))
 
                 isnew = state.runid != context.runid
                 currentload = not isnew
@@ -1647,7 +1650,7 @@ class Mapper(object):
                 loaded_instance = False
             else:
                 if self._should_log_debug:
-                    self._log_debug("_instance(): identity key %s not in session", identitykey)
+                    self._log_debug("_instance(): identity key %s not in session" % (identitykey,))
 
                 if self.allow_null_pks:
                     for x in identitykey[1]:
@@ -1675,8 +1678,8 @@ class Mapper(object):
                     instance = self.class_manager.new_instance()
 
                 if self._should_log_debug:
-                    self._log_debug("_instance(): created new instance %s identity %s",
-                                instance_str(instance), identitykey)
+                    self._log_debug("_instance(): created new instance %s identity %s" %
+                                    (instance_str(instance), identitykey))
 
                 dict_ = attributes.instance_dict(instance)
                 state = attributes.instance_state(instance)
index df21b24acc1a303dfcafd9447301097949d9cacd..1da2231a3af325f1d66b9e608ebed74d5d59c131 100644 (file)
@@ -121,7 +121,9 @@ class ColumnLoader(LoaderStrategy):
             if self._should_log_debug:
                 new_execute = self.debug_callable(new_execute, self.logger,
                     "%s returning active column fetcher" % self,
-                    lambda state, row, **flags: "%s populating %s" % (self, mapperutil.state_attribute_str(state, key))
+                    lambda state, dict_, row, **flags: "%s populating %s" % \
+                                                      (self,
+                                                       mapperutil.state_attribute_str(state, key))
                 )
             return (new_execute, None)
         else:
@@ -184,7 +186,8 @@ class CompositeColumnLoader(ColumnLoader):
             if self._should_log_debug:
                 new_execute = self.debug_callable(new_execute, self.logger,
                     "%s returning active composite column fetcher" % self,
-                    lambda state, row, **flags: "populating %s" % (mapperutil.state_attribute_str(state, key))
+                    lambda state, dict_, row, **flags: "populating %s" % \
+                                                      (mapperutil.state_attribute_str(state, key))
                 )
 
             return (new_execute, None)
@@ -212,7 +215,8 @@ class DeferredColumnLoader(LoaderStrategy):
 
         if self._should_log_debug:
             new_execute = self.debug_callable(new_execute, self.logger, None,
-                lambda state, row, **flags: "set deferred callable on %s" % mapperutil.state_attribute_str(state, self.key)
+                lambda state, dict_, row, **flags: "set deferred callable on %s" % \
+                                                  mapperutil.state_attribute_str(state, self.key)
             )
         return (new_execute, None)
 
@@ -345,7 +349,8 @@ class NoLoader(AbstractRelationLoader):
 
         if self._should_log_debug:
             new_execute = self.debug_callable(new_execute, self.logger, None,
-                lambda state, row, **flags: "initializing blank scalar/collection on %s" % mapperutil.state_attribute_str(state, self.key)
+                lambda state, dict_, row, **flags: "initializing blank scalar/collection on %s" % \
+                                                  mapperutil.state_attribute_str(state, self.key)
             )
         return (new_execute, None)
 
@@ -441,28 +446,34 @@ class LazyLoader(AbstractRelationLoader):
     def create_row_processor(self, selectcontext, path, mapper, row, adapter):
         if not self.is_class_level:
             def new_execute(state, dict_, row, **flags):
-                # we are not the primary manager for this attribute on this class - set up a per-instance lazyloader,
-                # which will override the class-level behavior.
-                # this currently only happens when using a "lazyload" option on a "no load" attribute -
-                # "eager" attributes always have a class-level lazyloader installed.
+                # we are not the primary manager for this attribute on this class - set up a
+                # per-instance lazyloader, which will override the class-level behavior.
+                # this currently only happens when using a "lazyload" option on a "no load"
+                # attribute - "eager" attributes always have a class-level lazyloader
+                # installed.
                 self._init_instance_attribute(state, callable_=LoadLazyAttribute(state, self.key))
 
             if self._should_log_debug:
                 new_execute = self.debug_callable(new_execute, self.logger, None,
-                    lambda state, row, **flags: "set instance-level lazy loader on %s" % mapperutil.state_attribute_str(state, self.key)
+                    lambda state, dict_, row, **flags: "set instance-level lazy loader on %s" % \
+                                                      mapperutil.state_attribute_str(state,
+                                                                                     self.key)
                 )
 
             return (new_execute, None)
         else:
             def new_execute(state, dict_, row, **flags):
-                # we are the primary manager for this attribute on this class - reset its per-instance attribute state, 
-                # so that the class-level lazy loader is executed when next referenced on this instance.
-                # this is needed in populate_existing() types of scenarios to reset any existing state.
+                # we are the primary manager for this attribute on this class - reset its
+                # per-instance attribute state, so that the class-level lazy loader is
+                # executed when next referenced on this instance.  this is needed in
+                # populate_existing() types of scenarios to reset any existing state.
                 state.reset(self.key, dict_)
 
             if self._should_log_debug:
                 new_execute = self.debug_callable(new_execute, self.logger, None,
-                    lambda state, row, **flags: "set class-level lazy loader on %s" % mapperutil.state_attribute_str(state, self.key)
+                    lambda state, dict_, row, **flags: "set class-level lazy loader on %s" % \
+                                                      mapperutil.state_attribute_str(state,
+                                                                                     self.key)
                 )
 
             return (new_execute, None)
@@ -767,7 +778,10 @@ class EagerLoader(AbstractRelationLoader):
             if self._should_log_debug:
                 execute = self.debug_callable(execute, self.logger, 
                     "%s returning eager instance loader" % self,
-                    lambda state, row, isnew, **flags: "%s eagerload %s" % (self, self.uselist and "scalar attribute" or "collection")
+                    lambda state, dict_, row, isnew, **flags: "%s eagerload %s" % \
+                                                  (self,
+                                                   self.uselist and "scalar attribute"
+                                                   or "collection")
                 )
 
             return (execute, execute)