471,831 Members | 1,285 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

Automation wrapped xmlrpc Server

Hello all,

I'm trying to create a COM Server with an embedded xmlrpc server.

Here is way it must work:
- The client application (programmed with a COM capable language)
instantiates my COM server (programmed with python).
- The COM server must have a connect interface in order to let the
client application process the xmlrpc request.
- After executing a "serveforever" method on the COM server it begins
to listen on a configured port for xmlrpc requests.
- When the COM server receives a xmlrpc request it passes this request
to the client application event (connect interface) in order to
process it.
- The client application processes the request and returns a result to
the COM server. The COM server returns this result to the xmlrpc

So, I must say that I have programmed some COM servers in python with
the aid of Mark's book, but in this case I have some problems:
- Must I instantiate a new thread for the xmlrpc server?
- If the xmlrpc server is a different thread how can this thread call
the _BroadcastNotify method from the main thread (the COM server)?
- I have successfully called the _BroadcastNotify method from the main
thread, but I become a strange behaviuor calling it from other thread.
- I tryied to pass the calling object reference to the xmlrpc thread,
so the xmlrpc thread has a reference to the _BroadcastNotify method,
but it does not work correctly.

Here is part of my code (I have deleted some parts):

class xmlrpcServer(Thread):
def __init__(self, mainthread, host, port):
self.host = host
self.port = port
self.mainthread = mainthread
def run(self):
while 1:
# the following line simulates the reception
# of a xmlrpc request
request = xmlrpcRequest('testmethod', [n, 'parameter2'])
wrapped = wrap(request, useDispatcher=useDispatcher)
self.mainthread._BroadcastNotify(self.mainthread.N otifyCall,
class COMServer(ConnectableServer):
_public_methods_ = ['Serve'] + ConnectableServer._public_methods_
_connect_interfaces_ = [IID_IxmlrpcEvents]

def __init__(self):
self.Host = ''
self.Port = None

def Serve(self):
# method Serve
#req = xmlrpcRequest('testmethod', ['parameter1', 23])
#wrapped = wrap(req, useDispatcher=useDispatcher)
#self._BroadcastNotify(self.NotifyCall, (wrapped,))
#req = unwrap(wrapped)
self._s = xmlrpcServer(self)

def NotifyCall(self, interface, arg):
interface.Invoke(1000, 0, pythoncom.DISPATCH_METHOD, 1, arg)

class xmlrpcRequest:
# wraps a xmlrpc request as a COM object in order to pass it to
# a client event
_public_methods_ = ['Method', 'Parameter', 'Result']

def __init__(self, method, parameters):
self.Result = None
self._method = method
self._parameters = parameters

If I call the _BroadcastNotify method directly from the Serve method,
it works correctly.

Has anybody examples of a similar COM server?
Helps will be appreciated.

Thank you.
Jul 18 '05 #1
0 1625

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by glin | last post: by
reply views Thread by Juan Carlos CORUÑA | last post: by
1 post views Thread by Joxean Koret | last post: by
15 posts views Thread by qwweeeit | last post: by
1 post views Thread by emielvl | last post: by
3 posts views Thread by David Hirschfield | last post: by
6 posts views Thread by half.italian | last post: by
4 posts views Thread by care02 | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.