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)

A better implementation would be an external module where you would pass in a user or session object and get back a cart object.

HTH
-Aaron

Thomas Dennehy wrote:

Is there a set of python classes that form the foundation of a “shopping cart” app?

I’m working on the prototype of an online catalog (just presentation, no order processing)
implemented in Webware. We’re at the point where we would like to let visitors select
products and later review their list, but I’m at a loss as to how to persist that information.

(Naivety on my part regarding web apps.)

 

Any leads would be appreciated.

 

 

Tom Dennehy

Bloomfield Hills MI USA

 


-- 
-Aaron
http://www.MetroNY.com/
"I don't know what's wrong with my television set. I was getting
 C-Span and the Home Shopping Network on the same station.
 I actually bought a congressman."
    - Bruce Baum

Reply via email to