koranthala wrote: > Hi, > I am doing web development using Django. I need to create an image > (chart) and show it to the users - based on some data which user > selects. > My question is - how do I create a temporary image for the user? I > thought of tempfile, but I think it will be deleted once the process > is done - which would happen by the time user starts seeing the image.
What makes you think that? You are the one creating it, you are responsible for deleting it. > I can think of no other option other than to have another script which > will delete all images based on time of creation. > Since python is extensively used for web development, I guess this > should be an usual scenario for many people here. How do you usually > handle this? There are various solutions - tempfiles, files based on a criteria (e.g. username and image-properties) so that they don't pollute the harddrive. For both approaches cleaning up as you suggest might be needed. Alternatively, if you use sessions, you can use memory-cached images. Or you can use the database. But the cleaning-up might get necessary here as well. The cleanest solution would be if the image would be rendered on the fly, based on GET-parameters (or REST-ful urls) so that you can render it into memory as string, but then forget immediately about it. Diez -- http://mail.python.org/mailman/listinfo/python-list