Ticket #13241 (confirmed Bug)

Opened 3 years ago

Last modified 3 years ago

cache error with Diazo when object is a kssview

Reported by: redcor Owned by: ldr
Priority: minor Milestone: 4.x
Component: Diazo (plone.app.theming) Version: 4.2
Keywords: kssview Cc:

Description

Whenn a site is that uses PloneKSSViews is style with Diazo then Diazos transform chain bombs with an attribute error as outlined in the attached email below.

A fix is as follows:

plone.app.theming-1.0.3-py2.7.egg/plone/app/theming/transform.py
----------------------------------------------------------------
def getCache(settings):
    # We need a persistent object to hang a _v_ attribute off for caching.

    registry = settings.__registry__
    caches = getattr(registry, '_v_plone_app_theming_caches', None)
    if caches is None:
        caches = registry._v_plone_app_theming_caches = {}

    try: #robert: added try block to avoi problem with PloneKSSView objects
        key = getSite().absolute_url()
    except AttributeError:
        key = getSite().__parent__.context.aq_inner.absolute_url()

    cache = caches.get(key)
    if cache is None:
        cache = caches[key] = _Cache()
    return cache

It's the fscking Kss component site manager in a view thing.

Your fix is broadly right, but should walk up __parent__ of the return value from getSite() I think. Site managers are chained.

Martin

On 4 Oct 2012, at 08:19, robert rottermann <robert@redcor.ch> wrote:

> Hi there,
>
> When I use one of our products that has been in use for  many years in a site 
> that is styled with Diazo I get the following traceback in the console.
> However everything seems to work fine.
>
> the companyListingAddressFilter of which  absolute_url () can not be access is a 
> PloneKSSView.
> Which has indeed no such attribute.
>
> When I change the offending method t use the instances context the traceback is 
> not shown any more.
> But I have NO idea, whether such a patch is allowed at all.
>
>
> If  this is likely to be a Diazo problem, then I open a ticket
>
> robert
>
> def getCache(settings):
>     # We need a persistent object to hang a _v_ attribute off for caching.
>
>     registry = settings.__registry__
>     caches = getattr(registry, '_v_plone_app_theming_caches', None)
>     if caches is None:
>         caches = registry._v_plone_app_theming_caches = {}
>
>     try: # <---------------- added this try block
>         key = getSite().absolute_url()
>     except AttributeError:
>         key = getSite().context.aq_inner.absolute_url()
>
>     cache = caches.get(key)
>     if cache is None:
>         cache = caches[key] = _Cache()
>     return cache
>
>
> 2012-10-04 08:08:33 ERROR plone.transformchain Unexpected error whilst trying to 
> apply transform chain
> Traceback (most recent call last):
>   File 
> "/home/zope/energieclusterR55/eggs/plone.transformchain-1.0.2-py2.7.egg/plone/transformchain/transformer.py", 
> line 48, in __call__
>     newResult = handler.transformIterable(result, encoding)
>   File 
> "/home/zope/energieclusterR55/eggs/plone.app.theming-1.0.3-py2.7.egg/plone/app/theming/transform.py", 
> line 208, in transformIterable
>     transform = self.setupTransform()
>   File 
> "/home/zope/energieclusterR55/eggs/plone.app.theming-1.0.3-py2.7.egg/plone/app/theming/transform.py", 
> line 102, in setupTransform
>     cache = getCache(settings)
>   File 
> "/home/zope/energieclusterR55/eggs/plone.app.theming-1.0.3-py2.7.egg/plone/app/theming/transform.py", 
> line 60, in getCache
>     key = getSite().absolute_url()
> AttributeError: 'companyListingAddressFilter' object has no attribute 'absolute_url'

Change History

comment:1 Changed 3 years ago by redcor

  • Owner set to ldr
  • Keywords Diazo, kssview added; Diazokssview removed
  • Component changed from Unknown to Diazo (plone.app.theming)

comment:2 Changed 3 years ago by kleist

  • Keywords Diazo, removed
  • Status changed from new to confirmed
Note: See TracTickets for help on using tickets.