Commit 71b12e30 authored by Jérome Perrin's avatar Jérome Perrin

Expose the original __init__ method of cache entry.

I know some tests where we test scripts that are caching some classes defined in the script itself. It works fine, but this patch reports them as an error.
This gives an opportunity to unapply this monkey patch in the rare case it's needed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43809 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4db27339
...@@ -1315,12 +1315,13 @@ def fortify(): ...@@ -1315,12 +1315,13 @@ def fortify():
''' '''
# check that we don't store persistent objects in cache # check that we don't store persistent objects in cache
from Products.ERP5Type.CachePlugins.BaseCache import CacheEntry from Products.ERP5Type.CachePlugins.BaseCache import CacheEntry
CacheEntry__init__ = CacheEntry.__init__ CacheEntry.__original_init__ = CacheEntry.__init__
def __init__(self, value, *args, **kw): def __init__(self, value, *args, **kw):
# this will raise TypeError if you try to cache a persistent object # this will raise TypeError if you try to cache a persistent object
dumps(value) dumps(value)
CacheEntry__init__(self, value, *args, **kw) return self.__original_init__(value, *args, **kw)
CacheEntry.__init__ = __init__ CacheEntry.__init__ = __init__
# randomize priorities of activities in a deterministic way # randomize priorities of activities in a deterministic way
seed = os.environ.get("random_activity_priority") seed = os.environ.get("random_activity_priority")
if seed is not None: if seed is not None:
......
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