Hi,

I was having a look at Phillipp's fabulous book (thanks!), and came across the code for publishing a PDF document to the browser (this is slightly modified from the book):

from zope.app import zapi
from zope.app.publisher.browser import BrowserView

from ccard.pdf.interfaces import IPDFPresentation

class PDFView(BrowserView):

 def __call__(self):
pdf = zapi.getViewProviding(self.context, IPDFPresentation, self.request)
   filename = zapi.name(self.context) + '.pdf'
   response = self.request.response
response.setHeader('Context-Disposition', 'attachment; filename=%s' % filena
me)
   response.setHeader('Content=Type', 'application/pdf')
   response.setHeader('Content-Length', len(pdf.data))
   response.write(pdf.data)

However, these days I get the error:

2005-12-28T15:29:56 ERROR SiteError http://localhost:8080/++skin++Boston/t2/Cred
itCard/pdf
Traceback (most recent call last):
File "/home/Adam/z3/Zope3/src/zope/publisher/publish.py", line 138, in publish
   result = publication.callObject(request, object)
File "/home/Adam/z3/Zope3/src/zope/app/publication/zopepublication.py", line 1
61, in callObject
   return mapply(ob, request.getPositionalArguments(), request)
File "/home/Adam/z3/Zope3/src/zope/publisher/publish.py", line 113, in mapply
   return debug_call(object, args)
File "/home/Adam/z3/Zope3/src/zope/publisher/publish.py", line 119, in debug_c
all
   return object(*args)
 File "/home/Adam/z3/products/ccard/pdf/browser.py", line 15, in __call__
   response.write(pdf.data)
AttributeError: 'BrowserResponse' object has no attribute 'write'

What is the correct technique, now that BrowserResponse does not have write()

TIA, and Happy New Year
Adam



_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to