thank you so much for your detail explaination about the differnce logic,
anthony.
according to your explaination about return so that i've modified into :
*#controllers/default.py*
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='subtract':
session.order[id]=max(0,session.order.get(id, 0)-1)
* if request.vars.action=='remove':*
* del session.order[id]*
* return locals()*
return str(session.order[id])
is the logic above is correct? i mean there is two return types in 1
definition, is it allowed? i've already tested it, it can work same like
using redirect, if it not correct or not allowed, should i create into the
different definition like :
*#controllers/default.py*
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='subtract':
session.order[id]=max(0,session.order.get(id, 0)-1)
* if request.vars.action=='remove':*
* del session.order[id]*
* redirect(URL('product'))*
return str(session.order[id])
def order_remove():
id=int(request.vars.id)
del session.order[id]
return locals()
*#**views/default/order.html*
<table width="100%">
{{for id, qty in order.items():}}
{{p=db.product(id)}}
<tr>
<td>{{=p.product_name}}</td>
<td>Rp. {{=p.unit_price}}</td>
<td><span id="{{='item%s'%p.id}}">{{=qty}}</span>
{{=SPAN(A('+', callback=URL('order_callback', vars=dict(id=p.id,
action='add')), target='item%s'%p.id, _title='Add Product', _class='btn
btn-navbar'))}} {{=SPAN(A('-', callback=URL('order_callback', vars=dict(id=
p.id, action='subtract')), target='item%s'%p.id, _title='Substract
Product', _class='btn btn-navbar'))}} *{{=SPAN(A('X',
callback=URL('order_remove', vars=dict(id=p.id)), delete='tr',
_title='Remove Product', _class='btn btn-navbar'))}}*</td>
</tr>
{{pass}}
</table>
both are work, i've already test it.
thank you
--
---
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.