[Zope-Checkins] CVS: Zope2 - Uninstalled.py:1.10.36.1
shane@digicool.com
shane@digicool.com
Mon, 2 Jul 2001 13:43:00 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/OFS
In directory korak.digicool.com:/tmp/cvs-serv29697
Modified Files:
Tag: Zope-2_4-branch
Uninstalled.py
Log Message:
Collector #2256: Handling of broken classes was broken. (Now that's ironic :-)
--- Updated File Uninstalled.py in package Zope2 --
--- Uninstalled.py 2001/03/26 20:02:47 1.10
+++ Uninstalled.py 2001/07/02 17:43:00 1.10.36.1
@@ -88,8 +88,11 @@
import string, SimpleItem, Globals, Acquisition
from Acquisition import Acquired
import Persistence
+from thread import allocate_lock
+from zLOG import LOG, WARNING
broken_klasses={}
+broken_klasses_lock = allocate_lock()
class BrokenClass(Acquisition.Explicit, SimpleItem.Item,
Persistence.Overridable):
@@ -117,30 +120,33 @@
manage_workspace=manage
-def Broken(self, oid, klass):
- if broken_klasses.has_key(klass):
- klass=broken_klasses[klass]
- else:
- module, klass = klass
- d={'BrokenClass': BrokenClass}
- exec ("class %s(BrokenClass): ' '; __module__=%s"
- % (klass, `module`)) in d
- broken_klasses[klass]=d[klass]
- klass=d[klass]
- module=string.split(module,'.')
- if len(module) > 2 and module[0]=='Products':
- klass.product_name= module[1]
- klass.title=(
- 'This object from the %s product '
- 'is broken!' %
- klass.product_name)
- klass.info=(
- 'This object\'s class was %s in module %s.' %
- (klass.__name__, klass.__module__))
-
+def Broken(self, oid, pair):
+ broken_klasses_lock.acquire()
+ try:
+ if broken_klasses.has_key(pair):
+ klass = broken_klasses[pair]
+ else:
+ module, klassname = pair
+ d={'BrokenClass': BrokenClass}
+ exec ("class %s(BrokenClass): ' '; __module__=%s"
+ % (klassname, `module`)) in d
+ klass = broken_klasses[pair] = d[klassname]
+ module=string.split(module,'.')
+ if len(module) > 2 and module[0]=='Products':
+ klass.product_name= module[1]
+ klass.title=(
+ 'This object from the %s product '
+ 'is broken!' %
+ klass.product_name)
+ klass.info=(
+ 'This object\'s class was %s in module %s.' %
+ (klass.__name__, klass.__module__))
+ LOG('ZODB', WARNING, 'Could not import class %s '
+ 'from module %s' % (`klass.__name__`, `klass.__module__`))
+ finally:
+ broken_klasses_lock.release()
if oid is None: return klass
i=klass()
i._p_oid=oid
i._p_jar=self
return i
-