property & ram.cache & dexterity

classic Classic list List threaded Threaded
4 messages Options
Régis Rouet Régis Rouet
Reply | Threaded
Open this post in threaded view
|

property & ram.cache & dexterity

Hi,

I have a content type with it's own base class _ which inherits from another base class _ where I tried to have a cached function accessible as a property.

    @property
    @ram.cache(lambda method, inst: (inst.getPhysicalPath(), inst.ModificationDate()))
    def myfunc(self):
        logger.debug('(p) %s - %s', self.ModificationDate(), self.getPhysicalPath())
        ...

This code result in getPhysicalPath() only returning the id.
Without "@property", the full path is returned.

I'm still on Plone 4.1, so, old code, but maybe someone is interested to verify what happens with current version.
David Glick (Plone) David Glick (Plone)
Reply | Threaded
Open this post in threaded view
|

Re: property & ram.cache & dexterity

On 2/4/13 8:00 AM, Régis Rouet wrote:

> Hi,
>
> I have a content type with it's own base class _ which inherits from another
> base class _ where I tried to have a cached function accessible as a
> property.
>
>
>
> This code result in getPhysicalPath() only returning the id.
> Without "@property", the full path is returned.
>
> I'm still on Plone 4.1, so, old code, but maybe someone is interested to
> verify what happens with current version.
>
>
Python properties and Zope Acquisition are not compatible. Using a
property strips the acquisition chain from the object.
David

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Régis Rouet Régis Rouet
Reply | Threaded
Open this post in threaded view
|

Re: property & ram.cache & dexterity

Thanks for clarification, David.
Dieter Maurer Dieter Maurer
Reply | Threaded
Open this post in threaded view
|

Re: property & ram.cache & dexterity

In reply to this post by Régis Rouet
Régis Rouet <[hidden email]> writes:

> ...
> This code result in getPhysicalPath() only returning the id.
> Without "@property", the full path is returned.

David has explained the reason for your observation.

You could use Zope's "ComputedAttribute" (instead of a Python's "property"),
should you need adquisition. "ComputedAttribute" has an option
to support/disregard acquisition.


------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users