[Zope] Generating and Downloading PDF.

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


Fernando Lujan wrote:
> J Cameron Cooper wrote:
> 
>> 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.
> 
> OK, thanks. But how can I pass the self parameter using the dtml-call 
> tag? <dtml-call "pdfwrite(self)"> is correct? Because I'm using this and 
> works fine.

It's Python magic. When you call a function/method on an object, the 
object is provided as the first parameter of the method. This is 
implicit, I believe, in DTML calls, either expression or name. It's 
explicit in TALES and Python::

    context/pdfwrite
    context.pdfwrite()

It's different than many other languages, but it turns out to be pretty 
useful.

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


More information about the Zope mailing list