this week we've been busy trying to solve a nasty performance issue on one of our sites; we already have the code located the solution has not been trivial:
we have a tile that display a link to the latest article of a list of authors; to get that piece of content I have to do a catalog search for each of the items in the list and this is killing the site.
our first idea was to implement results caching by using memoize, but every single way we have tested, we were getting a weird TypeError: 'NotImplementedType' object is not callable
.
yesterday I dig into this issue and submitted a patch to avoid hiding exception raised inside the index()
method:
and then I was able to see the real error that looks like this:
2017-03-17 00:31:49 ERROR Zope.SiteErrorLog 1489725109.470.443901532445 https://example.com/frontpage/@@authors/a651cd52-013d-4ecc-bf65-ad93ed0e2085
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.tiles.esi, line 74, in __call__
Module Products.Five.browser.pagetemplatefile, line 125, in __call__
Module Products.Five.browser.pagetemplatefile, line 59, in __call__
Module zope.pagetemplate.pagetemplate, line 132, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 149, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 171, in render
Module e2e8a8cb0ccaf124ca997cd3d42a8e5e, line 496, in render
Module five.pt.expressions, line 161, in __call__
Module Products.CMFDynamicViewFTI.browserdefault, line 70, in __call__
Module plone.autoform.view, line 47, in __call__
Module plone.directives.dexterity.form, line 181, in render
Module five.grok.components, line 130, in render
Module zope.pagetemplate.pagetemplate, line 132, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 149, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 46e71108af01ed762ca53797950e78d8, line 765, in render
Module f3ec90ed7a03091afd2017dd1f335f47, line 925, in render_master
Module AccessControl.ImplPython, line 675, in guarded_getattr
Module ZPublisher.HTTPRequest, line 1391, in __getattr__
AttributeError: RESPONSE
- Expression: "article"
- Filename: ... skins/example/portal/tiles/templates/authors.pt
- Location: (line 44: col 23)
- Source: condition="article">
^^^^^^^
- Expression: "python:request.RESPONSE.setHeader('X-UA-Compatible', 'IE=edge,chrome=1')"
- Filename: ... theme/sunburst/skins/sunburst_templates/main_template.pt
- Location: (line 16: col 3)
- Source: dummy python:request.RESPONSE.setHeader('X-UA-Compatible', 'IE=edge,chro ...
^
- Arguments: repeat: {...} (0)
template: <ViewPageTemplateFile - at 0x7fe81a29ec90>
views: <ViewMapper - at 0x7fe8085517d0>
modules: <instance - at 0x7fe82aaefb00>
args: <tuple - at 0x7fe831d73050>
here: <ImplicitAcquisitionWrapper trump-na-contramao-do-mundo at 0x7fe80854ff00>
static: <NoneType - at 0x8fe4d0>
user: <ImplicitAcquisitionWrapper - at 0x7fe808573910>
nothing: <NoneType - at 0x8fe4d0>
translate: <function translate at 0x7fe80a77d410>
container: <ImplicitAcquisitionWrapper trump-na-contramao-do-mundo at 0x7fe80854ff00>
request: <instance - at 0x7fe80b236f38>
wrapped_repeat: <SafeMapping - at 0x7fe80a7a5e10>
traverse_subpath: <list - at 0x7fe813647128>
default: <object - at 0x7fe831c8e520>
context: <ImplicitAcquisitionWrapper trump-na-contramao-do-mundo at 0x7fe80854ff00>
view: <Alternate_View alternate_view at 0x7fe8085d1dd0>
target_language: pt_BR
root: <ImplicitAcquisitionWrapper Zope at 0x7fe80b166fa0>
options: {...} (0)
loop: {...} (0)
I've being trying to add the memoizing in different ways: on a tile method, on a external utility function, and on a external helper view function (using memoize.view
and ram.cache
decorators) and all of them give the same problem.
any hint?