diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 4604d2b6fd871385b0730c83e52df830cc36de19..1b3e9a6c215be56a28c066359bb5856b0ec93a18 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -54,6 +54,7 @@ from Products.ERP5Type.XMLExportImport import Base_asXML from Products.ERP5Type.Cache import CachingMethod, clearCache, getReadOnlyTransactionCache from Products.CMFCore.WorkflowCore import ObjectDeleted from Accessor import WorkflowState +from Products.ERP5Type.Log import log as unrestrictedLog from ZopePatch import ERP5PropertyManager @@ -2208,16 +2209,6 @@ class Base( CopyContainer, # LOG('Base.setBinaryData',0,'data for : %s' % str(self)) # self.data = data - security.declarePublic('commitTransaction') - def commitTransaction(self): - # Commit a zope transaction (to reduce locks) - get_transaction().commit() - - security.declareProtected(Permissions.ModifyPortalContent, 'abortTransaction') - def abortTransaction(self): - # Abort a zope transaction (to reduce locks) - get_transaction().abort() - # Hash method def __hash__(self): return hash(self.getUid()) @@ -2393,19 +2384,10 @@ class Base( CopyContainer, security.declarePublic('log') def log(self, description, content='', level=INFO): """Put a log message """ - if content=='': # allow for content only while keeping interface - description,content=content,description - st=traceback.extract_stack() - head=[] - for frame in st[-2:-6:-1]: # assume no deep nesting in Script (Python) - if frame[3] is not None and frame[3].startswith('self.log'): # called from class - head.append('%s, %d' % (frame[2],frame[1])) - break - if frame[0]=='Script (Python)': # does anybody log from ZPT or dtml? - head.append('%s, %d' % (frame[2],frame[1])) - head=' -> '.join(head) - description='%s: %s' % (head,description) - LOG(description, level, content) + warnings.warn("The usage of Base.log is deprecated.\n" + "Please use Products.ERP5Type.Log.log instead.", + DeprecationWarning) + unrestrictedLog(description, content = content, level = leve) # Dublin Core Emulation for CMF interoperatibility # CMF Dublin Core Compatibility diff --git a/product/ERP5Type/Log.py b/product/ERP5Type/Log.py new file mode 100644 index 0000000000000000000000000000000000000000..97f1859818a2520ac473f78ebbbe723cbb6ca0fb --- /dev/null +++ b/product/ERP5Type/Log.py @@ -0,0 +1,49 @@ +############################################################################## +# +# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved. +# Yoshinori Okuji <yo@nexedi.com> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from zLOG import LOG, INFO +from traceback import extract_stack + +def log(self, description, content = '', level = INFO): + """Put a log message. This method is supposed to be used by + restricted environment, such as Script (Python).""" + if not content: # allow for content only while keeping interface + description, content = content, description + st = extract_stack() + head = [] + for frame in st[-2:-6:-1]: # assume no deep nesting in Script (Python) + if frame[3] is not None and frame[3].startswith('self.log'): # called from class + head.append('%s, %d' % (frame[2], frame[1])) + break + if frame[0] == 'Script (Python)': # does anybody log from ZPT or dtml? + head.append('%s, %d' % (frame[2], frame[1])) + del st # Prevent cycling references. + head = ' -> '.join(head) + description = '%s: %s' % (head, description) + LOG(description, level, content) + diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py index 8dcca7b86ce80d31fcf5bc3ed414a2c1e7ec046b..559633711a5ba837b262c01b644106b4aa84f146 100644 --- a/product/ERP5Type/__init__.py +++ b/product/ERP5Type/__init__.py @@ -96,7 +96,7 @@ def initialize( context ): from AccessControl.SecurityInfo import allow_module allow_module('Products.ERP5Type.Cache') -allow_module('Products.ERP5Type.Utils') +allow_module('Products.ERP5Type.Utils') # XXX this looks dangerous allow_module('Products.ERP5Type.Message') - +allow_module('Products.ERP5Type.Log')