[Zope-dev] two hard questions

Tim McLaughlin tim@iterationzero.com
Wed, 06 Mar 2002 09:57:55 -0500


Casey Duncan wrote:

>On Wednesday 06 March 2002 07:27 am, Tim McLaughlin allegedly wrote:
>
>>Firstly, I'm trying to return a lazy list to a dtml-in, but it seems
>>that the __getitems__ are all called up front....  This is the class and
>>the print statement shows up in debugging before any debugging output
>>from within the dtml-in:
>>
>[snip code]
>
>>Does this mean that dmtl-in touches all of the objects first for some
>>reason?  Or am I missing something?
>>
>
>My guess is that you have a sort attribute on your dtml-in, which would touch 
>everything in the sequence up front.
>
Your are right on with that (doh!)....

>
>>Second hard ?.....  Is there any way to wrap a Folder subclassed
>>instance within another class so that I can override some methods on an
>>instance by instance basis?  I tried doing a .__class__ replacement, but
>>for whatever reason, Zope machinery seems to keep it from taking effect.
>> Any ideas?  I've tried about 5 different approaches to no avail :(
>>
>
>I'm not sure how (or why) you would wrap a class around an instance. In order 
>to override methods on an instance by instance basis, you would most probably 
>need to create a object proxy wrapper that override __getattr__ so that it 
>can fire off the right methods.
>
>If these methods are accessed TTW, then you could just use __bobo_traverse__ 
>for this too.
>
Very long and involved explanation, so I'll skip it :)....  but since 
you agree with one of the many approaches I took (using a proxy), I'll 
revisit that one and see if morning will make it better.

Thanks for the help,
Tim

-- 
Tim McLaughlin
Iteration ZERO, Inc. - www.iterationzero.com
703.481.3983