[Zope] <dtml-with "portal_url.getPortalObject()"> gives AttributeError

Marc Lindahl marc at bowery.com
Thu Nov 13 04:17:21 EST 2003


On Wednesday, November 12, 2003, at 04:05  PM, Dieter Maurer wrote:

> Marc Lindahl wrote at 2003-11-12 11:54 -0500:
>>
>> On Tuesday, November 11, 2003, at 02:26  PM, Dieter Maurer wrote:
>>
>>> Marc Lindahl wrote at 2003-11-11 11:31 -0500:
>>>> Good point... how the heck to I get around it??
>>>
>>> First of all, you must find the place where
>>> "portal_url" is defined in the wrong way.
>>> Only then, can we find out how to work around that.
>>>
>>
>> Wrong way, or accessed such that it returns a string?  The latter I
>> have run into before, the string gets cached somehow.... very hard to
>> track down but there was a workaround that I forgot, getattr or
>> something.  Thought you'd remember.  I don't think portal_url is
>> actually redefined...
>
> You are right.
>
> Caching would be possible, too.
> I think, "dtml-var", "dtml-if" and "dtml-in" are caching.
>
> I fear, there is no way to access the uncached value through
> direct use of "_". "_.getitem(name)" would be the way
> to access "name" without rendering in the first place.
> But once, it is cached, you will get the cached value.
>
> You can try "_.getattr(this(),portal_url)".
> This way, you use explicite acquisition from the "current object"
> ("this()") to access "portal_url".
>
That didn't work....  with <dtml-with 
expr="_.getattr(this(),portal_url)">
I get the error:  exceptions.AttributeError on http://www.mysite.com in 
"standard:'here/homepage_links'", at line 55, column 5

and the same exact error when trying <dtml-with 
expr="_.getattr(this(),portal_url).getPortalObject()">

This is a good reason to *never* use dtml again!    Maybe I'll just 
rewrite this method in ZPT...




More information about the Zope mailing list