diff --git a/product/ERP5Type/patches/XMLExportImport.py b/product/ERP5Type/patches/XMLExportImport.py index 0200daf6f06ce5806cd9962423a7d90e64ab1369..82c5bd9344ab0500ac547cc437a89fd798a1e595 100644 --- a/product/ERP5Type/patches/XMLExportImport.py +++ b/product/ERP5Type/patches/XMLExportImport.py @@ -88,14 +88,11 @@ from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate PICKLE_CLEANERS = {} -class cleaner_for(object): - - def __init__(self, classdef): - self.classdef = classdef - - def __call__(self, callable): - PICKLE_CLEANERS[self.classdef] = callable - return callable +def cleaner_for(classdef): + def wrapper(func): + PICKLE_CLEANERS[classdef] = func + return func + return wrapper # BBB: Remove this cleaner when we drop support for Zope 2.8 @cleaner_for(ZopePageTemplate) diff --git a/product/ERP5Type/tests/utils.py b/product/ERP5Type/tests/utils.py index 979a391cb3e47ba9777736ba616b82af28b104ed..1e88df213f1a36d7c6b5215fa41068e6446d6ad3 100644 --- a/product/ERP5Type/tests/utils.py +++ b/product/ERP5Type/tests/utils.py @@ -41,6 +41,7 @@ from Products.MailHost.MailHost import MailHost from email import message_from_string import backportUnittest from Products.ERP5Type.Globals import PersistentMapping +from Products.ERP5Type.Utils import simple_decorator from Products.ZSQLCatalog.SQLCatalog import Catalog class FileUpload(file): @@ -316,23 +317,18 @@ def createZServer(log=os.devnull): hs.close() # decorators -class reindex(object): +@simple_decorator +def reindex(func): """Decorator to commit transaction and flush activities after the method is called. """ - def __init__(self, func): - self._func = func - - def __get__(self, instance, cls=None): - self._instance = instance - return self - - def __call__(self, *args, **kw): - ret = self._func(self._instance, *args, **kw) + def wrapper(self, *args, **kw): + ret = func(self, *args, **kw) if kw.get('reindex', 1): transaction.commit() - self._instance.tic() + self.tic() return ret + return wrapper # Use this as a method or class decorator to tag it as TODO. # The test will be skipped: