[Erp5-report] r40071 jm - in /erp5/trunk/products/ERP5Type: patches/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Nov 8 20:15:42 CET 2010
Author: jm
Date: Mon Nov 8 20:15:41 2010
New Revision: 40071
URL: http://svn.erp5.org?rev=40071&view=rev
Log:
Simplify code of some decorators
Modified:
erp5/trunk/products/ERP5Type/patches/XMLExportImport.py
erp5/trunk/products/ERP5Type/tests/utils.py
Modified: erp5/trunk/products/ERP5Type/patches/XMLExportImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/XMLExportImport.py?rev=40071&r1=40070&r2=40071&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/XMLExportImport.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/XMLExportImport.py [utf8] Mon Nov 8 20:15:41 2010
@@ -88,14 +88,11 @@ from Products.PageTemplates.ZopePageTemp
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)
Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=40071&r1=40070&r2=40071&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Mon Nov 8 20:15:41 2010
@@ -41,6 +41,7 @@ from Products.MailHost.MailHost import M
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):
+ at 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:
More information about the Erp5-report
mailing list