Update of /cvsroot/pymerase/pymerase/pymerase/output/dbAPI
In directory sc8-pr-cvs1:/tmp/cvs-serv2558
Modified Files:
dbAPI.py
Log Message:
Added code to support setObjects which replaces the current conents of
the association (unlike append, which just adds to the association).
Index: dbAPI.py
===================================================================
RCS file: /cvsroot/pymerase/pymerase/pymerase/output/dbAPI/dbAPI.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** dbAPI.py 2 Apr 2003 23:24:27 -0000 1.21
--- dbAPI.py 5 Apr 2003 01:39:42 -0000 1.22
***************
*** 186,189 ****
--- 186,206 ----
return self.loaded_objects + self.appended_objects
+ def setObjects(self, objects):
+ """Replace the current contents of this association with the provided set.
+ """
+ if self.otherEndMultiplicity == fkeyTypes.OneToOne:
+ # we want a singleton item
+ if type(object) == types.ListType:
+ raise ValueError("One to one links cannot be lists")
+ self.appended_objects = [objects]
+ else:
+ # we want a list
+ if type(object) != types.ListType:
+ raise ValueError("Many to one links must be lists")
+ self.appended_objects = objects
+
+ # erase any loaded objects
+ self.loaded_objects = []
+
def appendObjects(self, object):
if self.otherEndMultiplicity == fkeyTypes.OneToOne:
|