I have built an XML-RPC interface in Python and I need to enforce some stricter typing. For example, passing string ’10’ instead of int 10. I can clean this up with some type casting and a little exception handling, but I am wondering if there is any other way of forcing type integrity such as something XML-RPC specific, a decorator, or something else.
Share
XML-RPC methods (at least in
xmlrpclib) are dispatched to Python functions or method, so you have to enforce type checking in them. There is a lot of recipes on doing this task with decorators: Type Enforcement (accepts/returns), typecheck module.Note, that
xmlrpcliblacks proper error handling, so you probably would like to implement your own.