[Commits] (vajda) fixed bugs with del and set

commits at osafoundation.org commits at osafoundation.org
Mon Apr 4 15:03:33 PDT 2005


Commit by: vajda
Modified files:
internal/chandlerdb/Makefile 1.12 1.13
internal/chandlerdb/chandlerdb/item/ItemError.py 1.1 1.2
internal/chandlerdb/chandlerdb/schema/descriptor.c 1.7 1.8

Log message:
fixed bugs with del and set

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/internal/chandlerdb/Makefile.diff?r1=text&tr1=1.12&r2=text&tr2=1.13
http://cvs.osafoundation.org/index.cgi/internal/chandlerdb/chandlerdb/item/ItemError.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/internal/chandlerdb/chandlerdb/schema/descriptor.c.diff?r1=text&tr1=1.7&r2=text&tr2=1.8

Index: internal/chandlerdb/Makefile
diff -u internal/chandlerdb/Makefile:1.12 internal/chandlerdb/Makefile:1.13
--- internal/chandlerdb/Makefile:1.12	Tue Mar 29 14:54:26 2005
+++ internal/chandlerdb/Makefile	Mon Apr  4 15:03:31 2005
@@ -1,7 +1,7 @@
 
 include ../Makefile.inc
 
-RELVER=0.5-5
+RELVER=0.5-6
 CHANDLERDB=$(INTERNAL)/chandlerdb
 
 BUILD=build_$(SNAP)

Index: internal/chandlerdb/chandlerdb/item/ItemError.py
diff -u internal/chandlerdb/chandlerdb/item/ItemError.py:1.1 internal/chandlerdb/chandlerdb/item/ItemError.py:1.2
--- internal/chandlerdb/chandlerdb/item/ItemError.py:1.1	Fri Mar 18 13:24:18 2005
+++ internal/chandlerdb/chandlerdb/item/ItemError.py	Mon Apr  4 15:03:31 2005
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.1 $"
-__date__      = "$Date: 2005/03/18 21:24:18 $"
+__revision__  = "$Revision: 1.2 $"
+__date__      = "$Date: 2005/04/04 22:03:31 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -53,13 +53,6 @@
         return self.__doc__ %(self.getItem()._repr_())
 
 
-class NoParentError(ValueError, ItemError):
-    'While creating %s, parent is None'
-    
-    def __str__(self):
-        return self.__doc__ %(self.getItem()._repr_())
-
-
 class OwnedValueError(ValueError, ItemError):
     "Value %s is already owned by item %s on attribute '%s'"
 
@@ -165,6 +158,14 @@
                               self.str(self.args[2]))
 
 
+class ViewMismatchError(BadRefError):
+    "Error establishing bidirectional ref, item views don't match: %s is in %s but %s is in %s"
+
+    def __str__(self):
+        return self.__doc__ %(self.args[0]._repr_(), self.args[0].itsView,
+                              self.args[1]._repr_(), self.args[1].itsView)
+
+
 class IndexError(ItemError):
 
     def getCollection(self):
@@ -196,13 +197,3 @@
 
     def __str__(self):
         return self.args[0] % self.args[1:]
-
-
-class NoSuchDefaultParentError(SchemaError):
-    'While creating %s, defaultParent %s, specified on kind %s, was not found'
-
-    def __str__(self):
-        kind = self.args[1]
-        return self.__doc__ %(self.str(self.getItem()), 
-                              kind._values['defaultParent'],
-                              kind.itsPath)

Index: internal/chandlerdb/chandlerdb/schema/descriptor.c
diff -u internal/chandlerdb/chandlerdb/schema/descriptor.c:1.7 internal/chandlerdb/chandlerdb/schema/descriptor.c:1.8
--- internal/chandlerdb/chandlerdb/schema/descriptor.c:1.7	Tue Mar 29 16:44:11 2005
+++ internal/chandlerdb/chandlerdb/schema/descriptor.c	Mon Apr  4 15:03:32 2005
@@ -24,7 +24,6 @@
 } t_descriptor;
 
 
-
 static void t_descriptor_dealloc(t_descriptor *self);
 static PyObject *t_descriptor_new(PyTypeObject *type,
                                   PyObject *args, PyObject *kwds);
@@ -46,6 +45,7 @@
 
 static long _lastAccess = 0L;
 static PyObject *PyExc_StaleItemError;
+
 static PyObject *_getRef_NAME;
 static PyObject *getAttributeValue_NAME;
 static PyObject *setAttributeValue_NAME;
@@ -106,7 +106,7 @@
     0,                                          /* tp_getattro */
     0,                                          /* tp_setattro */
     0,                                          /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                         /* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   /* tp_flags */
     "attribute descriptor",                     /* tp_doc */
     0,                                          /* tp_traverse */
     0,                                          /* tp_clear */
@@ -290,8 +290,12 @@
                         return 0;
                 }
 
-                PyObject_CallMethodObjArgs(obj, setAttributeValue_NAME, self->name, value, attrDict, attrID, Py_True, Py_False, NULL);
+                value = PyObject_CallMethodObjArgs(obj, setAttributeValue_NAME, self->name, value, attrDict, attrID, Py_True, Py_False, NULL);
 
+                if (!value)
+                    return -1;
+                    
+                Py_DECREF(value);
                 return 0;
             }
         }
@@ -321,9 +325,12 @@
             PyObject *attrID = PyTuple_GET_ITEM(tuple, 0);
             int flags = PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 1));
             PyObject *attrDict = get_attrdict(obj, flags);
+            PyObject *value = PyObject_CallMethodObjArgs(obj, removeAttributeValue_NAME, self->name, attrDict, attrID, NULL);
 
-            PyObject_CallMethodObjArgs(obj, removeAttributeValue_NAME, self->name, attrDict, attrID, NULL);
+            if (!value)
+                return -1;
 
+            Py_DECREF(value);
             return 0;
         }
     }
@@ -384,11 +391,9 @@
     else
     {
         PyObject *values = ((t_item *) attribute)->values;
-        PyObject *isRequired;
         int flags = 0;
 
-        isRequired = PyDict_GetItem(values, required_NAME);
-        if (isRequired == Py_True)
+        if (PyDict_GetItem(values, required_NAME) == Py_True)
             flags |= REQUIRED;
 
         if (PyDict_Contains(values, otherName_NAME))
@@ -418,6 +423,8 @@
                 if (type != Py_None)
                 {
                     PyObject *isSimple = PyObject_CallMethodObjArgs(type, isSimple_NAME, NULL);
+
+                    Py_DECREF(type);
                     if (isSimple == NULL)
                         return NULL;
                     if (isSimple == Py_True)
@@ -425,8 +432,8 @@
 
                     Py_DECREF(isSimple);
                 }
-
-                Py_DECREF(type);
+                else
+                    Py_DECREF(type);
             }
 
             flags |= VALUE;



More information about the Commits mailing list