[Zope-CMF] Re: Plone Speed

Tres Seaver tseaver@zope.com
15 May 2002 10:08:02 -0400


On Wed, 2002-05-15 at 04:44, Chris Withers wrote:
> alan runyan wrote:
> > 
> > I can understand if request.get('something') would traverse the entire
> > skinspath?
> 
> I presume you mean "can't" there?
> 
> Well, the bit which may (unless someone has sneakily optimised it ;-) involve traversing
> the entire skin path is actually getting the REQUEST object. In both DTML and ZPT, and
> PythonScripts, this will, as some stage involve acquiring the REQUEST via self.REQUEST or
> context.REQUEST, and that will have to look through all the skin layers before finding
> that REQUEST isn't there :-S

Here is how 'Products.PageTemplates.ZopePageTemplate' sets up the
context::

    def pt_getContext(self):
        root = self.getPhysicalRoot()
        c = {'template': self,
             'here': self._getContext(),
             'container': self._getContainer(),
             'nothing': None,
             'options': {},
             'root': root,
             'request': getattr(root, 'REQUEST', None),
             'modules': SecureModuleImporter,
             }
        return c

No acquisition involved in binding the name 'request' (which would
happen only once, anyway).  So, using:

   tal:define="foo request/FOO"

can't possibly take a hit from acquisition (and therefore, from skins).

OTOH, PythonScripts idiomatically get the request via::

   request = context.REQUEST

which *will* take the hit (but only once per call, if stored as a local
as here).

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com