Maurits van Rees wrote:
One thought: if a context is already acquisition wrapped, you could
instead say `self.context.aq_inner`. That would save one import.
Maybe not really worth troubling myself over, but am I correct in
assuming that it is better to do that import anyway, like you write?
The function versions of the aq_ things are a bit faster (they're C
code), and I think it's more clear. You're doing an operation on the
context, not accessing an attribute of it.
It would at least avoid AttributeErrors when the context does not
inherit from Acquicition for some reason.
Indeed.
As an example, I see some code like this in my product, in the content
classes themselves:
current = portal.aq_inner
parent = self.aq_inner.aq_parent
Is it better to avoid that and import aq_* from Acquisition
and change the code into this?
current = aq_inner(portal)
parent = aq_parent(aq_inner(self))
It doesn't *really* matter, but I personally prefer the latter. The
former, like so many things in Zope 2, are there I guess mostly to
support TTW and traversal, e.g. you can do
context/aq_inner/some_acquired_thing in a path expression.
Martin
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers