problems rendering objects stored in the local file system
I am having trouble figuring out how to get Zope to access and render html and images files properly in the following context: In the local file system (that is, the Linux file system to be explicit) I have a collection of directories each containing an index.html file consisting of HTML and a collection of image files (*.jpg, *.gif, *.swf) referenced by the HTML. From a DTML object in the ZODB, I want to render the index.html and have it properly access the local image files. Calling the file "index.html" may be a bad name choice because it may be interpreted especially. In fact, what I really would like to be able to do is to reference all files relatively and allow internal directories and the like. We've been using the LocalFS product, mostly with great success, but this has got me stumped. Any suggestions? hints? pointers? -- Dennis Allison * Computer Systems Laboratory * Gates 227 * Stanford University * Stanford CA 94305 * (650) 723-9213 * (650) 723-0033 fax * allison@shasta.stanford.edu * allison@sumeru.stanford.edu
--On Mittwoch, 27. April 2005 19:57 Uhr -0700 Dennis Allison <allison@shasta.stanford.edu> wrote:
In the local file system (that is, the Linux file system to be explicit) I have a collection of directories each containing an index.html file consisting of HTML and a collection of image files (*.jpg, *.gif, *.swf) referenced by the HTML. From a DTML object in the ZODB, I want to render the index.html and have it properly access the local image files.
The index.html has nothing to do with your stuff in the filesystem. You reference images through an URL in the <img src...attribute. And the method or whatever is located behind the URL is in charge to send the image data to the client (it does not matter where the image is actually stored (filesystem, memory, moon). Bascially the method is called (requested) from the client through HTTP and it has to send the data + the corresponding HTTP header telling the client: I am an image of type XXX. -aj
You have at least two choices: 1. Use apache and don't fetch index.html and the images through zope. Most installations use apache in front of zope, so this is just a matter of rewrite rules. 2. Use an External Method and make each image src attribute a function call, passing the image url as a paramter, for example: <img src="fetchimage?from=some/place/in/your/file/system"... If you do that, make sure you include code to check that a malicious user cannot fetch any file from your file system. There have been some recent (this year) posts of example code you can google for. Cliff Dennis Allison wrote:
I am having trouble figuring out how to get Zope to access and render html and images files properly in the following context:
In the local file system (that is, the Linux file system to be explicit) I have a collection of directories each containing an index.html file consisting of HTML and a collection of image files (*.jpg, *.gif, *.swf) referenced by the HTML. From a DTML object in the ZODB, I want to render the index.html and have it properly access the local image files. Calling the file "index.html" may be a bad name choice because it may be interpreted especially. In fact, what I really would like to be able to do is to reference all files relatively and allow internal directories and the like. We've been using the LocalFS product, mostly with great success, but this has got me stumped.
Any suggestions? hints? pointers?
participants (3)
-
Andreas Jung -
Cliff Ford -
Dennis Allison