I get this error when following the example at 
http://www.satchmoproject.com/docs/dev/signals.html
(I have attached the error log to this post.)
The wording of the error is: "Error binding parameter 1 - probably 
unsupported type."
What am I doing wrong? I'm pretty sure my code is the same as the example.

Here is my code:

from satchmo_store.shop.exceptions import CartAddProhibited
from django.utils.translation import gettext_lazy as _

class ContactCannotOrder(CartAddProhibited):
    def __init__(self, contact, product, msg):
        super(ContactCannotOrder, self).__init__(product, msg)
        self.contact = contact

def can_user_buy(product, contact=None):
    return False # If I make this 'True' then obviously it works fine.

def veto_if_already_purchased(sender, cartitem=None, added_quantity=0, 
**kwargs):
    customer = kwargs['cart'].customer
    if can_user_buy(cartitem.product, customer):
        return True
    else:
        msg = _("You have already purchased this.")
        raise ContactCannotOrder(customer, cartitem.product, msg)

In localsite/models.py, I have added the following line:

signals.satchmo_cart_add_verify.connect(veto_if_already_purchased, 
sender=None)

Many thanks,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/satchmo-users/-/5qQD_iXIvr4J.
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.

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/add/
Django Version: 1.2.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.sites',
 'satchmo_store.shop',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.comments',
 'django.contrib.sessions',
 'django.contrib.sitemaps',
 'registration',
 'sorl.thumbnail',
 'keyedcache',
 'livesettings',
 'l10n',
 'satchmo_utils.thumbnail',
 'satchmo_store.contact',
 'tax',
 'tax.modules.no',
 'tax.modules.area',
 'tax.modules.percent',
 'shipping',
 'product',
 'product.modules.configurable',
 'product.modules.custom',
 'payment',
 'store.vcs',
 'payment.modules.cod',
 'satchmo_ext.satchmo_toolbar',
 'satchmo_utils',
 'app_plugins',
 'store.localsite',
 'captcha']
Installed Middleware:
('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')


Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, 
**callback_kwargs)
File 
"/home/tandrews/racetraq/website/src/satchmo/satchmo/apps/satchmo_store/shop/views/smart.py"
 in smart_add
  19.     return method['view'](request)
File 
"/home/tandrews/racetraq/website/src/satchmo/satchmo/apps/satchmo_store/shop/views/cart.py"
 in add
  192.         return _product_error(request, product, cap.message)
File 
"/home/tandrews/racetraq/website/src/satchmo/satchmo/apps/satchmo_store/shop/views/cart.py"
 in _product_error
  403.         messages.error(request, msg)
File "/usr/lib/pymodules/python2.6/django/contrib/messages/api.py" in error
  114.                 fail_silently=fail_silently)
File "/usr/lib/pymodules/python2.6/django/contrib/messages/api.py" in 
add_message
  24.         return request.user.message_set.create(message=message)
File "/usr/lib/pymodules/python2.6/django/db/models/fields/related.py" in create
  423.                 return super(RelatedManager, 
self).using(db).create(**kwargs)
File "/usr/lib/pymodules/python2.6/django/db/models/query.py" in create
  352.         obj.save(force_insert=True, using=self.db)
File "/usr/lib/pymodules/python2.6/django/db/models/base.py" in save
  434.         self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
File "/usr/lib/pymodules/python2.6/django/db/models/base.py" in save_base
  527.                     result = manager._insert(values, 
return_id=update_pk, using=using)
File "/usr/lib/pymodules/python2.6/django/db/models/manager.py" in _insert
  195.         return insert_query(self.model, values, **kwargs)
File "/usr/lib/pymodules/python2.6/django/db/models/query.py" in insert_query
  1479.     return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py" in 
execute_sql
  783.         cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py" in 
execute_sql
  727.         cursor.execute(sql, params)
File "/usr/lib/pymodules/python2.6/django/db/backends/util.py" in execute
  15.             return self.cursor.execute(sql, params)
File "/usr/lib/pymodules/python2.6/django/db/backends/sqlite3/base.py" in 
execute
  200.             return Database.Cursor.execute(self, query, params)

Exception Type: InterfaceError at /add/
Exception Value: Error binding parameter 1 - probably unsupported type.

Reply via email to