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: class LazyList: def __init__(self, root, selections): self._root = root self._selections = selections def __getitem__(self, index): s = self._selections[index] print s.getPath() ##### this is executed for all items before anythingwithin the dtml-in o = self._root.restrictedTraverse(s.getPath()) o.setSelection(s) return o def __len__(self): return len(self._selections) Does this mean that dmtl-in touches all of the objects first for some reason? Or am I missing something? 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 :( Sincerely, Tim McLaughlin -- Tim McLaughlin Iteration ZERO, Inc. - www.iterationzero.com 703.481.3983
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.
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. Maybe restate the problem in a different way. /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
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
participants (2)
-
Casey Duncan -
Tim McLaughlin