[Zope-dev] ZPatterns example update....

Phillip J. Eby pje@telecommunity.com
Tue, 02 Jan 2001 11:44:12 -0500


At 03:08 PM 1/2/01 +1100, Itai Tavor wrote:
>Hi Steve,
>
>>Steve Spicklemire wrote:
>
>>  >>>>> "Itai" == Itai Tavor <itai@optusnet.com.au> writes:
>>
>>     Itai> Maybe with this
>>     Itai> SkinScript: WITH Doers.getItem(self.doerID) CALCULATE
>>     Itai> self.doerID=RESULT.id or '' ?  But I'm not really sure about
>>     Itai> this...
>>
>>Ahh.. I think my brain just imploded in a recursive death spiral,
>>but I get intent of the idea. This would work I think:
>>
>>WITH Doers.getItem(self.doerID) COMPUTE self.myDoer=RESULT or 
>>Doers.getItem('doNothing')
>>
>>where there is a default 'doer' named 'doNothing' in one of the Doers
>>Racks.  This guy would 'fill in' for the ToDo's doer when no 'real'
>>doer can be found... I like that. ;-)
>
>Yeah, this looks good... whether it's appropriate or not depends on 
>how you expect the case where there's no Doer to behave - if you 
>needed to know explicitly that a Doer doesn't exist, returning a 
>'nothing' doer could confuse things. BTW, I can't see the recursion 
>in my script... but maybe my brain is still in vacation mode :)

Your script uses an attribute (doerID) in the WITH clause that is provided
by the COMPUTE clause.  This is infinitely recursive in theory.  In
practice, it will result in the non-existence of the doerID attribute, as
ZPatterns treats recursive attribute references as non-existence of the
attribute.  The WITH clause will fail with an AttributeError.