dynamically generating temporary files through python/cgi
Tiziano Bettio
tbettio at transnorm.ch
Thu Apr 28 11:10:08 EDT 2005
poisondart 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?
>
>Thanks,
>- poisondart
>
>
>
hi there
first of you could use the tempfile
import tempfile
tempfile.mktemp('.thefileendingudlike')
i never really studied the cgi capability of python but for example in
php there is the posibility to serve a request with a mime formated
response such as html, gif, pdf, and so on. so if u want to generate
content dynamically u wouldn't need to store those files but generate
and send em on request without having to destroy them later on..
hope this is helpful
cheers
tc
More information about the Python-list
mailing list