[Twisted-Python] Questions about class KeyFactory.

Thomas Kristensen thomas at copyleft.no
Wed Dec 8 06:30:59 EST 2004


I my a bit afraid im asking a stupid question here, I'll do it anyways

(from twisted/enterprise/row.py)
class KeyFactory:
         warnings.warn("This is deprecated. Use the underlying database to
 	generate keys, or just roll your own.", DeprecationWarning)

As the warnings says this class is deprecated. Use the underlying 
database. I was wondering if anybody have some example code for this. Im 
using a PgDB.

Here's my rowObject:
class DummyRow(row.RowObject):
     rowColumns = [
         ("testId",  "int"),
     rowKeyColumns    = [("testId","int")]
     rowTableName     = "dummytable"

And my sql code:

CREATE TABLE dummytable (
 	testName varchar(64),
 	testData varchar

So when using a sequencer to generate an unique key for testId, I dont 
need to supply testId in my insert sql statement. But twisted complains if 
i dont use the assignKeyAttr function, PG complains if I use it with a 
value thats already used (ofcourse).

My insert code

     b = DummyRow()
     b.assignKeyAttr("testId", 3)
     b.testName = "myTestName"
     b.testData = "My test data string"

Again if was wondering if somebody had some sample code to help me solve 
my problem or a point in the right direction.

Thanks in advance,


More information about the Twisted-Python mailing list