I am just catching up on Ross's work last week, and I am not sure about
the changes in this changeset:
http://dev.plone.org/old/collective/changeset/88642/Products.membrane
I see the problem Ross is trying to solve: generating a list of
everything an object can be adapted to is expensive (which is why the
same thing was removed from the Plone 3.x tree just before 3.0).
This solution moves the penalty to the developer: instead of only having
to write an adapter developers are now forced to register both an
adapter and a new marker interface. I feel quite strongly that this
repetition is not desirable, so I want to investigate alternatives.
A trivial alternative is to add some simple caching to the
object_implements method. If we cache based on class and directly
provided interfaces we should get the exact same results while having
almost no noticeable performance problems. This might even allow us to
simplify the code and only use the slow-but-readable code path
Plone offers a fairly rich system of catalog indexing helper routines
which we can leverage. Instead of iterating over the ZCA registrations
to build a list of interface an object implements or can be adapted to
we can do simpler things. For example we could have a feature catalog
that looks like this:
@indexer(Interface, membrane_tool.IMembraneTool)
def features(obj):
_features = dict(user = IMembraneUserObject,
auth = IMembraneUserAuth,
props = IMebraneUserProperties)
result=[]
for (ft, iface) in _features.items():
a=iface(obj, None)
if a is not None:
result.append(ft)
return ft
This should be fast enough for indexing purposes since we can use all
the fast paths and optimisations from the ZCA, and gives us much simpler
catalog data: we will no longer need to index all the interfaces that
are not relevant for membrane. There is an obvious optimization here: if
an object does not adapt to IMembraneUserObject we can short-circuit and
stop processing immediately.
Wichert.
--
Archive:
http://www.coactivate.org/projects/remember/lists/remember/archive/2009/06/1246285918960
To unsubscribe send an email with subject "unsubscribe" to
[email protected]. Please contact [email protected] for
questions.