On 20 Oct 1999 14:25:01 -0500, Stefan Hoffmeister wrote:
Is there a way to generate non-existent documents on the fly - some kind of "rewriting" the target URL?
Example site structure
/root (http://localhost/) /content layout_template some_txt
A user queries
http://localhost/content/some.html
Obviously, "some.html" does not exist. This is where some mechanism (the one I am trying to find <g>) kicks in. It will analyze the query string, detect that there is "some_txt" and "layout_template". Based on that it will generate "some.html" on the fly.
Any ideas?
There are several ways of going about this, depending on what you are doing. I don't know of a way to do it without using Python to wrap the object in a class which knows what to do with the rest of the URL. For example, say you are extracting a document from a SQL database but you want the client to save the data with a specific filename (stored in the database?). You can set the headers via something like: <!--#call "RESPONSE.setHeader('Content-Disposition', 'attachment; filename='+filename)"--> But 'filename' isn't standard (AFAIK) and isn't implement in all browsers. However, if you include the filename as the last component of the URL, browsers can (usually) deal with that. So what you need is some sort of __getitem__ or __bobo_traverse which knows how to deliver the correct file data given a query and the 'filename'. How you invoke the __bobo_traversee__ is the hard part. :^) If you are doing a SQL query with a SQL Method, you can use the Advanced Options to specify the Class name which will wrap the SQL method results. That class would include a __bobo_traverse__ method which takes the key (the filename part of the URL) and returns the result. Note that you might not even use the key because you might have all the info needed already. The __bobo_traverse__ method could set the mime headers, etc and ship the data out via a str() method or such. In the above example, the method preceeds the virtual part of the URL, You can reverse the order and have many, many virtual URL components preceed the method, again, using __bobo_traverse__. I do this with my tabular data mining product I am working on.