I guess it would depend on how the items are catalogued. For my application, product groups are arranged by index, with multiple SKUs per index. Based on the same observation Frank makes, I implemented the cart object as a dictionary, rather than a list. Index numbers serve as keys, with a list of selected SKUs for the corresponding value per key.
Aaron's approach to where and how to persist the information was ideal for my needs. Thanks to all! Tom Dennehy Bloomfield Hills MI -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Barknecht Sent: Tuesday, August 26, 2003 7:01 PM To: [EMAIL PROTECTED] Subject: Re: [Webware-discuss] Shopping Cart App Hallo, Aaron Held hat gesagt: // Aaron Held wrote: > An easy way is to make the cart a list. > > def AddItem(item) > cart = self.session().value('cart',[]) > cart.append(item) > self.session.setValue('cart',cart) > > def DelItem(item) > cart = self.session().value('cart',[]) > try: > cart.remove(item) > except ValueError: > print "Item Removed" > self.session.setValue('cart',cart) This is fine except that I found a dictonary more appropriate for a shopping cart. The reason is, that a customer might want to buy more than one of an item. So I just keep a dictonary with item IDs as keys, and the item's count as value. So when it comes to the checkout, the customer can easily change how many of one item he wants. ciao -- Frank Barknecht _ ______footils.org__ ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
