I fear I type too much. Let me try this a different way. I have a template tag (discount_price) that intermittently breaks -- throws a ProgrammingError with "Error in formatting: couldn't adapt" message (debian stable, apache2, mod-wsgi, satchmo 0.9.1. stable). I don't know what causes it to happen. Restarting the server makes the problem go away. While the problem is happening, I can fire up the django shell and invoke the template tag with no problems. It seems it must have something to do with the apache process's connection to the postgresql database.
Has anyone seen anything like this before? --Stuart On Wed, Jun 9, 2010 at 11:31 PM, Stuart Laughlin <[email protected]> wrote: > Hello Everyone -- > > I have a recurring intermittent problem that I've been battling off > and on for the past few months. The error initially manifests itself > as a ProgrammingError in the product template on the bit that says "{{ > product|discount_price:sale|currency }}". I've been dealing with it up > till now by commenting it out, avoiding using the discount_price > template tag, etc. Finally I resolved to get to the bottom of it and > added some logging to the get_product view. Well, the only effect that > had was to move the origin of the error from the template to my > logging statement in the view (but at least it seems like I get a > better stack trace when the error happens in the view!). > > At any rate, I'm looking at my stack trace, and I think I understand > what's happening. My logging statement in the get_product() view > throws an error when I invoke the discount_price template-tag method: > > log.debug("product|discount_price:sale is %s" % > discount_price(product, best_discount)) > > The error appears to actually occur in product/prices.py on line 14 here: > > 8. qty_discounts = product.price_set.exclude( > 9. expires__isnull=False, > 10. expires__lt=datetime.date.today()).filter(quantity__lte=qty) > 11. > 12. adjustments = None > 13. > 14. if qty_discounts.count() > 0: > 15. # Get the price with the quantity closest to the one specified > without going over > 16. adjustments = qty_discounts.order_by('price','-quantity', > 'expires')[0].adjustments(product) > > Line 14 executes the query defined in lines 8-10, and qty_discounts > ends up being set to "Error in formatting: can't adapt". > > At the moment I'm getting this error every time I navigate to a > product (which obviously invokes my get_product view). I suspect that > when I restart apache, the error will go away. > > But here's the really odd thing: I can use "manage.py" to fire up the > shell and run the discount_price template tag with no problems, even > though I'm running it exactly like I am in the logging statement. So I > find this very puzzling. Has anyone seen anything like this? I'm > really hoping someone can point me in the right direction. > > Oh, and I'm on version 0.9.1 final. > > Full traceback follows my signature. > > > Thanks very much! > > --Stuart > > Environment: > > Request Method: GET > Request URL: http://10.10.20.20/vw/product/basic-black-center-console-304734/ > Django Version: 1.1.1 > Python Version: 2.5.2 > Installed Applications: > ['django.contrib.sites', > 'satchmo_store.shop', > 'django.contrib.admin', > 'django.contrib.auth', > 'django.contrib.admindocs', > 'django.contrib.contenttypes', > 'django.contrib.comments', > 'django.contrib.sessions', > 'django.contrib.sitemaps', > 'registration', > 'keyedcache', > 'livesettings', > 'l10n', > 'sorl.thumbnail', > 'satchmo_store.contact', > 'tax', > 'tax.modules.no', > 'tax.modules.area', > 'tax.modules.percent', > 'shipping', > 'product', > 'product.modules.configurable', > 'payment', > 'payment.modules.dummy', > 'payment.modules.giftcertificate', > 'satchmo_utils', > 'app_plugins', > 'satchmo_ext.productratings', > 'satchmo_ext.recentlist', > 'satchmo_ext.upsell', > 'satchmo_ext.wishlist', > 'satchel', > 'south', > 'ecomm', > 'filer', > 'tinymce', > 'debug_toolbar'] > Installed Middleware: > ('django.middleware.cache.UpdateCacheMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware', > 'threaded_multihost.middleware.ThreadLocalMiddleware', > 'satchmo_store.shop.SSLMiddleware.SSLRedirect', > 'debug_toolbar.middleware.DebugToolbarMiddleware', > 'passion.middleware.FilterPersistMiddleware', > 'django.middleware.cache.FetchFromCacheMiddleware') > > > Traceback: > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/core/handlers/base.py" > in get_response > 92. response = callback(request, *callback_args, > **callback_kwargs) > File > "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/views/__init__.py" > in get_product > 161. log.debug("product|discount_price:sale is %s" % > discount_price(product, best_discount)) > File > "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/templatetags/satchmo_discounts.py" > in discount_price > 107. return untaxed_discount_price(product, discount) > File > "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/templatetags/satchmo_discounts.py" > in untaxed_discount_price > 117. up = product.unit_price > File "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/models.py" > in _get_fullPrice > 925. price = get_product_quantity_price(self, Decimal('1')) > File "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/prices.py" > in get_product_quantity_price > 32. adjustments = get_product_quantity_adjustments(product, > qty=qty, parent=parent) > File "/usr/local/python-envs/satch/src/satchmo/satchmo/apps/product/prices.py" > in get_product_quantity_adjustments > 14. if qty_discounts.count() > 0: > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/db/models/query.py" > in count > 292. return self.query.get_count() > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/db/models/sql/query.py" > in get_count > 376. number = obj.get_aggregation()[None] > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/db/models/sql/query.py" > in get_aggregation > 348. result = query.execute_sql(SINGLE) > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/db/models/sql/query.py" > in execute_sql > 2369. cursor.execute(sql, params) > File > "/usr/local/python-envs/satch/lib/python2.5/site-packages/django/db/backends/util.py" > in execute > 19. return self.cursor.execute(sql, params) > > Exception Type: ProgrammingError at > /product/basic-black-center-console-304734/ > Exception Value: can't adapt > -- You received this message because you are subscribed to the Google Groups "Satchmo users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.
