[Soap-Python] How to create ComplexModel data?
KenWhitesell at comcast.net
KenWhitesell at comcast.net
Thu Apr 26 18:37:14 CEST 2012
Newbie to SOAP / RPC / rpclib - trying to understand how the different pieces fit together to generate a response.
I've been playing with the "User Manager" example, and I'm trying to extend it by adding a method that will randomly generate a User _on the server_, and add that to the user database. (I'm referring to the simple example, server_basic.py)
In the code there is this object User, defined as:
class User(ComplexModel):
__namespace__ = 'rpclib.examples.user_manager'
user_id = Integer
user_name = String
first_name = String
last_name = String
permissions = Array(Permission)
Now, what _I_ want to do is create a server-side method (lets call it "make_user"), that will create an instance of User with a random data, and return it to the caller. (I know how to generate the random data, that's not the issue.)
So far, I think I need to add a method to UserManagerService that would look something like this:
@rpc(_returns=User)
def make_user(ctx):
return ?????
What I can't see is how I create an instance of User _and_ populate the various fields with the data that I want in it - and the sample doesn't appear to me to cover that case - it assumes that all Users come to it from the client.
Help please?
Thanks,
Ken
More information about the Soap
mailing list