Commit 5e2b3bbd authored by Yusei Tahara's avatar Yusei Tahara

Reduce rare AttributeError on Skins Tool.

Thanks to Vincent Pelletier for his help on this bug fix.
parent e274b020
Pipeline #28021 failed with stage
in 0 seconds
...@@ -20,6 +20,7 @@ from _thread import get_ident ...@@ -20,6 +20,7 @@ from _thread import get_ident
from zLOG import LOG, WARNING, DEBUG from zLOG import LOG, WARNING, DEBUG
from Acquisition import aq_base from Acquisition import aq_base
import six import six
import random
""" """
This patch modifies the way CMF Portal Skins gets a skin by its name from This patch modifies the way CMF Portal Skins gets a skin by its name from
...@@ -148,7 +149,12 @@ def CMFCoreSkinnableSkinnableObjectManager_changeSkin(self, skinname, REQUEST=No ...@@ -148,7 +149,12 @@ def CMFCoreSkinnableSkinnableObjectManager_changeSkin(self, skinname, REQUEST=No
skinname = sf.getDefaultSkin() skinname = sf.getDefaultSkin()
tid = get_ident() tid = get_ident()
SKINDATA[tid] = ( SKINDATA[tid] = (
None, # CMFCore uses the first item of this tuple, but ERP5 did not.
# Thus we put a random value here to reduce rare AttributeError
# caused by wrong SKINDATA deletion. See SkinDataCleanup.hashSkinData.
# However, it is not enough. To eliminate rare AttributeError bug,
# we have to stop using global SKINDATA dict completely.
random.getrandbits(24),
skinname, skinname,
{'portal_skins': None, 'portal_callables': None}, {'portal_skins': None, 'portal_callables': None},
{}) {})
...@@ -207,5 +213,7 @@ class SkinDataCleanup: ...@@ -207,5 +213,7 @@ class SkinDataCleanup:
pass pass
def hashSkinData(self, skindata): def hashSkinData(self, skindata):
return id(skindata) # id() might return the same value even though object is different.
# thus use a random value additionally.
return (id(skindata), skindata[0])
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