[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/commdrivers GCommBase.py _helpe...
From: |
Jason Cater |
Subject: |
gnue/common/src/commdrivers GCommBase.py _helpe... |
Date: |
Thu, 20 Dec 2001 18:27:27 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/12/20 18:27:27
Modified files:
common/src/commdrivers: GCommBase.py
common/src/commdrivers/_helpers: AsyncSocketServer.py
common/src/commdrivers/xmlrpc: ClientAdapter.py ServerAdapter.py
Log message:
more work on async socket server/xml-rpc
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/GCommBase.py.diff?cvsroot=OldCVS&tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnue/common/src/commdrivers/GCommBase.py
diff -c gnue/common/src/commdrivers/GCommBase.py:1.12
gnue/common/src/commdrivers/GCommBase.py:1.13
*** gnue/common/src/commdrivers/GCommBase.py:1.12 Mon Dec 17 00:20:16 2001
--- gnue/common/src/commdrivers/GCommBase.py Thu Dec 20 18:27:27 2001
***************
*** 66,71 ****
--- 66,73 ----
self._bindings = bindings
self._rpcdef = rpcdef
+ def serve(self):
+
def runService(self, method, data):
pass
Index: gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py
diff -c gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.4
gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.5
*** gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.4 Sun Dec
9 23:41:02 2001
--- gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py Thu Dec 20
18:27:27 2001
***************
*** 1,9 ****
#
# This file is part of GNU Enterprise.
#
! # GNU Enterprise is free software; you can redistribute it
! # and/or modify it under the terms of the GNU General Public
! # License as published by the Free Software Foundation; either
# version 2, or (at your option) any later version.
#
# GNU Enterprise is distributed in the hope that it will be
--- 1,9 ----
#
# This file is part of GNU Enterprise.
#
! # GNU Enterprise is free software; you can redistribute it
! # and/or modify it under the terms of the GNU General Public
! # License as published by the Free Software Foundation; either
# version 2, or (at your option) any later version.
#
# GNU Enterprise is distributed in the hope that it will be
***************
*** 22,28 ****
# AsyncSocketServer
#
# DESCRIPTION:
! # Set of classes that implement a Async-IO-based socket server.
#
# NOTES:
# These socket servers do their magic without threads or forking.
--- 22,28 ----
# AsyncSocketServer
#
# DESCRIPTION:
! # Set of classes that implement a Async(select)-based socket server.
#
# NOTES:
# These socket servers do their magic without threads or forking.
***************
*** 32,37 ****
--- 32,38 ----
from gnue.common.commdrivers import GCommBase
import asyncore
+ import asynchat
import socket
import string
***************
*** 39,49 ****
class AsyncSocketServer(GCommBase.Server):
! def __init__(self):
! GCommBase.Server.__init__(self)
class AsyncHTTPServer(AsyncSocketServer):
pass
--- 40,136 ----
class AsyncSocketServer(GCommBase.Server):
!
! def __init__(self, bindings, params):
! GCommBase.Server.__init__(self, bindings, params)
!
! # TODO: This should probably allow you to
! # TODO: connect to both a Unix-style socket
! # TODO: file and to a TCP/IP socket.
!
! try:
! self._socketfile = params['socket']
! if not len(self.__socketfile:
! raise ImportError
! except ImportError:
! self._socketfile = None
! self._port = params['port']
!
! # Create our dispatcher
! if self._socketfile:
! self._dispatcher = _AsyncUnixDispatcher(self, self._socketfile)
! else:
! # TODO: This only binds to 127.0.0.1...
! # TODO: Recode to allow the interface to be specified
! self._dispatcher = _AsyncInetDispatcher(self, ('',self._port))
!
!
! # Called by GComm when all is initialized
! # as we can start our infinite wait loop.
! def serve(self):
! asyncore.loop()
!
class AsyncHTTPServer(AsyncSocketServer):
pass
+
+
+
+
+ ##############################################################################
+ #
+ # Internal classes
+ #
+ ##############################################################################
+
+
+ #
+ # Socket Dispatcher
+ #
+ # Do not use this class... instead use
+ # _AsyncInetDispatcher or _AsyncUnixDispatcher
+ #
+ class _AsyncDispatcher(asyncore.dispatcher):
+
+ def handle_accept (self):
+ conn, addr = self.accept()
+ _AsyncChannel (self.root, conn, addr)
+
+
+ #
+ # Bind to a port and dispatch events
+ #
+ class _AsyncInetDispatcher(_AsyncDispatcher):
+
+ def __init__ (self, root, address):
+ self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
+ self.set_reuse_addr()
+ self.bind (address)
+ self.listen (128)
+ self.root = root
+
+
+ #
+ # Bind to a UNIX-style socket file and dispatch events
+ #
+ class _AsyncUnixDispatcher(_AsyncDispatcher):
+
+ def __init__ (self, root, file):
+ self.create_socket (socket.AF_UNIX, socket.SOCK_STREAM)
+ self.set_reuse_addr()
+ self.bind (address)
+ self.listen (128)
+ self.root = root
+
+
+ #
+ #
+ #
+ class _AsyncChannel(asynchat.async_chat):
+ def __init__(self, root, addr):
+ self.root = root
+ self.addr = addr
+ asynchat.async_chat.__init__ (self, conn)
Index: gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.1
gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.2
*** gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.1 Mon Dec 17
20:10:28 2001
--- gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py Thu Dec 20 18:27:27 2001
***************
*** 52,58 ****
import string, sys
try:
! import xmlrpclib
except ImportError:
raise GComm.AdapterInitializationError, \
"\nUnable to load xmlrpclib. To use the XML-RPC interface, \n" \
--- 52,64 ----
import string, sys
try:
!
! # xmlrpclib could be in a package, so try both
! try:
! import xmlrpclib
! except ImportError:
! from xmlrpclib import xmlrpclib
!
except ImportError:
raise GComm.AdapterInitializationError, \
"\nUnable to load xmlrpclib. To use the XML-RPC interface, \n" \
Index: gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.5
gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.6
*** gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.5 Thu Dec 20
00:14:53 2001
--- gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py Thu Dec 20 18:27:27 2001
***************
*** 54,60 ****
import string, sys
try:
! import xmlrpclib
except ImportError:
raise GComm.AdapterInitializationError, \
"\nUnable to load xmlrpclib. To use the XML-RPC interface, \n" \
--- 54,66 ----
import string, sys
try:
!
! # xmlrpclib could be in a package, so try both
! try:
! import xmlrpclib
! except ImportError:
! from xmlrpclib import xmlrpclib
!
except ImportError:
raise GComm.AdapterInitializationError, \
"\nUnable to load xmlrpclib. To use the XML-RPC interface, \n" \
***************
*** 316,321 ****
--- 322,328 ----
"Server does not have XML-RPC " \
"procedure %s" % method
return server_method(method, params)
+
##############################################################################
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src/commdrivers GCommBase.py _helpe...,
Jason Cater <=