Simon Hang wrote:
> How can I use zope session id(client_id) in .pt template? I'm not
> understanding zope's session id management very well.

What do you need the client id for? It's a detail that shouldn't bother
you when dealing with sessions, at least not in a ZPT.

> Sometime, I can get session id using code like this
> <span tal:content="python:request.cookies.items()[0][1]"/>

I would say that this code's behaviour is utterly unpredictable.
Mappings like request.cookies are not required to have an ordering.
Plus, who says that sessions have to use cookies?

> I know I can get session id using a function like below:
> ...
>     def SessionData(self):
>         return ISession(self.request).client_id
> ...
> but is it possible to do this ONLY using a .pt file?

You could do ISession(self.request).client_id in a python: TALES
expression. But I would recommend against it.

I don't think you need the client id in a ZPT. If you do, then perhaps
you should rethink your approach to sessions in your browser views.


Zope3-users mailing list

Reply via email to