[reportlab-users] registerFont stays how long in memory? what s the best place to register a font?
Robin Becker
robin at reportlab.com
Tue Apr 20 05:27:29 EDT 2010
On 19/04/2010 18:59, Thomas Kremmel wrote:
> We changed back to mod_python and it worked for two days and now I do occur
> another error which is:
>
>
>
> File "/usr/lib/python2.6/dist-packages/reportlab/lib/utils.py", line 452,
> in open_for_read
>
> raise IOError('Cannot open resource "%s"' % name)
>
>
>
> IOError: Cannot open resource
> "/var/www/mydoamint/libs/reportlab/fonts/DarkGardenMK.afm"
>
> Which is pretty strange since this error is new, the file is available and I
> did not changed anything in the meantime. File is world-readable and I have
> no clue why it could not be read from one minute to the other.
> I ' m thinking of that the calibri font that I'm using is maybe damaged. Is
> this a possible source of problems? I do not know anything about fonts but
> it seems to me as if this could be the problem..
> Still it is strange that it sometimes work and sometimes it does not..er e
>..........
I think we've had this kind of error before, but it is related to the search
for a font. Andy's original code tries to locate an afm which has the right name
internally; along the way it may attempt to search along the T1 search paths and
open afms to see if they match the required resource. It could be that the
mod_python user doesn't have access to the font above in the reportlab fonts folder.
I think the real problem is mod_python; back in November we had a similar error
which I posted about in comp.lang.python
> A reportlab user running via mod_python+django (Python 2.5.2 and mod_python
> 3.3.1) reports a strange intermittent error involving failure to read files
> which are known to be present.
>
> After some debugging efforts we got this clearer error message
>
>
> File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line 810,
> in dump
> f = open(self.fn,'wb')
>
> IOError: file() constructor not accessible in restricted mode
>
> this is not the original error, but part of our efforts to debug; however, the
> original error was during an attempt to read a file so presumably open was not
> available there.
>
> Googling the error indicates something to do with restricted
> environments/mod_python+threads.
>
> I thought that restricted mode died ages ago.
>
> Any ideas what could be causing this?
> --
> Robin Becker
the clearer error message appears to indicate that somehow the mod_python
process has switched into something called 'restricted mode'; once there all
bets are off and really strange things can happen like open not being available.
I don't think we ever saw this ourselves running mod_python in a single use
environment, but mod_python certainly seems to be at risk from cross app
problems etc etc.
--
Robin Becker
More information about the reportlab-users
mailing list