[Zodb-checkins] CVS: Zope/lib/python/ZODB - DB.py:1.36.2.2

Brian Lloyd brian@zope.com
Wed, 9 Jan 2002 13:53:32 -0500


Update of /cvs-repository/Zope/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv27003

Modified Files:
      Tag: Zope-2_5-branch
	DB.py 
Log Message:
Fixed an assumption on the existence of an __module__ for a class, 
which broke cache detail reporting when ZClass instances appeared 
in the cache.


=== Zope/lib/python/ZODB/DB.py 1.36.2.1 => 1.36.2.2 ===
         def f(con,detail=detail,have_detail=detail.has_key):
             for oid, ob in con._cache.items():
-                c="%s.%s" % (ob.__class__.__module__, ob.__class__.__name__)
+                module = getattr(ob.__class__, '__module__', '')
+                module = module and '%s.' % module or ''
+                c="%s%s" % (module, ob.__class__.__name__)
                 if have_detail(c): detail[c]=detail[c]+1
                 else: detail[c]=1
         
@@ -177,13 +179,15 @@
                         id=d['id']
                     elif d.has_key('__name__'):
                         id=d['__name__']
-    
+
+                module = getattr(ob.__class__, '__module__', '')
+                module = module and '%s.' % module or ''
+
                 detail.append({
                     'conn_no': cn,
                     'oid': oid,
                     'id': id,
-                    'klass': "%s.%s" % (ob.__class__.__module__,
-                                        ob.__class__.__name__),
+                    'klass': "%s%s" % (module, ob.__class__.__name__),
                     'rc': rc(ob)-4,
                     'state': ob._p_changed,
                     #'references': con.references(oid),