[z3-five] use of aq_base
Florent Guillaume
fg at nuxeo.com
Sat Oct 29 20:53:52 CEST 2005
I'm not sure if it causes bugs or not, but I see this code several
times (for instance in site/utility.py):
utilities = getattr(aq_base(self.context), 'utilities', None)
For instance followed by:
if utilities is not None:
utility = utilities._getOb(id, None)
if utility is not None:
return utility
Because of the aq_base, the "utility" will have an acquisition chain
that's truncated to just its parent. It may or not be a problem, but
in the context of Zope 2 many objects will fail in these circumstances.
I advocate using:
if getattr(aq_base(self.context), 'utilities', None) is not
None:
utilities = self.context.utilities
....
Florent
--
Florent Guillaume, Nuxeo (Paris, France) Director of R&D
+33 1 40 33 71 59 http://nuxeo.com fg at nuxeo.com
More information about the z3-five
mailing list