Hi,
why you don't serve the PDF file directly with cherrypy?
For example, some as:
import cherrypy
expose()
def documentDisplay(self, *args, **kw):
documentId = args[0]
doc = Document.get(documentId)
resourceDir = cherrypy.config.get('motion.resourcedir')
fileName = '%sdocuments/%s' % (resourceDir, doc.documentName)
return cherrypy.lib.cptools.serveFile(fileName, "application/x-
download", "attachment", doc.documentName)
you can change the content-type and content-disposal as you want.
Leonardo
On Feb 2, 5:27 pm, Jim Steil <[email protected]> wrote:
> 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)
>
> Any thoughts on what I could do to debug this situation? Anyone else
> seeing this?
>
> tg-admin info
>
> TurboGears Complete Version Information
>
> TurboGears requires:
>
> * turbogears 1.0.4.4
> * turbokid 1.0.4
> * turbojson 1.1.2
> * turbocheetah 1.0
> * simplejson 1.8.1
> * setuptools 0.6c8
> * ruledispatch 0.5a0.dev-r2306
> * pastescript 1.6.3
> * formencode 1.0.1
> * decoratortools 1.7
> * configobj 4.5.2
> * cherrypy 2.3.0
> * kid 0.9.6
> * ruledispatch 0.5a0.dev-r2306
> * cheetah 2.0.1
> * pyprotocols 1.0a0
> * pastedeploy 1.3.2
> * paste 1.7.1
>
> Toolbox Gadgets
>
> * info (turbogears 1.0.4.4)
> * catwalk (turbogears 1.0.4.4)
> * shell (turbogears 1.0.4.4)
> * designer (turbogears 1.0.4.4)
> * widgets (turbogears 1.0.4.4)
> * admi18n (turbogears 1.0.4.4)
>
> Identity Providers
>
> * sqlobject (turbogears 1.0.4.4)
> * sqlalchemy (turbogears 1.0.4.4)
>
> tg-admin Commands
>
> * info (turbogears 1.0.4.4)
> * shell (turbogears 1.0.4.4)
> * quickstart (turbogears 1.0.4.4)
> * update (turbogears 1.0.4.4)
> * sql (turbogears 1.0.4.4)
> * i18n (turbogears 1.0.4.4)
> * toolbox (turbogears 1.0.4.4)
>
> Visit Managers
>
> * sqlobject (turbogears 1.0.4.4)
> * sqlalchemy (turbogears 1.0.4.4)
>
> Template Engines
>
> * kid (turbokid 1.0.4)
> * json (turbojson 1.1.2)
> * cheetah (turbocheetah 1.0)
> * genshi-markup (genshi 0.6dev-r888)
> * genshi-text (genshi 0.6dev-r888)
> * genshi (genshi 0.6dev-r888)
>
> Widget Packages
>
> * selectshuttle (select-shuttle 1.3.1)
>
> TurboGears Extensions
>
> * visit (turbogears 1.0.4.4)
> * identity (turbogears 1.0.4.4)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---