[Zope] AUTHENTICATED_USER and external methods

Heiko Stoermer heiko@mig.net
Mon, 13 Sep 1999 10:12:24 +0200


Tony McDonald wrote:

> Hi,
> I've got an external method that creates an HTML page from a large
> number of SQL queries. I call it like so;
> <a href="supercascade?tag_id=11>Overview of Module</a>.
>
> I want to have the benefits of standard_html_header and
> standard_html_footer in my documents too, so I've got this in the
> code...
>
>          template_str = self.standard_html_header.read_raw()
>          template = DocumentTemplate.HTML(template_str)
>          html = template(self)
>
> ... lots of wondrous stuff with databases that add to 'html'
>
>          template_str = self.standard_html_footer.read_raw()
>          template = DocumentTemplate.HTML(template_str)
>          return html + template(self)
>
> Now this works ok - standard_html_header can *get at* dtml variables
> in it, such as 'title' and 'id'. Problems arise if I want to get to
> AUTHENTICATED_USER, as adding this
> User:<dtml-var "AUTHENTICATED_USER.getUserName()">
>
> Results in the header *being rendered* with the correct user, but the
> page gives
> <!--
>   Error type:  NameError
>   Error value: AUTHENTICATED_USER
>   -->

I'm not definite about it, but I think I have a hint:
This might be the case because AUTHENTICATED_USER is a property of the
REQUEST object (according the the DTML-Guide).
So, in your DTML you should put REQUEST['AUTHENTICATED_USER'] instead of
just the name. This might then work within the external method, because
it looks up the name correctly.

Hope this helps,
Heiko


--
Heiko Stoermer
MIG Augsburg