Re: [SQLObject] SQLite fails for binaries
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-09-07 02:55:29
|
On Saturday, September 6, 2003, at 09:35 PM, Joshua Rothenberg wrote: > On Sat, 06 Sep 2003 21:53:27 -0400 > "Ian Bicking" <ia...@co...> wrote: >> image = (wherever you are getting images from) >> soinstance.image = image >> assert soinstance.image == image > > All right, I added an assert to my wrapper function: > > def set_img(filename, data, refpage): > encodedData = base64.encodestring(data) > newImage = Image.new(name = filename, content = encodedData, page = > get_byname(refpage)) > assert newImage.content == encodedData > > and the assertion fails.. > Here, I'll post the rest of the file: > > from SQLObject import * > import base64 > > __connection__ = SQLiteConnection('db.db') > > class record: > def __init__(self,name,content): > self.name=name > self.content=content > > class Image(SQLObject): > name = StringCol(alternateID=True) > content = StringCol() > page = ForeignKey('Page') > You should add: def _set_content(self, value): self._SO_set_content(base64.encodestring(value)) def _get_content(self): return base64.decodestring(self._SO_get_content()) I'm not sure where the problem is, but this will make the whole thing less error-prone. Ian |