summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'py/modules/IcePy/Connection.cpp')
-rw-r--r--py/modules/IcePy/Connection.cpp94
1 files changed, 77 insertions, 17 deletions
diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp
index 17ba5672a9e..a6fc415b761 100644
--- a/py/modules/IcePy/Connection.cpp
+++ b/py/modules/IcePy/Connection.cpp
@@ -11,6 +11,7 @@
# include <IceUtil/Config.h>
#endif
#include <Connection.h>
+#include <ObjectAdapter.h>
#include <Proxy.h>
#include <Util.h>
#include <Ice/Connection.h>
@@ -90,12 +91,27 @@ connectionClose(ConnectionObject* self, PyObject* args)
extern "C"
#endif
static PyObject*
-connectionFlushBatchRequests(ConnectionObject* self)
+connectionCreateProxy(ConnectionObject* self, PyObject* args)
{
+ PyObject* identityType = lookupType("Ice.Identity");
+ PyObject* id;
+ if(!PyArg_ParseTuple(args, "O!", identityType, &id))
+ {
+ return NULL;
+ }
+
+ Ice::Identity ident;
+ if(!getIdentity(id, ident))
+ {
+ return NULL;
+ }
+
assert(self->connection);
+ assert(self->communicator);
+ Ice::ObjectPrx proxy;
try
{
- (*self->connection)->flushBatchRequests();
+ proxy = (*self->connection)->createProxy(ident);
}
catch(const Ice::Exception& ex)
{
@@ -103,35 +119,74 @@ connectionFlushBatchRequests(ConnectionObject* self)
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ return createProxy(proxy, (*self->communicator));
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-connectionCreateProxy(ConnectionObject* self, PyObject* args)
+connectionSetAdapter(ConnectionObject* self, PyObject* args)
{
- PyObject* identityType = lookupType("Ice.Identity");
- PyObject* id;
- if(!PyArg_ParseTuple(args, "O!", identityType, &id))
+ PyObject* adapterType = lookupType("Ice.ObjectAdapter");
+ PyObject* adapter;
+ if(!PyArg_ParseTuple(args, "O!", adapterType, &adapter))
{
- return NULL;
+ return NULL;
}
- Ice::Identity ident;
- if(!getIdentity(id, ident))
+ Ice::ObjectAdapterPtr oa = unwrapObjectAdapter(adapter);
+ assert(oa);
+
+ assert(self->connection);
+ assert(self->communicator);
+ try
{
- return NULL;
+ (*self->connection)->setAdapter(oa);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return NULL;
}
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+connectionGetAdapter(ConnectionObject* self)
+{
+ Ice::ObjectAdapterPtr adapter;
+
assert(self->connection);
assert(self->communicator);
- Ice::ObjectPrx proxy;
try
{
- proxy = (*self->connection)->createProxy(ident);
+ adapter = (*self->connection)->getAdapter();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return NULL;
+ }
+
+ return wrapObjectAdapter(adapter);
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+connectionFlushBatchRequests(ConnectionObject* self)
+{
+ assert(self->connection);
+ try
+ {
+ (*self->connection)->flushBatchRequests();
}
catch(const Ice::Exception& ex)
{
@@ -139,7 +194,8 @@ connectionCreateProxy(ConnectionObject* self, PyObject* args)
return NULL;
}
- return createProxy(proxy, (*self->communicator));
+ Py_INCREF(Py_None);
+ return Py_None;
}
#ifdef WIN32
@@ -209,10 +265,14 @@ static PyMethodDef ConnectionMethods[] =
{
{ "close", (PyCFunction)connectionClose, METH_VARARGS,
PyDoc_STR("close(bool) -> None") },
- { "flushBatchRequests", (PyCFunction)connectionFlushBatchRequests, METH_NOARGS,
- PyDoc_STR("flushBatchRequests() -> None") },
{ "createProxy", (PyCFunction)connectionCreateProxy, METH_VARARGS,
PyDoc_STR("createProxy(Ice.Identity) -> Ice.ObjectPrx") },
+ { "setAdapter", (PyCFunction)connectionSetAdapter, METH_VARARGS,
+ PyDoc_STR("setAdapter(Ice.ObjectAdapter) -> None") },
+ { "getAdapter", (PyCFunction)connectionGetAdapter, METH_NOARGS,
+ PyDoc_STR("getAdapter() -> Ice.ObjectAdapter") },
+ { "flushBatchRequests", (PyCFunction)connectionFlushBatchRequests, METH_NOARGS,
+ PyDoc_STR("flushBatchRequests() -> None") },
{ "type", (PyCFunction)connectionType, METH_NOARGS,
PyDoc_STR("type() -> string") },
{ "timeout", (PyCFunction)connectionTimeout, METH_NOARGS,