On Wed, Mar 13, 2002 at 01:53:13PM -0500, Greg Ward wrote: >I'm not clear on what the custom code is here. Is what the code in the >function whose name is stored in 'method'? Correct. When you do an XML-RPC call, you use a single fixed URL (usually http://.../RPC2) and the method name and parameters are POSTed to that URL. Maybe the grovelling around in locals is too cute. What if I just included my rpc() function, that unmarshals the arguments, calls rpc_process(), and checks for uncaught exceptions? Then the user would have to write a function with the signature rpc_process(method_name, params). rpc_process() would then almost always look something like this: def rpc_process (method_name, params): if method_name == 'login': user_id, password = params return login_func(user_id, password) elif method_name == 'method2': ... elif ... Boring code, and people might write 200-line rpc_process() functions containing the code for all of their methods, but that's not our problem. Or they can write a smart rpc_process() that uses a dictionary or grovels through locals, or whatever, and it's also not our problem. I think I like this idea. >I have to believe there's a nice OO design waiting to jump out at you -- >surely you can get away without having to grovel through some other >scope's locals() -- yecchh. OO seems like overkill to handle just a list of methods and their parameters. I suppose we could use classes for this, like so: class MyXMLRPCStuff(XMLRPCHandler): _q_exports = ['login', ...] def login (self, user_id, password): return ... def ... RPC2 = MyXMLRPCStuff() But 'self' doesn't contribute anything useful; the MyXMLRPCStuff instance doesn't contain any information of interest. --amk (www.amk.ca) We of Faerie are of the wild magic. We are not creatures of spells and grimoires. We *are* spells, and we are written of in grimoires. -- From SANDMAN #52: "Cluracan's Tale"