[mod_python] Sessions (Aaaarggghhhh!!)

Luis M. Gonzalez luismg at gmx.net
Mon Jan 16 20:15:21 EST 2006


Hi Folks!

I'm needing some help with this problem...
I just started playing with mod_python yesterday, and after pulling my hair with installation problems and configurations,
I managed to get it working and I also could write some basic little apps.

Right now, I'm almost finished with a simple shopping cart, wich is an instance of class "cart" and contains, obviously, items with their prices and quantities.
It performs the usual actions, such add item, update quantity, etc.
The problem is that when I perform any of these actions, the cart is created again, and the previous information gets lost.
It seems that there's a problem with my session handling, but I can't figure out what's wrong...

This is how I create the session for my shopping cart:

s = Session.Session(req)

s = Session.Session(req)
if not hasattr(s,'x'):
    s['x']= cart()
    s.save() 

 and this is the code that handles the operations:

if form['action']=='upqty':
    try:
        if int(form['qty'])==0:
            del s['x'].items[form['item']]
            s.save()
        else:
            s['x'].upqty(form['item'],int(form['qty']))
            s.save()
        s['x'].pp()
        
    except:
        print 'Bad entry. Try again...with numbers'
elif form['action']=='ad':
    try:
        if form['item']=='':
     print 'no item to add'
        else:
     s['x'].ad(form['item'],float(form['price']),int(form['qty']))
            s.save()
         s['x'].pp()
            
    except:
 print 'Bad entry. Try again...with numbers'
s.save()   


Note that I use exclusively the PSP programming style, and this is my Apache conf:

<Directory "C:\Archivos de programa\Apache Group\Apache2\htdocs">
    AddHandler mod_python .psp
    PythonHandler mod_python.psp
    PythonDebug On
</Directory>


Please! I would highly appreciate any hint from you guys!
Thanks in advance and regards,

Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060116/d9d46af0/attachment.html


More information about the Mod_python mailing list