[Zope-Checkins] CVS: Zope3/lib/python/Persistence - cPersistence.c:1.1.2.5

Guido van Rossum guido@python.org
Wed, 13 Feb 2002 14:34:09 -0500


Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv14140

Modified Files:
      Tag: Zope-3x-branch
	cPersistence.c 
Log Message:
Add __dict__ attribute.


=== Zope3/lib/python/Persistence/cPersistence.c 1.1.2.4 => 1.1.2.5 ===
 }
 
+
+static PyObject *
+persist_get_dict(PyPersistObject *self)
+{
+    PyObject *d;
+    d = self->po_dict;
+    if (d == NULL) {
+	self->po_dict = d = PyDict_New();
+	if (d == NULL)
+	    return NULL;
+    }
+    Py_INCREF(d);
+    return d;
+}
+
 static PyGetSetDef persist_getsets[] = {
     {"_p_changed", (getter)persist_get_state, (setter)persist_set_state},
     {"_p_time", (getter)persist_get_time},
+    {"__dict__", (getter)persist_get_dict},
     {NULL}
 };
 
@@ -533,7 +549,7 @@
 	0,					/* tp_dict */
 	0,					/* tp_descr_get */
 	0,					/* tp_descr_set */
-	0,					/* tp_dictoffset */
+	offsetof(PyPersistObject, po_dict),	/* tp_dictoffset */
 	0,					/* tp_init */
 	0,					/* tp_alloc */
 	PyType_GenericNew,			/* tp_new */