[Zope] Programmatic creation/update of ZSQL methods

Dieter Maurer dieter@handshake.de
Sat, 2 Nov 2002 23:56:48 +0100


Charlie Reiman writes:
 >   srv = xmlrpclib.Server("http://srvr/test/manage_addProduct/ZSQLMethods",
 >                          transport = BasicAuthTransport(username="xxx",
 >                                                         password="yyyy"))
 >   err= srv.manage_addZSQLMethod('amethod', 'atitle' 'zfly', 'one two',
 >                          'select sysdate from dual', 'xxx')
 > 
 > I'm still not sure what to invoke on srv. The above is as close as I have
 > come. It does create an object but it issues a 302 error response and the
 > object has incorrect paramters.
The first problem (302 redirect) is easily explained:

  "manage_addZSQLMethod" is a management function that tries to
  give you a result page using "redirect". It was not conceived
  to be used by XML-Rpc.

  The easiest way is to provide a wrapper around this function,
  that calls "manage_addZSQLMethod" without "REQUEST"
  and returns success information more appropriate for XML-RPC.

The second problem (wrong parameters) is more difficult (as you
do not provide enough info on how the parameters are wrong):

  Are you sure, you provide the parameters in the correct order?

  In what way are the parameters of the created object wrong?


 > I'm pretty certain that this is not the
 > right method to invoke (as it will expect an ObjectManager as the first
 > parameter, which I can't really pass across xmlrpc and it's designed for TTW
 > creation).
The "self" should be implicitely passed. In fact, it is (in your case) not
an "ObjectManager" but a so called "Product Dispatcher" created
by "manage_addProduct". It creates the object in its parent,
an "ObjectManager".

 > However, I was unable to invoke the SQL constructor which is what
 > I think I need as that's what manage_addZSQLMethod calls.
Go for a PythonScript wrapper:

   createZSQLMethod:
     Parameters: as needed

     Body:

       context.manage_addProduct[...].manage_addZSQLMethod(parameters)
       return 1



Dieter