[web2py] Re: delete session strange behaviour

2013-02-16 Thread 黄祥
hi anthony, here is the trace back : TRACEBACK 1. 2. 3. 4. 5. 6. Traceback (most recent call last): File "/host/Downloads/web2py/gluon/restricted.py", line 212, in restricted exec ccode in environment File "/host/Downloads/web2py/applications/retail/views/default/bill.html", line 83, in

[web2py] Re: delete session strange behaviour

2013-02-16 Thread Anthony
Difficult to help without knowing what the error is. Do you have a traceback? When you return a dict from a controller function, web2py looks for the associated view and then executes the view. If the view is expecting some variable to be in the returned dict but that variable happens not to be

[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
hi anthony, sorry, i'm not sure what do you mean 'the view is expecting a particular variable to be returned but that variable is not in locals()' here is the code that return an error: for k, v in session.order.items(): if v==0: del session.order[k] *redirec

[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
What error occurs if you return locals()? If the view is expecting a particular variable to be returned but that variable is not in locals(), that would cause an error -- is that the issue? Anthony On Friday, February 15, 2013 7:39:17 PM UTC-5, 黄祥 wrote: > > thank you so much for your explainat

[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
thank you so much for your explaination, antony, i thought it was an illegal operation in web2py work flow or programming logic. but some times it's wise to decide it whether use redirect or return locals(), or is there any other options to do this except using redirect or return locals()? here

[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
Yes, you can have multiple return statements in different logic branches of a function. Anthony On Friday, February 15, 2013 11:44:02 AM UTC-5, 黄祥 wrote: > > thank you so much for your detail explaination about the differnce logic, > anthony. > according to your explaination about return so tha

[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
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]=sess

[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
In the second and third cases, you delete session.order[id] but then try to return it, which will generate an error (so the response to the Ajax call will be a 500 error). This doesn't happen in the first case because the redirect happens before the return. Anthony On Thursday, February 14, 20