[Zope3-checkins] CVS: Zope3/lib/python/Persistence - cPersistence.c:1.19
Jeremy Hylton
jeremy@zope.com
Mon, 7 Oct 2002 19:27:08 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv7411/Persistence
Modified Files:
cPersistence.c
Log Message:
Change implementation of _p_activate() method.
The new implementation only calls setstate() if the object is a
ghost. The old behavior of calling setstate() every time was bogus,
because the caller is almost always interested in making sure the
object is not a ghost, regardless of its current state.
=== Zope3/lib/python/Persistence/cPersistence.c 1.18 => 1.19 ===
--- Zope3/lib/python/Persistence/cPersistence.c:1.18 Mon Oct 7 10:46:22 2002
+++ Zope3/lib/python/Persistence/cPersistence.c Mon Oct 7 19:27:08 2002
@@ -217,6 +217,17 @@
return Py_None;
}
+/* Only activate an object if it is a ghost. */
+
+static PyObject *
+persist_activate(PyPersistObject *self)
+{
+ if (self->po_state == GHOST && self->po_dm)
+ return _PyPersist_Load((PyPersistBaseObject *)self);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject *
persist_deactivate(PyPersistObject *self)
{
@@ -674,7 +685,7 @@
}
static PyMethodDef base_persist_methods[] = {
- {"_p_activate", (PyCFunction)_PyPersist_Load, METH_NOARGS, },
+ {"_p_activate", (PyCFunction)persist_activate, METH_NOARGS, },
{"_p_deactivate", (PyCFunction)persist_deactivate, METH_NOARGS, },
{"_p_setattr", (PyCFunction)persist_p_setattr, METH_VARARGS, },
{"_p_delattr", (PyCFunction)persist_p_delattr, METH_O, },
@@ -685,7 +696,7 @@
{"__reduce__", (PyCFunction)persist_reduce, METH_NOARGS, },
{"__getstate__", (PyCFunction)persist_getstate, METH_NOARGS, },
{"__setstate__", persist_setstate, METH_O, },
- {"_p_activate", (PyCFunction)_PyPersist_Load, METH_NOARGS, },
+ {"_p_activate", (PyCFunction)persist_activate, METH_NOARGS, },
{"_p_deactivate", (PyCFunction)persist_deactivate, METH_NOARGS, },
{"_p_setattr", (PyCFunction)persist_p_setattr, METH_VARARGS, },
{"_p_delattr", (PyCFunction)persist_p_delattr, METH_O, },