[reportlab-users] Building/Storing PDF's in memory

Adrian Klaver adrian.klaver at gmail.com
Thu Dec 27 10:57:16 EST 2012


On 12/27/2012 07:47 AM, J. R. Carroll wrote:

> I have not! Thank you, I'll look into that. (I've not attempted to

> this before, so I'm trying to find the right tools).

>

> Do you know if tempfile builds in memory, or does it just temp write to

> the disk (and then is responsible for deleting the data)? Only asking

> because I've never used tempfile before either and I'm curious to know

> if that is a potential solution as well - I have no affinity one way or

> the other.

>


I have not used tempfile, all I can offer is the docs:

http://docs.python.org/2/library/tempfile.html#module-tempfile

Whether the file is written:

"tempfile.tempdir

If tempdir is unset or None at any call to any of the above functions,
Python searches a standard list of directories and sets tempdir to the
first one which the calling user can create files in. The list is:

The directory named by the TMPDIR environment variable.
The directory named by the TEMP environment variable.
The directory named by the TMP environment variable.
A platform-specific location:
On RiscOS, the directory named by the Wimp$ScrapDir environment variable.
On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order.
On all other platforms, the directories /tmp, /var/tmp, and /usr/tmp, in
that order.
As a last resort, the current working directory."

I guess one could set up a ramdisk and point tempfile.tempdisk there if
you wanted it in memory:)


As to clean up, that is dependent on what function you use to write the
file:

Example:

"tempfile.mkstemp

Unlike TemporaryFile(), the user of mkstemp() is responsible for
deleting the temporary file when done with it."


--
Adrian Klaver
adrian.klaver at gmail.com


More information about the reportlab-users mailing list