classification
Title: Option for XMLRPC clients to automatically transform Fault exceptions into standard exceptions
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, ezio.melotti, flox, loewis, rhettinger
Priority: low Keywords:

Created on 2011-11-13 21:00 by rhettinger, last changed 2011-11-19 13:32 by ezio.melotti.

Messages (1)
msg147572 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-11-13 21:00
Currently, an XMLRPC client communicating with a server running Python can make Python style calls but exceptions get collapsed into a standard FaultException making it difficult to program in a Pythonic style:

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
try:
    value = proxy.lookup('somekey')
except xmlrpc.client.Fault as err:
    if err.faultCode == 1 and 'KeyError' in err.faultString:
        k = re.search(r":.(\w+)' not found$", err.faultString).groups(1)
        raise KeyError(k)
 
It would be better if we could do this automatically (search for a pure python exception of the same name and raise it instead of a Fault):

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/", python_exceptions=True)

try:
   value = proxy.lookup('somekey')
except KeyError as e:
   ...
History
Date User Action Args
2011-11-19 13:32:04ezio.melottisetnosy: + ezio.melotti

stage: needs patch
2011-11-18 17:20:13eric.araujosetnosy: + eric.araujo
2011-11-13 21:04:53pitrousetnosy: + loewis, flox
2011-11-13 21:00:47rhettingersetpriority: normal -> low
components: + Library (Lib)
2011-11-13 21:00:28rhettingercreate