2011/4/29 Ken <[email protected]>:
> # settngs.py
> def cookie():
>     return web.cookies()
> web.template.Template.globals['cookie_office'] = cookie()
>
> # people.py
> class Login:
>     def GET(self):
>         cookie = web.cookies()
>         return render.people.login('Login', cookie)
>
> # login.html
> $def with(title, cookie)
> $:render_office.header(title)
>     $if cookie == cookie_office:
>         OK
>     $else:
>         It is wrong<br />
>         cookie: $cookie.userid, $cookie.email<br />
>         cookie_office: $cookie_office.userid, $cookie_office.email
>
> OK, when I logined, and it return:
> It is wrong
> cookie: 2, [email protected]
> cookie_office: None, None
>
> what happend? How to fix?

cookie_office is cookies taken at the time of initialization of you
code. Which is empty. If you want to access cookies you might want to
make cookie_office a function. However, I don't recommend exposing
functions like cookies to templates. Ideally your GET/POST method
should process them pass them to the template.

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to