[Zope-Checkins] CVS: ZODB3/Persistence - cPersistence.c:1.72.8.6

Jeremy Hylton jeremy@zope.com
Tue, 1 Jul 2003 18:03:46 -0400


Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv26532

Modified Files:
      Tag: zodb33-devel-branch
	cPersistence.c 
Log Message:
reindent


=== ZODB3/Persistence/cPersistence.c 1.72.8.5 => 1.72.8.6 ===
--- ZODB3/Persistence/cPersistence.c:1.72.8.5	Tue Jul  1 17:01:05 2003
+++ ZODB3/Persistence/cPersistence.c	Tue Jul  1 18:03:45 2003
@@ -543,134 +543,134 @@
 static int
 _setattro(cPersistentObject *self, PyObject *oname, PyObject *v)
 {
-  char *name = "";
+    char *name;
 
-  if (oname == NULL)
-      return -1;
-  if (!PyString_Check(oname)) 
-      return -1;
-  name = PyString_AS_STRING(oname);
-  if (name == NULL)
-      return -1;
-
-  if (*name == '_' && name[1] == 'p' && name[2] == '_') {
-      if (strcmp(name + 3, "oid") == 0) {
-	  if (self->cache) {
-	      int result;
-	      if (v == NULL) {
-		  PyErr_SetString(PyExc_ValueError,
-				  "can not delete oid of cached object");
-		  return -1;
-	      }
-	      if (PyObject_Cmp(self->oid, v, &result) < 0)
-		  return -1;
-	      if (result) {
-		  PyErr_SetString(PyExc_ValueError,
-				  "can not change oid of cached object");
-		  return -1;
-	      }
-	  }
-	  Py_XINCREF(v);
-	  ASSIGN(self->oid, v);
-	  return 0;
-      }
-      else if (strcmp(name + 3, "jar") == 0) {
-	  if (self->cache && self->jar) {
-	      int result;
-	      if (v == NULL) {
-		  PyErr_SetString(PyExc_ValueError,
-				  "can not delete jar of cached object");
-		  return -1;
-	      }
-	      if (PyObject_Cmp(self->jar, v, &result) < 0)
-		  return -1;
-	      if (result) {
-		  PyErr_SetString(PyExc_ValueError,
-				  "can not change jar of cached object");
-		  return -1;
-	      }
-	  }
-	  Py_XINCREF(v);
-	  ASSIGN(self->jar, v);
-	  return 0;
-      }
-      else if (strcmp(name + 3, "serial") == 0) {
-	  if (v) {
-	      if (PyString_Check(v) && PyString_GET_SIZE(v) == 8)
-		  memcpy(self->serial, PyString_AS_STRING(v), 8);
-	      else {
-		  PyErr_SetString(PyExc_ValueError,
-				  "_p_serial must be an 8-character string");
-		  return -1;
-	      }
-	  } else 
-	      memset(self->serial, 0, 8);
-	  return 0;
-      }
-      else if (strcmp(name+3, "changed") == 0) {
-	  int deactivate = 0;
-	  if (!v)
+    if (oname == NULL)
+	return -1;
+    if (!PyString_Check(oname)) 
+	return -1;
+    name = PyString_AS_STRING(oname);
+    if (name == NULL)
+	return -1;
+
+    if (*name == '_' && name[1] == 'p' && name[2] == '_') {
+	if (strcmp(name + 3, "oid") == 0) {
+	    if (self->cache) {
+		int result;
+		if (v == NULL) {
+		    PyErr_SetString(PyExc_ValueError,
+				    "can not delete oid of cached object");
+		    return -1;
+		}
+		if (PyObject_Cmp(self->oid, v, &result) < 0)
+		    return -1;
+		if (result) {
+		    PyErr_SetString(PyExc_ValueError,
+				    "can not change oid of cached object");
+		    return -1;
+		}
+	    }
+	    Py_XINCREF(v);
+	    ASSIGN(self->oid, v);
+	    return 0;
+	}
+	else if (strcmp(name + 3, "jar") == 0) {
+	    if (self->cache && self->jar) {
+		int result;
+		if (v == NULL) {
+		    PyErr_SetString(PyExc_ValueError,
+				    "can not delete jar of cached object");
+		    return -1;
+		}
+		if (PyObject_Cmp(self->jar, v, &result) < 0)
+		    return -1;
+		if (result) {
+		    PyErr_SetString(PyExc_ValueError,
+				    "can not change jar of cached object");
+		    return -1;
+		}
+	    }
+	    Py_XINCREF(v);
+	    ASSIGN(self->jar, v);
+	    return 0;
+	}
+	else if (strcmp(name + 3, "serial") == 0) {
+	    if (v) {
+		if (PyString_Check(v) && PyString_GET_SIZE(v) == 8)
+		    memcpy(self->serial, PyString_AS_STRING(v), 8);
+		else {
+		    PyErr_SetString(PyExc_ValueError,
+				    "_p_serial must be an 8-character string");
+		    return -1;
+		}
+	    } else 
+		memset(self->serial, 0, 8);
+	    return 0;
+	}
+	else if (strcmp(name+3, "changed") == 0) {
+	    int deactivate = 0;
+	    if (!v)
 	    {
-	      /* delatter is used to invalidate the object
+		/* delatter is used to invalidate the object
 	         *even* if it has changed.
-	       */
-	      if (self->state != cPersistent_GHOST_STATE)
-		self->state = cPersistent_UPTODATE_STATE;
-	      deactivate = 1;
+		 */
+		if (self->state != cPersistent_GHOST_STATE)
+		    self->state = cPersistent_UPTODATE_STATE;
+		deactivate = 1;
 	    }
-	  else if (v == Py_None)
-	      deactivate = 1;
-	  if (deactivate)
+	    else if (v == Py_None)
+		deactivate = 1;
+	    if (deactivate)
 	    {
-	      PyObject *res;
-	      PyObject *meth = PyObject_GetAttr((PyObject *)self, 
-						py__p_deactivate);
-	      if (meth == NULL)
-		  return -1;
-	      res = PyObject_CallObject(meth, NULL);
-	      if (res) {
-		  Py_DECREF(res);
-	      } 
-	      else {
-		  /* an error occured in _p_deactivate().  
-
-		  It's not clear what we should do here.  The code is
-		  obviously ignoring the exception, but it shouldn't
-		  return 0 for a getattr and set an exception.  The
-		  simplest change is to clear the exception, but that
-		  simply masks the error. 
-
-		  XXX We'll print an error to stderr just like
-		  exceptions in __del__().  It would probably be
-		  better to log it but that would be painful from C.
-		  */
-		  PyErr_WriteUnraisable(meth);
-	      }
-	      Py_DECREF(meth);
-	      return 0;
+		PyObject *res;
+		PyObject *meth = PyObject_GetAttr((PyObject *)self, 
+						  py__p_deactivate);
+		if (meth == NULL)
+		    return -1;
+		res = PyObject_CallObject(meth, NULL);
+		if (res) {
+		    Py_DECREF(res);
+		} 
+		else {
+		    /* an error occured in _p_deactivate().  
+		       
+		    It's not clear what we should do here.  The code is
+		    obviously ignoring the exception, but it shouldn't
+		    return 0 for a getattr and set an exception.  The
+		    simplest change is to clear the exception, but that
+		    simply masks the error. 
+		    
+		    XXX We'll print an error to stderr just like
+		    exceptions in __del__().  It would probably be
+		    better to log it but that would be painful from C.
+		    */
+		    PyErr_WriteUnraisable(meth);
+		}
+		Py_DECREF(meth);
+		return 0;
 	    }
-	  if (PyObject_IsTrue(v)) 
-	      return changed(self);
-	  if (self->state >= 0) 
-	      self->state=cPersistent_UPTODATE_STATE;
-	  return 0;
+	    if (PyObject_IsTrue(v)) 
+		return changed(self);
+	    if (self->state >= 0) 
+		self->state=cPersistent_UPTODATE_STATE;
+	    return 0;
 	}
     }
-  else
+    else
     {
         if (!unghostify(self))
             return -1;
-      
-      accessed(self);
-
-      if ((! (*name=='_' && name[1]=='v' && name[2]=='_'))
-	 && (self->state != cPersistent_CHANGED_STATE && self->jar)
-	  && self->ob_type->tp_base->tp_setattro
-	 )
-	if (changed(self) < 0) return -1;
+	
+	accessed(self);
+	
+	if ((! (*name=='_' && name[1]=='v' && name[2]=='_'))
+	    && (self->state != cPersistent_CHANGED_STATE && self->jar)
+	    && self->ob_type->tp_base->tp_setattro
+	    )
+	    if (changed(self) < 0) return -1;
     }
-
-  return PyObject_GenericSetAttr((PyObject *)self, oname, v);
+    
+    return PyObject_GenericSetAttr((PyObject *)self, oname, v);
 }
 
 static int