Looks like there is no purchase_order with id=3 in the session. You'll have 
to do some debugging to figure out where it's going wrong.

On Thursday, January 30, 2014 7:43:48 PM UTC-5, 黄祥 wrote:
>
> thanks anthony, i've tried your hint, but it return a new traceback on 
> purchase_cart when i click add or subtract:
>
> Traceback (most recent call last):
>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in 
> restricted
>   File 
> "C:/Users/sugizo/Desktop/web2py/2.8.2/applications/citifone/controllers/transaction.py"
>  
> <http://127.0.0.1:8000/admin/default/edit/citifone/controllers/transaction.py>,
>  line 261, in <module>
>   File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 372, in 
> <lambda>
>   File 
> "C:/Users/sugizo/Desktop/web2py/2.8.2/applications/citifone/controllers/transaction.py"
>  
> <http://127.0.0.1:8000/admin/default/edit/citifone/controllers/transaction.py>,
>  line 131, in purchase_order_callback
>     quantity = session.purchase_order[id]['quantity']
> KeyError: 3
>
> *controllers/transaction.py*
> def purchase_order_callback():
>     id = int(request.vars.id)
>     quantity = session.purchase_order[id]['quantity']
>     price = session.purchase_order[id]['price']
>     if request.vars.action == 'add':
>         quantity = max(0, quantity + 1)
>         price = max(0, price + 2)
>         session.purchase_order[id] = dict(quantity = quantity, price = 
> price )
>         return str(session.purchase_order[id])
>     if request.vars.action == 'subtract':
>         quantity = max(0, quantity - 1)
>         price = max(0, price - 2)
>         session.purchase_order[id] = dict(quantity = quantity, price = 
> price )
>         return str(session.purchase_order[id])
>     if request.vars.action == 'adjust_total_price':
>         quantity = int(request.vars['quantity_%s' % id])
>         price = int(request.vars['price_%s' % id])
>         session.purchase_order[id] = dict(quantity = quantity, price = 
> price)
>         total_price = quantity * price
>         grand_total = 0
>         for calculation_id, calculation_quantity, calculation_price in 
> session_purchase_order.items():
>             product = db.product(calculation_id)
>             calculation_total_price = calculation_quantity * 
> calculation_price
>             grand_total += calculation_total_price
>         print session
>         return 
> "jQuery('#total_price_%s').html(%s);jQuery('#grand_total').html(%s);" % 
> (str(id), str(total_price), str(grand_total) )
>
> *views/transcation/purchase_cart.html*
> {{=SPAN(session.purchase_order.get(row.id, 0), _id="item_%s" % row.id) }}
> {{=T('In Order') }}
>
> another thing, when i tried to adopt your hint in the 
> views/transaction/purchase_cart.html, an error occured. :
> *views/transcation/purchase_cart.html*
> {{=SPAN(session.purchase_order[row.id]['quantity'], _id="item_%s" % row.id) 
> }}
> {{=T('In Order') }}
>
> Traceback (most recent call last):
>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in 
> restricted
>   File 
> "C:\Users\sugizo\Desktop\web2py\2.8.2\applications\citifone\views\transaction/purchase_cart.html",
>  line 175, in <module>
> KeyError: 3L
>
>
> any idea how to fix it?
>
> thanks so much and best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to