I'm trying to use a custom file system handler to retrieve data from the Zope
object database (ZODB) and display it in a wxHTML window; and while it
seems (to me...) to return correct values, the stuff that's returned seems to be
ignored ignored by the HTML browser.
Here's the code for the ZODB_FS file system handler. It retrieves certain
types of objects; say, a jpeg, or html, or text/plain; and seems (to me...) to
set up a wxFSFile correctly. It responds correctly to a URI that begins
with 'db'. like: db:RootFolder.Image
Using the Wing debugger, I can set a breakpoint just at the end of the
OpenFile method and strobe the FSFile for it's stream, mime, etc:
these are correct.
I can even read the stream and the data is correct. But when the method
returns nothing appears in the HTML window! Arrgh!
Perhaps there's a problem in the SWIGged code, or maybe it's me.
Robin or anyone: any comments/corrections/help?
code: Note that this is not Zope although it uses the ZODB and a
custom object file system.
···
_____________________________________________
from wxPython.wx import *
from Mixins.BaseFunctionality.Traversable import findObjectViaTraversal
from StringIO import StringIO
class ZODB_FS(wxFileSystemHandler):
def __init__(self):
wxFileSystemHandler.__init__(self)
def CanOpen(self,location):
p=self.GetProtocol(location)
return (p=='db')
def OpenFile(self,parentfs,location):
path=self.GetRightLocation(location)
obj = findObjectViaTraversal(path.replace('.','+'))
if not obj:
return None
if not hasattr(obj,'getData') or not hasattr(obj,'getMimeType'):
return None
data = obj.getData(1)
if not data:
return None
mime = obj.getMimeType(1)
s = StringIO(data)
i=wxInputStream(s)
anchor = self.GetAnchor(location)
tm = obj.bobobase_modification_time().timeTime()
wxT = wxDateTimeFromTimeT(tm)
f=wxFSFile(i,location,mime,anchor,wxT)
return f
Jeff Sasmor
jeff@sasmor.com