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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests