[Zope] Passing Parameters to External Methods

Asad Habib ahabib at engin.umich.edu
Wed Nov 16 09:30:22 EST 2005


Hello. I am trying to use the Python version of the PHP script written by 
Jason Rust called 'HTML_ToPDF.php'. I have represented this script using 
an External Method since it uses functions, such as open, which cannot be 
used in Zope Python scripts for security reasons. The python code for the 
script consists of a class definition and so I have had to create a python 
function which instantiates an object of this class. However, I am having 
toruble passing parameters to this function which are needed by the 
class constructor to instantiate an object of this class. Can parameters 
be passed to external methods? Whenever I try to pass parameters to 
function 'createHtmlToPdf', Zope returns an error stating that no such 
function exists. Other on the hand, if I pass no parameters this call is 
successful but the init function fails complaining that three parameters 
are expected. I have provided a snippet of my code below. Any help would 
be greatly appreciated. Thanks.

- Asad



def createHtmlToPdf(in_htmlFile, in_domain, in_pdfFile):
    return html2pdf(in_htmlFile, in_domain, in_pdfFile)

# This is based on a php script (c) Jason Rust <jrust at rustyparts.com>
# See that script for licensing
# Convert an HTML file to a PDF file using html2ps and ps2pdf

from tempfile import gettempdir, mkstemp
import os
import re
from re import IGNORECASE, DOTALL
from copy import copy

class html2pdf:
   def __init__(self, in_htmlFile, in_domain, in_pdfFile = None):
     """Constructor

     in_htmlFile The full path to the html file to convert
     in_domain The default domain name for images that have a relative path
     in_pdfFile (optional) The full path to the pdf file to output. If not 
given then we create a temporary name.
     """


More information about the Zope mailing list