[ZPT] Strange session behavior with macro-call
Jeff Peterson
jpeterso at crary.com
Tue Jun 27 09:12:45 EDT 2006
Chris Withers wrote:
> Jeff Peterson wrote:
>> I have a page template that calls a couple of scripts at the
>> beginning, they are setting session objects and redirecting to a
>> login screen if certain session objects don't exist.
>
> Why not just use PAS or Cookie Crumbler? ;-)
I guess I could look at that...I am having to authenticate against an
existing database of usernames and passwords so I just wrote it myself.
>
>> the content for this page. When the macro is rendered, the scripts
>> fail to operate properly (commented out they work perfectly).
>
> I'll bet your doing something like:
>
> <mytag tal:define="dummy here/myScript"
> metal:use-macro="something">
> ...
>
> The macro replaces the whole tag before the tal:define gets called.
Actually I am not doing anything of the sort.
The whole page is a macro to start. The scripts that are being called
are all in this format:
<metal:block metal:fill-slot="defines">
<!-- define any template specific variables here -->
<tal:x tal:define="baseurl context/root/baseurl"></tal:x>
<tal:x tal:define="global session request/SESSION"></tal:x>
<tal:x tal:condition="python:not session.has_key('user')">
<tal:x tal:define="bookmark
context/commonRoot/bookmarks/setBookmark"></tal:x>
</tal:x>
<tal:x tal:condition="python:session.has_key('user')">
<tal:x tal:define="global accountname
session/user/account_name;
global username
session/user/user_name;
global account_id
session/user/account_id;
global roles
session/user/role;
global uadm python:'uadm' in roles;
global dadm python:'dadm' in roles;
global padm python:'padm' in
roles"></tal:x>
</tal:x>
</metal:block>
then below, the macro is being pulled in inside a different fill-slot.
>
> Anyway, overarchingly, don't mix presentation and logic like this,
> 'cos it causes these kind of problems ;-)
>
> cheers,
>
> Chris
>
--
Jeffrey D Peterson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jpeterso.vcf
Type: text/x-vcard
Size: 294 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zpt/attachments/20060627/5886ae3c/jpeterso.vcf
More information about the ZPT
mailing list