non integer cart item's quantity bug workaround

0 views
Skip to first unread message

danielle davout

unread,
Jul 3, 2009, 10:42:13 AM7/3/09
to getpa...@googlegroups.com
When you enter a non integer value for the number of items in the cart
listing you have got an exception.
So I try to have my own class ShoppingCartListing :

class ShoppingCartListing(PGP_ShoppingCartListing):

# to change templates
# to use my cartformatter
# to hopefully patch handle_update
# quantity integer http://code.google.com/p/getpaid/issues/detail?id=255
template = ZopeTwoPageTemplateFile('templates/cart-listing.pt')
formatter_factory = CartFormatter

@form.action(_("Update"), condition="isNotEmpty")
def handle_update(self, action, data):
try:
data = self.quantity_column.input(self.container.values(),
self.request)
except: # put everything back
self.form_reset = True
for i in self.request.form.keys():
self.request.form.pop(i)
self.form_reset = True
self.quantity_column.update(self.container.values(), data)
for item_id in self.container:
if self.container[item_id].quantity == 0: # remove everything
del self.container[item_id]
It works ( although not for the negative numbers yet )
but
ONLY if I change in the class FieldEditColumn(Column), the method input
from
......
if widget.hasInput():
try:
data[id] = widget.getInputValue()
except WidgetInputError, v:
raise errors.append(v)
.....
to
......
if widget.hasInput():
try:
data[id] = widget.getInputValue()
except :#WidgetInputError, v:
raise #errors.append(v)
.......
Some advice needed....

Reply all
Reply to author
Forward
0 new messages