diff options
author | Mark Spruiell <mes@zeroc.com> | 2006-03-30 23:59:47 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2006-03-30 23:59:47 +0000 |
commit | ad25c1e684538ff594362aaf55c5ad89ff8a28eb (patch) | |
tree | 073343bf577790f74ec7cb800658fde1d5f97915 /py/modules/IcePy/Communicator.cpp | |
parent | minor edits (diff) | |
download | ice-ad25c1e684538ff594362aaf55c5ad89ff8a28eb.tar.bz2 ice-ad25c1e684538ff594362aaf55c5ad89ff8a28eb.tar.xz ice-ad25c1e684538ff594362aaf55c5ad89ff8a28eb.zip |
fixing setDefaultRouter/setDefaultLocator to accept None
Diffstat (limited to 'py/modules/IcePy/Communicator.cpp')
-rw-r--r-- | py/modules/IcePy/Communicator.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index 8dceecf0bf2..e83c46c4c31 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -838,25 +838,34 @@ extern "C" static PyObject* communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) { - PyObject* routerProxyType = lookupType("Ice.RouterPrx"); - assert(routerProxyType != NULL); PyObject* proxy; - if(!PyArg_ParseTuple(args, STRCAST("O!"), routerProxyType, &proxy)) + if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } - Ice::RouterPrx router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + PyObject* routerProxyType = lookupType("Ice.RouterPrx"); + assert(routerProxyType != NULL); + Ice::RouterPrx router; + if(PyObject_IsInstance(proxy, routerProxyType)) + { + router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + } + else if(proxy != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultRouter requires None or Ice.RouterPrx")); + return NULL; + } assert(self->communicator); try { - (*self->communicator)->setDefaultRouter(router); + (*self->communicator)->setDefaultRouter(router); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -898,25 +907,34 @@ extern "C" static PyObject* communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) { - PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); - assert(locatorProxyType != NULL); PyObject* proxy; - if(!PyArg_ParseTuple(args, STRCAST("O!"), locatorProxyType, &proxy)) + if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } - Ice::LocatorPrx locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); + PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); + assert(locatorProxyType != NULL); + Ice::LocatorPrx locator; + if(PyObject_IsInstance(proxy, locatorProxyType)) + { + locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); + } + else if(proxy != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultLocator requires None or Ice.LocatorPrx")); + return NULL; + } assert(self->communicator); try { - (*self->communicator)->setDefaultLocator(locator); + (*self->communicator)->setDefaultLocator(locator); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); |