Hello,
le 02.02.2009 17:27 Jim Steil a écrit:
> Hi
>
> I use the following code to display PDF files. This has worked for me
> for a couple years. All of a sudden, this stopped working for some of
> our PDFs. Some display correctly, but some do not. This happens only
> on my production box (Win 2003), but works fine on my test/dvlp
> environment (WinXP). I don't even know where to begin trying to debug
> this. No errors are thrown. In the browser, it's as if the document
> displayed, but it really didn't. The title has changed to the one that
> should be displayed, but the page never changes. It is not still
> processing, but just seems to have forgotten to display the PDF. This
> is happening on all clients trying to connect, whether using IE or
> Firefox.
>
> def documentDisplay(self, *args, **kw):
> documentId = args[0]
> doc = Document.get(documentId)
>
> pdfFile = StringIO.StringIO()
> resourceDir = cherrypy.config.get('motion.resourcedir')
> f = open('%sdocuments/%s' % (resourceDir, doc.documentName), 'rb')
>
> while 1:
> data = f.read(1024*8)
> if not data:break
> pdfFile.write(data)
> f.close()
>
> pdf = pdfFile.getvalue()
> pdfFile.close()
>
> return(pdf)
>
>
You could first check the length of the 'pdf' variable... Is it coherent
with the actual length of the file ?
Are you PDFs static or generated dynamically on the fly just before
displaying them. In that case it could be a "flush" issue of the
generated file not closed (so not flushed) to the disk while you try to
read it.
And I was just wondering why you use a StringIO and not directly
pdf = f.read()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---