Dynamic files

Ernesto Adorio <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
How do you serve a 'dynamic' file where the filename 
is not known at application start? I have tried 

class MainDirectory(Directory):
   _q_exports = ["", ..... ]

   def _q_index(self):
       if not hasattr(self, str("dynamicfiles")):
          self.dynamicfiles = []
	  # Entries are of the form (urlname, fullpathfilename)
	  # Deletion of entries done by other routines

   def _q_lookup [html] (self, component):
        print "@@@ component = ", str(component)

        for (urlname, filename)  in self.dynamicfiles:
	    print "@@@ filename = ", filename
	    if str(component) == urlname:
	       return StaticFile(filename)()
	       
    def dynamicfile(self, urlname, fullpathfilename):
        print "@@@ appending dynamic file"
	if not hasattr(self, str("dynamicfiles")):
	   self.dynamicfiles = []
        self.dynamicfiles.append((urlname, fullpathfilename))
	print "@@@ redirecting ", str(get_path(1)) + urlname
	redirect(str(get_path(1)) + str("/") + urlname)

This only handle urlname  without a "/". One can write _q_traverse()
for handling this case.  The urlname is mapped to the fullpathfilename.
I don't know if the code is reliable.

Ernie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.