J Cameron Cooper wrote:
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()
So, I put the code here. Please, what I'm missing? :)
def gerarTCE(self, id_tce, cnpj_escola='', matricula=''):
from reportlab.lib.colors import Color
from reportlab.lib.pagesizes import letter
from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox
from reportlab.lib.styles import ParagraphStyle
from reportlab.pdfgen import canvas
import os
import urllib
from reportlab.lib.units import inch, cm
import time
import string_linha = cm / 2.25 _fname = "tce"+id_tce+".pdf" _c = canvas.Canvas(_fname, pagesize=letter) _width, _height = letter _aW = _width - 2 * cm _aH = 750
_c.bookmarkPage("TCE")
_c.bookmarkPage("pagina1")
_c.addOutlineEntry("TCE", "TCE")
_c.addOutlineEntry("Pagina 1", "pagina1", 1)
_c.showOutline()
_c.setAuthor("NUBE - N�cleo Brasileiro de Est�gios")
_c.scale(1, 0.9)_c.setFont("Times-Bold", 16)
_c.drawCentredString(_width / 2, 735, "TERMO ADITIVO")
_c.setFont("Times-Roman", 9)
_c.drawCentredString( _width / 2, 735, "(determina��es legais estabelecidas no art. 5� e o �1� do art. 6� do Decreto 87.497/82 que regulamentou a Lei 6.494/77)")
_c.drawCentredString( _width / 2, 725, "(Atualizada pela Medida Provis�ria N.� 1952-22 de 30/03/2000)")
_c.showPage()
_c.save()
R = self.REQUEST.RESPONSE
R.setHeader('content-type', 'application/pdf')
R.Header('content-length', str(len(_fname)))
R.write(_fname)
_______________________________________________
Zope maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )
