[Zope-CMF] Re: [CMF 2.1] FSPageTemplate & Unicode

Rocky Burt rocky at serverzen.com
Sat Jan 6 12:39:44 EST 2007


On Sat, 2007-06-01 at 16:32 +0100, Hanno Schlichting wrote:
> Hhm, I'm not sure what the best way is here. Personally I would like to
> get rid of as much of Acquisition as possible, but obviously we need to
> be careful here.

+10 here


> Thinking about it a bit more, I would say, that if you need to aq_wrap a
> tool in order for it to function as expected, you shouldn't really
> register it as a utility in the first place.

Maybe, maybe not.  I would go as far as to say that 75% of the time when
a tool needs an acquisition context, all it really needs it for is to
get to the portal object.  From there it can usually do whatever it
wants.  Why not clean up the tools a bit so that instead of trying to do
something acquired, it looks up the portal and goes from there instead?
Or maybe that's biting off a bit too much?

I recently had the problem where in certain circumstances if you're
inside the mutator or accessor of a python property, then aq is not
maintained which prevented me from doing tool lookups that I needed to
do (Plone 2.5 / CMF 1.6).  What I ended up doing was calling
getToolByName(zope.app.component.hooks.getSite(), 'sometool').  Of
course if we make getUtility(ISiteRoot) work, we could use that instead
of the zope.app.component.hooks.getSite() rule.  Although, I'd love to
see utility lookups from one utility to another just use ISite and note
ISiteRoot as it would make overriding tools in "sub-portals" much
easier.


> In the end a utility is defined as something that does not need a
> context to do it's work. 

Hm... I'm not convinced of this, for me using "local" utilities versus
global utilities is about being able to get to the portal somehow.
Perhaps I'm mis-using local utilities?


> Registering tools as utilities that either need
> an Acquisition context or even worse the request (think of the evil
> self.REQUEST you see sometimes) violates that very definition of what
> utilities are.

Indeed, using request inside a utility/tool is evil.  But


> But maybe I'm just in a bit too cautious mood right now ;)

It does seem that way.... ;)


Regards,
Rocky

-- 
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope-cmf/attachments/20070106/168fec8c/attachment.bin


More information about the Zope-CMF mailing list