Commit 83b3264d authored by Yoshinori Okuji's avatar Yoshinori Okuji

Deprecate Base.log. Use Products.ERP5Type.Log.log instead.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12947 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 049ac3d2
...@@ -54,6 +54,7 @@ from Products.ERP5Type.XMLExportImport import Base_asXML ...@@ -54,6 +54,7 @@ from Products.ERP5Type.XMLExportImport import Base_asXML
from Products.ERP5Type.Cache import CachingMethod, clearCache, getReadOnlyTransactionCache from Products.ERP5Type.Cache import CachingMethod, clearCache, getReadOnlyTransactionCache
from Products.CMFCore.WorkflowCore import ObjectDeleted from Products.CMFCore.WorkflowCore import ObjectDeleted
from Accessor import WorkflowState from Accessor import WorkflowState
from Products.ERP5Type.Log import log as unrestrictedLog
from ZopePatch import ERP5PropertyManager from ZopePatch import ERP5PropertyManager
...@@ -2208,16 +2209,6 @@ class Base( CopyContainer, ...@@ -2208,16 +2209,6 @@ class Base( CopyContainer,
# LOG('Base.setBinaryData',0,'data for : %s' % str(self)) # LOG('Base.setBinaryData',0,'data for : %s' % str(self))
# self.data = data # 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 # Hash method
def __hash__(self): def __hash__(self):
return hash(self.getUid()) return hash(self.getUid())
...@@ -2393,19 +2384,10 @@ class Base( CopyContainer, ...@@ -2393,19 +2384,10 @@ class Base( CopyContainer,
security.declarePublic('log') security.declarePublic('log')
def log(self, description, content='', level=INFO): def log(self, description, content='', level=INFO):
"""Put a log message """ """Put a log message """
if content=='': # allow for content only while keeping interface warnings.warn("The usage of Base.log is deprecated.\n"
description,content=content,description "Please use Products.ERP5Type.Log.log instead.",
st=traceback.extract_stack() DeprecationWarning)
head=[] unrestrictedLog(description, content = content, level = leve)
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)
# Dublin Core Emulation for CMF interoperatibility # Dublin Core Emulation for CMF interoperatibility
# CMF Dublin Core Compatibility # CMF Dublin Core Compatibility
......
##############################################################################
#
# 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)
...@@ -96,7 +96,7 @@ def initialize( context ): ...@@ -96,7 +96,7 @@ def initialize( context ):
from AccessControl.SecurityInfo import allow_module from AccessControl.SecurityInfo import allow_module
allow_module('Products.ERP5Type.Cache') 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.Message')
allow_module('Products.ERP5Type.Log')
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