[Twisted-Python] assignKeyAttr in row object

Dear all, What is the assignKeyAttr method used for in a row object? Is it similar to a primary key that can be used to identity the instance? Liming

Is there any other documentation on using Twisted other than that on the Twisted site? Chuck Wegrzyn

Dave Peticolas wrote:
Hi Dave, Is it necessary to use assignKeyAttr? From the source code, it doesn't seem to do anything special, except to change the primary key(s)? def assignKeyAttr(self, attrName, value): """Assign to a key attribute. This cannot be done through normal means to protect changing keys of db objects. """ found = 0 for keyColumn, type in self.rowKeyColumns: if keyColumn == attrName: found = 1 if not found: raise DBError("%s is not a key columns." % attrName) self.__dict__[attrName] = value Alternatively, I could set the primary key manually. newRoom = RoomRow() newRoom.roomID = get_unique _id() #newRoom.assignKeyAttr("roomID", get_unique _id()) reflector.insertRow(newRoom).addCallback(onInsert) Liming

Is there any other documentation on using Twisted other than that on the Twisted site? Chuck Wegrzyn

Dave Peticolas wrote:
Hi Dave, Is it necessary to use assignKeyAttr? From the source code, it doesn't seem to do anything special, except to change the primary key(s)? def assignKeyAttr(self, attrName, value): """Assign to a key attribute. This cannot be done through normal means to protect changing keys of db objects. """ found = 0 for keyColumn, type in self.rowKeyColumns: if keyColumn == attrName: found = 1 if not found: raise DBError("%s is not a key columns." % attrName) self.__dict__[attrName] = value Alternatively, I could set the primary key manually. newRoom = RoomRow() newRoom.roomID = get_unique _id() #newRoom.assignKeyAttr("roomID", get_unique _id()) reflector.insertRow(newRoom).addCallback(onInsert) Liming
participants (3)
-
C Wegrzyn
-
Dave Peticolas
-
Tsai Li Ming