[Zope] External http access.

Small Business Services toolkit at magma.ca
Thu Jun 10 07:52:15 EDT 2004


From: "Ben Last (Zope)" <zope at benlast.com>
> > From: Small Business Services [mailto:toolkit at magma.ca]
> > We do this quite a lot.
> Thanks Jonathan, that sounds like a very useful set of scripts - are you
> able to post any examples?

The dtml methods/python scripts are standard, other than the removal of any
use of html (eg. no <html> <body> tags or anything that sets html tags, such
as standard_html_header/footer or standard_error_message.

Here is an example of some python code to trap errors (from an external
method):

import sys, traceback

def somefunc(self):
        try:
                <your code here>
        except:
                etype = sys.exc_info()[0]
                evalue = sys.exc_info()[1]
                etb = traceback.extract_tb(sys.exc_info()[2])
                return str([etype, evalue, etb])

If an error is encountered this returns a string version of the list
containing the relevant error info. The dtml method that calls this routine
would have a simple statement:

<dtml-var somefunc>

In the case of an error a string would be returned to the calling http
routine which contains the error info (the calling http routine would need
to parse the string to get at the error list items).

We use cURL from either perl or C++ routines (you can use a command line
call to cURL or the cURL C++ library routines), so  I don't know if code
examples from these would be of any use.

HTH

Jonathan










More information about the Zope mailing list