dynamically generating temporary files through python/cgi

Jaime Wyant programmer.py at gmail.com
Thu Apr 28 08:45:37 EDT 2005


On 27 Apr 2005 23:32:15 -0700, poisondart <poisondart985 at gmail.com> wrote:
> Is there a way to dynamically generate temporary files (such as an
> html, xml or text file) in Python?
> 
> I'm not sure if I'm explaining myself clearly as I've no clue how to
> describe this mechanism. I've seen it on certain websites that will
> generate a file under certain parameters (through forms) that will
> dissapear (i.e. delete itself) after a specified amount of time. These
> files usually have some phony string for their filenames...like it's
> been md5 hashed or something.
> 
> Is there a group of library functions that allow this? I imagine that
> if i manually go and allocate a bunch of timers to monitor files, it
> would be really expensive in load. Or perhaps is this a client-side
> mechanism?

I think the best way to do that is have a web page that generates the
files with random filenames.  These files probably ought to reside in
their own special directory.  This web page gives the user a link to
the filename.

Next, have a cron job kick off every 5 minutes or so that deletes any
files that are older than 'X' minutes.  This seems to be the simplest
approach.

jw



More information about the Python-list mailing list