Mercurial > p > roundup > code
diff roundup/backends/rdbms_common.py @ 5492:6b0c542642be
blobfiles now always stores/returns bytes
any conversation is done in the backend layer
added a special "binary_content" property to read the data as bytes
changed history generation to read property data on demand
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Sun, 12 Aug 2018 16:05:42 +0100 |
| parents | 630a00b20394 |
| children | bb7865241f8a |
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py Mon Aug 06 20:52:15 2018 +0100 +++ b/roundup/backends/rdbms_common.py Sun Aug 12 16:05:42 2018 +0100 @@ -69,7 +69,7 @@ from roundup.date import Range from roundup.backends.back_anydbm import compile_expression -from roundup.anypy.strings import us2s +from roundup.anypy.strings import b2s, bs2b, us2s # dummy value meaning "argument not passed" @@ -3055,7 +3055,7 @@ content, mime_type) # store off the content as a file - self.db.storefile(self.classname, newid, None, content) + self.db.storefile(self.classname, newid, None, bs2b(content)) # fire reactors self.fireReactors('create', newid, None) @@ -3070,11 +3070,14 @@ poss_msg = 'Possibly a access right configuration problem.' if propname == 'content': try: - return self.db.getfile(self.classname, nodeid, None) + return b2s(self.db.getfile(self.classname, nodeid, None)) except IOError as strerror: # BUG: by catching this we donot see an error in the log. return 'ERROR reading file: %s%s\n%s\n%s'%( self.classname, nodeid, poss_msg, strerror) + elif propname == 'binary_content': + return self.db.getfile(self.classname, nodeid, None) + if default is not _marker: return Class.get(self, nodeid, propname, default) else: @@ -3098,7 +3101,7 @@ # do content? if content: # store and possibly index - self.db.storefile(self.classname, itemid, None, content) + self.db.storefile(self.classname, itemid, None, bs2b(content)) if self.properties['content'].indexme: mime_type = self.get(itemid, 'type', self.default_mime_type) self.db.indexer.add_text((self.classname, itemid, 'content'),
