[Zope-dev] Product Access to Files

Ian Beatty beatty at physics.umass.edu
Tue Mar 9 13:12:59 EST 2004


Greetings.

I'm developing a Python-based product that needs to serve up a variety of
XML files out of the product's directory. That is, certain URLs handled by
instances of a product-defined type need to return an XML file that's on
disk along with the product's DTML views and the like. Let's say that the
URL

    http://localhost/foo/bar

resolves to an object my product class defines. Then I'd like

    http://localhst/foo/bar/static/a

to serve a file named 'a' in a directory named 'xml_files' in my product's
directory. Similarly,

    http://localhst/foo/bar/static/b/c

should serve a file named 'c' within a directory named 'b' within
'xml_files' in my product's directory.

I'd rather not hard-code every single file in the Python module, since there
will be many, and they'll be changing a lot during development.

I've been messing around with DTMLFile and ClassicHTMLFile and the like,
haven't been able to figure out how to get it to work for arbitrary paths.
They also require all my file names end in '.dtml', which is quite a pain.

Any suggestions?

Thanks,

..Ian

-- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --
Dr. Ian Beatty                           beatty at physics.umass.edu
Physics Education Research Group              voice: 413.545.9483
Department of Physics                           fax: 413.545.4884
Univ. of Massachusetts              AIM: (available upon request)
Amherst, MA 01003-4525 USA       http://umperg.physics.umass.edu/
-- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- --





More information about the Zope-Dev mailing list