[Zope] RE: Reportlab and Zope
Rik Hoekstra
rik.hoekstra@inghist.nl
Thu, 6 Jul 2000 09:34:33 +0200
-----Original Message-----
From: Jorge Magalhaes <root@predict.telepac.pt>
To: zope@zope.org <zope@zope.org>
Date: donderdag 6 juli 2000 0:15
Subject: [Zope] RE: Reportlab and Zope
>
>In my last post i search for help concerning to the use of the libs
Reportlab in to Zope environment. I make some research in Reportlab mailing
list and Osmin Lazo (Canada) suggests my to use the following buffer class
>
>########################
># Buffer Class
>########################
>class buffer:
>
> def __init__(self):
> self._buffer = []
> self._size = 0
>
> def write(self,line):
> self._buffer.append(str(line))
>
> def read(self):
> data = string.join(self._buffer, '')
> return data
>
> def tell(self):
> return len(self._buffer)
>
>My fistreportlabinzope.py is:
>
>#############################
># firstreportlabinzope.py
>##############################
>
>import string
>from reportlab.pdfgen.canvas import Canvas
>from reportlab.lib.pagesizes import A3, landscape
>from reportlab.pdfgen.textobject import PDFTextObject
>from types import *
>
>class buffer:
>
> def __init__(self):
> self._buffer = []
> self._size = 0
>
> def write(self,line):
> self._buffer.append(str(line))
>
> def read(self):
> data = string.join(self._buffer, '')
> return data
>
> def tell(self):
> return len(self._buffer)
>
>stream = buffer()
>c = Canvas(stream, pagesize=landscape(A3), bottomup=0)
>c.setFont("Times-Roman", 12.0, leading=10.0)
>c.drawString(100,100, "Hello World")
>c.showPage()
>c.save()
>tempfile=open("helloworld.pdf","wb")
>tempfile.write(stream.read())
>temfile.close()
>
>########################3
>
>My main problem is:
>
> When i tried to add the External method i have the following error
message:
>
> IOERROR: [Errno 13] Permission Denied 'helloworld.pdf'
this seems to be a filesystem problem rather than a Zope one- what OS are
you on? Are the permissions for the directory set right (Zope runs as nobody
on Unix I think)
One more small suggestion - the last line of your method has a typo
>temfile.close()
I might want to change it to
>tempfile.close()
Rik