List Info

Thread: Bug with modpywrapper




Bug with modpywrapper
country flaguser name
United States
2007-06-06 14:52:38

Hi all.

I've found a minor bug when using the modpywrapper. If you request a
methodthat does not exist, then ModPyServiceHandler raises a
ServiceImplementaionNotFound exception (that's misspelled, btw):

if not os.path.exists(os.path.join(modulePath, moduleName + ".py")):
raise ServiceImplementaionNotFound()

This method is called from ServiceHandler, which handles the exception
by translating the error like so:

def translateResult(self, rslt, err, id_):
if err != None:
err = {"name": err.__class__.__name__, "message":err.message}
rslt = None

Above, err is an instance of ServiceImplementaionNotFound, which does
not have a message property. So, when the err dictionary is built, or
attempted to be built, you get an AttributeError:

PythonHandler jsonrpc: AttributeError:
ServiceImplementaionNotFound instance has no attribute 'message'

Anyway, this is how I fixed it locally. Y'all can fix it however
y'all see fit...

[jwyantl-jwyant:python-jsonrpc]$ svn diff jsonrpc/modpywrapper.py
Index: jsonrpc/modpywrapper.py
===================================================================
--- jsonrpc/modpywrapper.py (revision 17)
+;++ jsonrpc/modpywrapper.py (working copy)
-19,7 +19,9
(moduleName, ext) = os.path.splitext(fileName)

if not os.path.exists(os.path.join(modulePath, moduleName +
".py")):
- raise ServiceImplementaionNotFound()
+ e = ServiceImplementaionNotFound()
+ e.message = "Service %s could not be found." % name
+ raise e
else:
if not modulePath in sys.path:
sys.path.insert(0, modulePath)

Good day!
jw

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )