[Zope] Generating and Downloading PDF.

J Cameron Cooper zope-l at jcameroncooper.com
Wed Apr 27 15:05:07 EDT 2005


Fernando Lujan wrote:
> Hi guys,
> 
> I'm creating a pdf using reportlab, after the canvas.close()
> 
> I put the following code inside a External Method:
> 
> R = self.REQUEST.RESPONSE
> R.setHeader('content-type', 'application/rtf')
> R.setHeader('content-length', str(len(data)))
> R.write(data)
> 
> But I receive the following error:
> 
> *Error Type: NameError*
> *Error Value: global name 'self' is not defined
> 
> Is there some import wich I have been missing?

The method that contains your code must have at least the first 
parameter 'self'::

   def pdfwrite(self):
     R = self.REQUEST.RESPONSE
     R.setHeader('content-type', 'application/rtf')
     R.setHeader('content-length', str(len(data)))
     R.write(data)

It's a way of getting access to context.

		--jcc
-- 
http://plonebook.packtpub.com/


More information about the Zope mailing list