[Twisted-Python] enterprise.row

Justin Ryan justin at gnubia.net
Sat Apr 5 13:20:11 MST 2003


I'm attempting to implement a simple database application (again) using
twisted.enterprise.row.  Perhaps my failure to do so successfully in the
past should be a hint that I should give up, but the concept seems
really cool, and I keep getting closer.

I'm running into an issue that no doubt has something to do with my lack
of understanding of t.e.row.  I've been wanting to try it for a while,
and decided to design a simple database with the goal of implementing a
simple application using t.e.row.  In any case, it seems I am angering
row.  My first attempt at using it was to try and create/insert a new
row, and i received the following exception:

<- snip ->
Traceback (most recent call last):
  File "Zone.py", line 33, in ?
    reflector.insertRow(newZone).addCallback(onInsert)
  File
"/usr/lib/python2.2/site-packages/twisted/enterprise/sqlreflector.py",
line 308, in insertRow
    sql = self.insertRowSQL(rowObject)
  File
"/usr/lib/python2.2/site-packages/twisted/enterprise/sqlreflector.py",
line 301, in insertRowSQL
    args.append(self.quote_value(rowObject.findAttribute(column), type))
  File "/usr/lib/python2.2/site-packages/twisted/enterprise/row.py",
line 87, in findAttribute
    return getattr(self, attr)
AttributeError: ZONE_SOA instance has no attribute 'ZONE_SOAID'
<- snip ->

"ZONE_SOAID" is the primary key for the "ZONE_SOA" table.  I did not set
the primary key because it is a postgres serial column - that is, it
should automatically increment the pkey each time a new row is
inserted.  If I use setKeyAttr("ZONE_SOAID", 1), the AttributeError
comes up for the next attribute that is not being given a value.

I read the row documentation a little more, and it doesn't appear to
like what I'm trying to do all too much.  I can use python to fill the
object with default values, but the database will do that for me, and
with less work on the part of my application (plus, the KeyFactory class
says it is not thread-safe, I know that my postgres series is).

Is there any way for row to allow me to insert a new row with some empty
values, and simply ignore them (allowing the database to use its'
default)?  If not, any idears on where/how this might need to be done? 
Perhaps this is a good time for me to foray into twisted hacking..

TIA,

-Justin





More information about the Twisted-Python mailing list