[Zope-dev] XMLRPCMethod product

Andrew M. Kuchling akuchlin@mems-exchange.org
Tue, 26 Oct 1999 14:41:18 -0400 (EDT)


In Amos's XML-RPC HOWTO, he writes:

   It would be an interesting project (hint, hint) to write an XML-RPC
   Method Zope Product that was smart about caching, etcetera. This
   would make XML-RPC available from DTML in a safe form.

I can take hints, and have a need for easier access to XML-RPC.  So,
what should an XMLRPCMethod look like?  

One idea is that it has a single property, the URL for an XML-RPC
server.  You would set this to http://othersite/zope/ or whatever.
Assuming your method was given an ID of 'rpcserv', you could then
write DTML like:

<!--Use the standard_html_header of another Zope site (!) -->
<dtml-var "rpcserv.standard_html_header()">  

<dtml-in "rpcserv.listUsers()">
  ...
</dtml-in>

This would be better named XMLRPCServer than *Method.

Alternatively, by analogy with ExternalMethods, an XML-RPC Method
could pin things down to a single method; you might create one for
listUsers() on a given server, another for standard_html_header() on
that site, etc.  I don't like this, because it means you may have lots
of different method objects, and when a server moves, a lot of
updating is required.  Too inflexible for my taste.

You could make updating server URLs easier by doing something similar
to DAs and SQLMethods, having XMLRPCMethods use a given XMLRPCServer
object, just as SQLMethods use a given database object.  This strikes
me as over-engineering the problem, though, resulting in two new
object types, and is still rather inflexible.

Caching is an interesting problem.  Who can know whether a given
XML-RPC method is returning relatively static data that's constant for
several hours, or transient data that changes a lot?  Only the XML-RPC
server, and maybe the caller, can know this.  I don't think a solution
is possible until XML-RPC supports some way to signal whether a
method's results are cacheable or not, so I don't think caching is
possible at this point in time.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Aristocrats need not be rich, but they must be free, and in the modern world
freedom grows rarer the more we prate about it.
    -- Robertson Davies, "Osbert Sitwell"