[Twisted-Python] Re: Insecure Jelly exception in daemon mode (John Toohey)

Matthew Sherborne miracle at slingshot.co.nz
Mon Jul 12 19:20:56 EDT 2004

Turn the data into nice types, with pg you might get PgInt types from 
your data, and each row of the database is in a special list & dict type 
allowing numeric or nomical access the value of each column.

Easy way:
tosend = []
for row in data:
   newRow = tuple([str(item) for item in row])

Better way?
Surposing your data is returned as an int, a date/time, an interval 
(mx.datetimedelta) and a string...
tosend = []
for myint, mydate, mydelta, mystr in data:
   tosend.append((int(myint), packageDate(mydate), 
packageDateTimeDelta(mydelta), str(mystr)))

def packageDate(d):
   return d.year, d.month, d.day, d.hour, d.minute, d.second

def unpackageDate(d):
  from mx.DateTime import DateTime
  return DateTime(*d)

I will leave the rest as an exercise for the reader.


May God bless you and your family
Matthew Sherborne

More information about the Twisted-Python mailing list