[Zope] Newbie question: using backing files.

Michael T. Richter Michael T. Richter" <mtr@ottawa.com
Fri, 24 Mar 2000 12:00:48 -0500


I have a situation where there are some HTML files which I do not control
that I would like to open up to access through my Zope server.  I don't want
to import these HTML files as Zope objects because these files will
frequently be edited and updated in place and I want any changes made to
these HTML sources to be immediately reflected in Zope as they occur.  I
also don't want to just use a URL to access them because a) the end-users
shouldn't be aware that they're exiting Zope scope for these items and b) no
URL could possibly point to these files since they're actually stored in a
revision control system through a "view" (in essence, a virtual local
directory tree).

So what this basically boils down to is this: I'd like to take a URL like
this...

    http://my.intranet.site/Documentation/ComponentSpecs/MyComponent.html

...and have the logic behind it conform roughly to the following pseudocode:

    1. Switch to "/viewdir/source/component/MyComponent/doc".
    2. Open the file "ComponentSpec.html".
    3. Serve up the contents of that file to the user.

The user should see no visible signs that the data comes from outside of the
Zope environment.

I've already investigated using an external method to accomplish some of
this.  For example I served up an outside file in almost exactly the way I
wanted to accomplish this using code like the following:

    def testMethod():
        s = ""
        f = open("/viewdir/[...]/ComponentSpec.html", "r")
        for l in f.readlines():
            s = s + l[:-1]
        return s

Indeed this does EXACTLY what I want.  (In any production version of
this--this was only a quick'n'dirty hack--I'd be doing some significant
caching and version checking.  But the example gets the drift across.)  The
only problem is that I can't figure out how to translate a URL like the one
I provided above into a method call like testMethod("MyComponent").  (The
documentation on these things is a bit... spare.)

So does anybody out there have any suggestions?  I'm not afraid to get my
hands dirty with Python (it being my scripting language of choice for the
past 4+ years) and I'm not afraid to learn Stupid DTML Tricks.  I just don't
know enough Zope yet to even be dangerous.