[Zope] RE: Reportlab and Zope

Jorge Magalhaes jmagalhaes@eng.uminho.pt
Wed, 05 Jul 2000 23:14:50 +0100 (WET)


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'

How i can fix it?

Have a nice day

Jorge