Commit 65ae7d9f authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.patches.OFSItem: Explicitly declare volatileCached public.

parent 253200f7
from AccessControl import ClassSecurityInfo
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
""" """
...@@ -14,6 +15,8 @@ NOTE: This patches OFS.Item.SimpleItem as it's the lowest patchable class ...@@ -14,6 +15,8 @@ NOTE: This patches OFS.Item.SimpleItem as it's the lowest patchable class
before persistence.Persistent, where this patch would actually belong. before persistence.Persistent, where this patch would actually belong.
""" """
security = ClassSecurityInfo()
security.declarePublic('volatileCached')
def volatileCached(self, func): def volatileCached(self, func):
""" """
Cache "func()" return value using a volatile on self. Cache "func()" return value using a volatile on self.
...@@ -40,7 +43,7 @@ def volatileCached(self, func): ...@@ -40,7 +43,7 @@ def volatileCached(self, func):
# volatile property anyway. # volatile property anyway.
self._v_SimpleItem_Item_vCache = cache_dict = {} self._v_SimpleItem_Item_vCache = cache_dict = {}
# Use whole func_code as a key, as it is the only reliable way to identify a # Use whole func_code as a key, as it is the only reliable way to identify a
# function reliably. # function.
key = func.func_code key = func.func_code
try: try:
return cache_dict[key] return cache_dict[key]
...@@ -49,4 +52,4 @@ def volatileCached(self, func): ...@@ -49,4 +52,4 @@ def volatileCached(self, func):
return value return value
SimpleItem.volatileCached = volatileCached SimpleItem.volatileCached = volatileCached
security.apply(SimpleItem)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment