Tomas Neme  committed 23f5695

added a lot of logging. Some of it might be a little redundant, but we really need some insight

  • Participants
  • Parent commits d46fb7b

Comments (0)

Files changed (1)

File satchmo/apps/satchmo_store/shop/

 import operator
 import signals
+import traceback
 log = logging.getLogger('')
+def format_traceback(count=15):
+    """
+    Return a string with the traceback up to `count` frames
+    """
+    return "".join(traceback.format_stack(limit=count))
 class NullConfig(object):
     """Standin for a real config when we don't have one yet."""
     def remove_all_items(self):
         """Delete all items belonging to this order."""
+        log.debug("Removing all items from Order #%d %s",
+        , format_traceback())
         for item in self.orderitem_set.all():
     def _balance(self):
         if is None:
+        else:
+            log.debug("balance for Order #%d. Skipping recalculate %s",
+            , format_traceback())
         return trunc_decimal(, 2)
     balance = property(fget=_balance)
     def _is_partially_paid(self):
-            return (
+            ret = (
                 float(self.balance) > 0.0
                 and float(self.balance_paid) > 0.0
                 and self.balance != self.balance_paid
+            if ret:
+                log.debug("Order #%d partially paid: balance: %s balance_paid: %s",, self.balance, self.balance_paid)
+            return ret
             return False
         Copy addresses from contact. If the order has just been created, set
         the create_date.
+        log.debug("Saving order #%d. %s",,
+                  format_traceback(10))
         if not
             self.time_stamp =
     def force_recalculate_total(self, save=True):
         """Calculates sub_total, taxes and total."""
+        log.debug("recalculate total from Order #%d\n%s",
+        , format_traceback())
         zero = Decimal("0.0000000000")
         total_discount = Decimal("0.0000000000")
     def _paid_in_full(self):
         """True if total has been paid"""
+        log.debug("Order #%d paid in full? %s", self.balance)
         return self.balance == Decimal('0.00')
     paid_in_full = property(fget=_paid_in_full)
     line_total = property(_get_line_total)
     def save(self, **kwargs):
+        log.debug("Saving OrderItem #%d for Order #%d, %s",
+        ,, format_traceback())
         super(OrderItem, self).save(**kwargs)
     def update_tax(self):
+        log.debug("OrderItem #%d update_tax. Before: %s",
         taxclass = self.product.taxClass
         processor = get_tax_processor(order=self.order)
         if self.product.taxable:
             self.unit_tax = processor.by_price(taxclass, self.unit_price)
    = processor.by_orderitem(self)
+        log.debug("OrderItem #%d update_tax. After: %s",
     class Meta:
         verbose_name = _("Order Line Item")