[Zope-dev] XMLRPCMethod product

Ben Leslie benno@sesgroup.net
Wed, 27 Oct 1999 19:49:04 +1000


> 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>



OK, I've also needed something todo this and gone ahead and created somthing
that works for me.

It may or may not work for other, it may be a base for anyone that wants to
extend/change it.

If you are interested http://www.zope.org/Members/Benno/XMLRPCClient

It is still very much development at the moment. This basically just gives
you an XML Server objectwhich you can place anywhere in Zope and then use
it as follows

<dtml-var "some_server('multiply', 3, 4)">

Obviously this is a bit of a forced example.


I would prefer the syntax <dtml-var "some_server.multiply(3, 4)"> but
I have had problem overriding __getattr__ so I'll stick to the former for
the moment.


You can also use it just as easily to retrieve a struct over XML-RPC

eg:

<dtml-let x="some_server('ages')">
<dtml-in "x.keys()">
<dtml-let seq=sequence-item>
<dtml-var sequence-item> is <dtml-var "x[seq]"> years old<br>
</dtml-let>
</dtml-in>
</dtml-let>


or just get a specific entry:


<dtml-var "someserver('ages')['Ben']">



It should also work on arrays by using <dtml-in> on the result.


If you actually want to test it on a server you can try:

http://www.sesgroup.net:9080

where any of the above examples *should* work.


I'm not sure that this would be the prefereed syntax for all people
however it seems the most logical to my little brain so I'm going 
with it for the moment until a can get __getattr__ working properly.

It does seem a bit overkill having the XMLRPC server as an entire
object however you basically have the same type of thing with 
mailhost at the moment as well.


Any comments gratefully accepted.


Benno