[z3-five] Does Five support Local Utilities?
Philipp von Weitershausen
philipp at weitershausen.de
Tue Sep 19 11:15:33 CEST 2006
Chris Withers wrote:
> Philipp von Weitershausen wrote:
>> There is no "local to a single object".
Actually, I lied. The Component Architecture has the semantics of a
componetn that's specifically looked up for one or more objects: adapter.
>> The zope.component lookup functions will query the currently active
>> site manager, which is typically set during traversal. If that site
>> manager has the utility registered you want to lookup, it'll be
>> found. If not, lookup will cascade to site managers higher up the
>> hierarchy. It's acquisition, Zope 3 style.
>
> Oh, this sucks :-(
Whatever.
> I can't get the semantics I'm after unless I do nasty things:
>
> (pseudo-ish code)
>
> from copy import deepcopy
> from twiddler.interfaces import IInput
> from twiddler.zope2.interfaces import IConfigurableComponent
> from zope.component import getUtility
>
> def setInput(self,name):
> input = getUtility(IInput,name)
> if IConfigurableComponent.providedBy(input):
> input = deepcopy(input)
> self.input = input
>
> ...in order to be able to configure the input for that particular
> Twiddler instance, without that configuration affection the use of the
> input in all instances that use it.
>
> I don't know how evil the above it, would be interested on people's
> views...
I don't understand the pseudo code above. What's your goal?
More information about the z3-five
mailing list