in models/0.py that code work:
if request.cookies.has_key('gift_code'):
## если онн уже дежжит в кукиях то берем его а не новый из запроса
MY_GIFT_CODE = request.cookies['gift_code'].value
#print 'in cookies gift_code:', MY_GIFT_CODE
else:
# если в кукиях нет кода то возможно он есть в запросе
MY_GIFT_CODE = request.vars.gc # из запроса возьмем пригласительный код
если он не задан в кукиех
if MY_GIFT_CODE:
##print 'in request gift_code:', MY_GIFT_CODE
from gifts_lib import store_in_cookies
store_in_cookies(MY_GIFT_CODE)
# а теперь когда запомнили куки переадресуемся чтобы сбросить код в
строке запроса
request.vars.pop('gc')
redirect(URL(args=request.args, vars=request.vars))
in ajax controller:
if MY_GIFT_CODE:
... - work
If I use instead MY_GIFT_CODE that names: GIFT_CODE or _GIFT_CODE - it
raise error - UnboundLocalError: local variable 'GIFT_CODE' referenced
before assignment <http://127.0.0.1:8000/admin/errors/ipay3#>
why?
--
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/d/optout.