[Zope] External Method - "context" arg

Marty Stitt marty.stitt@esker.com
Thu, 15 Feb 2001 07:49:45 -0600


Tom Sheffler wrote:
> The Zope book chapter "Advanced Zope Scripting" shows a method with
> an arg list like this:
> 
>    def makeThumbnail(context, original_id, size=128):
> 
> When I create a method with the "context" arg, Zope complains
> that the parameter "context" was omitted from the request.
> 
> THE REAL QUESTION:::
> 
> Using a Python Method, it's easy to get the variables
> "context"  and "travers_subpath."  How do I get these two
> values when using an External Method.
> 
> Thanks for any assistance.
> Tom

 
Here's how I've been able to get external methods to work:

  def SomeExternalMethod(self, PARMS):
  
    try: relativePathSpec = PARMS['relativePathSpec']
    except: return ("FAIL", "missing parm: relativePathSpec")
    try: fileName = PARMS['fileName']
    except: return ("FAIL", "missing parm: fileName")

    .....

    return ("OK", theDataOfInterest)



Within the body of the method, if you need to access the passed in
parameters, they're in the PARMS dictionary.  If you want to get at
things in the REQUEST collection, use this form:

  self.REQUEST


Here's how I would call this method:

  someObject.SomeExternalMethod({'relativePathSpec':'x/y/z',
'fileName':'abc.txt'})


Hope this helps.


There's also:

  http://www.zope.org/Documentation/How-To/ExternalMethods


-- 
Martin Stitt
Chief Software Engineer
Esker, Inc.
email: marty.stitt@esker.com
phone: (608) 273-6000 x331
fax:   (608) 273-8227
web:   http://www.esker.com