[Zodb-checkins] CVS: ZODB3/persistent - cPickleCache.c:1.87.10.5

Jim Fulton jim at zope.com
Fri Jan 30 11:16:51 EST 2004


Update of /cvs-repository/ZODB3/persistent
In directory cvs.zope.org:/tmp/cvs-serv9960/src/persistent

Modified Files:
      Tag: zope3-zodb3-devel-branch
	cPickleCache.c 
Log Message:
Added a method for getting debugging information.


=== ZODB3/persistent/cPickleCache.c 1.87.10.4 => 1.87.10.5 ===
--- ZODB3/persistent/cPickleCache.c:1.87.10.4	Thu Jan 29 08:32:17 2004
+++ ZODB3/persistent/cPickleCache.c	Fri Jan 30 11:16:48 2004
@@ -423,6 +423,45 @@
 }
 
 static PyObject *
+cc_debug_info(ccobject *self)
+{
+    PyObject *l,*k,*v;
+    int p = 0;
+
+    l = PyList_New(0);
+    if (l == NULL)
+	return NULL;
+
+    while (PyDict_Next(self->data, &p, &k, &v)) 
+      {
+        if (v->ob_refcnt <= 0)
+          v = Py_BuildValue("Oi", k, v->ob_refcnt);
+
+        else if (! PyType_Check(v) &&
+                 (v->ob_type->tp_basicsize >= sizeof(cPersistentObject))
+                 )
+          v = Py_BuildValue("Oisi", 
+                            k, v->ob_refcnt, v->ob_type->tp_name,
+                            ((cPersistentObject*)v)->state);
+        else
+          v = Py_BuildValue("Ois", k, v->ob_refcnt, v->ob_type->tp_name);
+
+        if (v == NULL)
+          goto err;
+
+        if (PyList_Append(l, v) < 0)
+          goto err;
+      }
+
+    return l;
+
+ err:
+    Py_DECREF(l);
+    return NULL;
+
+}
+
+static PyObject *
 cc_lru_items(ccobject *self)
 {
     PyObject *l;
@@ -563,6 +602,8 @@
      "get(key [, default]) -- get an item, or a default"},
     {"ringlen", (PyCFunction)cc_ringlen, METH_NOARGS,
      "ringlen() -- Returns number of non-ghost items in cache."},
+    {"debug_info", (PyCFunction)cc_debug_info, METH_NOARGS,
+     "debug_info() -- Returns debugging data about objects in the cache."},
     {NULL, NULL}		/* sentinel */
 };
 




More information about the Zodb-checkins mailing list