[Zope-CMF] SkinTools optimisation
Shane Hathaway
shane@zope.com
Mon, 14 Apr 2003 15:20:38 -0400
Johan Carlsson [EasyPublisher] wrote:
>
> Hi,
> I'm not sure if this is an issue for zope-cmf or zope-dev,
> correct me if I'm wrong.
>
> I about to implement a SkinnableObjectManager and I as I understand it
> the SkinnableObjectManager setus up a self._v_skindata for each object
> supporting the SkinnableObjectManager when it is traversed?
>
> This have the implication that if the traverse path of the URL is very
> long,
> e.g. the object is deep in the hierarchy of the ZODB it will use more
> time to calculate each _v_skindata.
>
> I would suggest solving this by implementing a lazy _v_skindata that stores
> the path, object path and skin name (for instance) and can be use from
> the __getattr__ when ever an actually _v_skindata is needed.
>
> Am I missing something how it's implemented?
> Is this a good or bad idea?
There is only one SkinnableObjectManager--it's the CMF site object.
Only folders that directly contain a "portal_skins" tool need to be
SkinnableObjectManagers. The _v_skindata attribute is set up as lazily
as possible already, since it's computed only once per request, and
every request needs it. You could optimize it in C.
FWIW, the proposal linked below mentions one way the skinning machinery
could be transformed. It would eliminate __getattr__(), _v_skindata,
and all the other skin magic. This is more than what you asked for, and
I don't know whether the proposal will be accepted, but I wanted to give
you a better answer than just "write C code instead." :-)
http://dev.zope.org/Zope3/NamespacesInTemplates
If this were implemented in Zope 2.x, CMF could take advantage of it to
implement skins a better way.
Shane