[Zope] AUTHENTICATED_USER and external methods

Tony McDonald tony.mcdonald@ncl.ac.uk
Mon, 13 Sep 1999 09:50:12 +0100


Heiko,
I was thinking that I should do

  html = template(self, REQUEST) but that didn't work.

Your code seems to do the trick - many thanks!
Tone

At 10:12 am +0200 13/9/99, Heiko Stoermer wrote:
>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

------
Dr Tony McDonald,  FMCC, Networked Learning Environments Project 
http://nle.ncl.ac.uk/
The Medical School, Newcastle University Tel: +44 191 222 5888
Fingerprint: 3450 876D FA41 B926 D3DD  F8C3 F2D0 C3B9 8B38 18A2