[wxPython] wxFileSystemHandler - not the wxPyTypeCast prob!

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

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

> 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
>

Sorry for the empty reply, I had too many windows open at once and lost
track of this one and just clicked send on all of them. I meant to say that
I didn't see anything wrong after a quick look around. If you can send me a
small standalone sample I can look further.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

I think it would be faster for me to trace thru the prob myself: since I
have VStudio etc. I have successfully avoided building from src
so far :slight_smile:

BTW, I has two hassles building wxPython from the CVS srcs downloaded
today; both related to wx\msw\setup.h. I found that USE_DOC_VIEW_ARCHITECTURE
needs to be 1 or the new FileHistory stuff causes undefined external errors when linking
wxPython. This was ambiguous, since the various on-line and cvs versions of BUILD.win32.txt
differed on this one. Also, the cvs version of BUILD.win32.txt says that wxUSE_CMDLINE_PARSER
needs to be 0; I found that it needed to be 1 or undef external errors occurred (having something to
do with the App class) when building wxPython.

Fortunately, these are easy to spot since the error messages give pretty good hints as to what's
going on.

Anyway, building from CVS solved my problem. Saved me from debugging it!
  
Jeff Sasmor
jeff@sasmor.com

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Monday, May 13, 2002 3:27 PM
Subject: Re: [wxPython] wxFileSystemHandler - not the wxPyTypeCast prob!

> > 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
> >

Sorry for the empty reply, I had too many windows open at once and lost
track of this one and just clicked send on all of them. I meant to say that
I didn't see anything wrong after a quick look around. If you can send me a
small standalone sample I can look further.

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

BTW, I has two hassles building wxPython from the CVS srcs downloaded
today; both related to wx\msw\setup.h. I found that

USE_DOC_VIEW_ARCHITECTURE

needs to be 1 or the new FileHistory stuff causes undefined external

errors when linking

wxPython. This was ambiguous, since the various on-line and cvs versions

of BUILD.win32.txt

Yep, I need to update those docs...

Anyway, building from CVS solved my problem. Saved me from debugging it!

Good! I love it when problems are already solved! <wink>

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!