Zope htmldoc python scripts

Pete Pete at nospam.com
Wed Feb 5 06:36:48 CET 2003


Hello,

I'm running zope using htmldoc however when I pass zope a URL that is a
python script,
it ignores it and renders html out instead of PDF.


I installed htmldoc and followed the instructions at
http://www.zope.org/Members/mjablonski/howtoPDF

eg,

test1 is a DTML document
test2 is a PYTHON script

http://svr/test1/html2pdf  -> renders PDF
http://svr/test2/html2pdf     -> renders HTML

Whats the problem with python scripts?
heres the python code for html2pdf extension

 # HTML2PDF - converts HTML to PDF
    # Needs 'htmldoc' from Easy Software Products
    # Send comments to maik.jablonski at uni-bielefeld.de

    import AccessControl, os

    def html2pdf(self):
        """ html2pdf converts a HTML-Page to a PDF-Document """

        securityContext=AccessControl.getSecurityManager()

        if securityContext.checkPermission('View', self):

                if self.meta_type=='Folder':
                        html =
self.index_html(self,self.REQUEST,self.REQUEST.RESPONSE)
                else:
                        html = self(self,self.REQUEST,self.REQUEST.RESPONSE)

                (stin,stout) = os.popen2('htmldoc --footer " :
" --webpage -t pdf --quiet --jpeg -')
                stin.write(html)
                stin.close()
                pdf = stout.read()
                stout.close()


self.REQUEST.RESPONSE.setHeader('Content-type','application/pdf')

self.REQUEST.RESPONSE.setHeader('Content-disposition','inline;
filename="%s.pdf"' % (self.getId()))

                return pdf

        else:
                raise AccessControl.Unauthorized


Cheers






More information about the Python-list mailing list