[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src GComm.py commdrivers/GCommBase....
From: |
Jason Cater |
Subject: |
gnue/common/src GComm.py commdrivers/GCommBase.... |
Date: |
Thu, 06 Dec 2001 18:19:42 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/12/06 18:19:42
Modified files:
common/src : GComm.py
common/src/commdrivers: GCommBase.py
common/src/commdrivers/_helpers: AsyncSocketServer.py
common/src/commdrivers/_parser: Objects.py Parser.py
common/src/commdrivers/_test: donuts.grpc server.py
common/src/commdrivers/xmlrpc: CommDriver.py
Log message:
synching machines
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GComm.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/GCommBase.py.diff?cvsroot=OldCVS&tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_parser/Objects.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/_parser/Parser.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_test/donuts.grpc.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_test/server.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/CommDriver.py.diff?cvsroot=OldCVS&tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: gnue/common/src/GComm.py
diff -c gnue/common/src/GComm.py:1.10 gnue/common/src/GComm.py:1.11
*** gnue/common/src/GComm.py:1.10 Thu Dec 6 01:58:33 2001
--- gnue/common/src/GComm.py Thu Dec 6 18:19:41 2001
***************
*** 28,34 ****
--- 28,36 ----
#
import GDebug
+ from gnue.common import dyn_import
+
##############################################################################
#
# Attach to a client driver
***************
*** 38,100 ****
driver = dyn_import('gnue.common.commdrivers.%s' % interface)
except ImportError, mesg:
GDebug.printMesg(1, \
! "Unable to import GComm Adapter '%s': \n%s" % (driver,mesg))
raise InvalidAdapter, mesg
if not (hasattr(driver,'CLIENT') and driver.CLIENT):
raise NoClientAdapter, \
"GComm adapter '%s' does not support clients" % interface
! adapter = driver.Client(params)
return adapter
##############################################################################
#
# Bind/export our services
#
# Attributes:
#
! # drivers A tuple that defines all the transports to be used. The tuple
! # contains tuples of:
# 1) driver: A string containing the name of the commdriver
# (e.g., 'xmlrpc' or 'corba')
# 2) params: A dictionary containing parameters specific to
# the commdriver (e.g., {'port':'8888'} )
- #
- # bindings A tuple containing binding definitions where a binding definition
- # is a tuple of:
#
! # 1) exported service name: Name of the service being bound
# 2) handler: Method that when called returns a class instance
- # 3) rpcdef: The RPC definition loaded from an XML file
#
! def bind(drivers, bindings):
servers = {}
! for interface, params in drivers:
! for binding in bindings:
! service, handler, rpcdef = binding
try:
driver = dyn_import('gnue.common.commdrivers.%s' % interface)
except ImportError, mesg:
GDebug.printMesg(1, \
! "Unable to import GComm Adapter '%s': \n%s" % (driver,mesg))
raise InvalidAdapter, mesg
if not (hasattr(driver,'SERVER') and driver.SERVER):
raise NoServerAdapter, \
! "GComm adapter '%s' does not support clients" % interface
! adapter = driver.Server(params)
servers[interface] = adapter
return servers
#
# To keep everything that a client/server app will need in this
! # file, load any convenience functions from the commdrivers directory...
#
#
--- 40,109 ----
driver = dyn_import('gnue.common.commdrivers.%s' % interface)
except ImportError, mesg:
GDebug.printMesg(1, \
! "Unable to import GComm Adapter '%s': \n%s" % (interface,mesg))
raise InvalidAdapter, mesg
if not (hasattr(driver,'CLIENT') and driver.CLIENT):
raise NoClientAdapter, \
"GComm adapter '%s' does not support clients" % interface
! adapter = driver.ClientAdapter(params)
return adapter
+
##############################################################################
#
# Bind/export our services
#
# Attributes:
#
! # rpcdef The RPC definition loaded from an XML file
! #
! # drivers A dictionary that defines all the transports to be used. The
! # dictionary is of the form: {driver:params} where:
# 1) driver: A string containing the name of the commdriver
# (e.g., 'xmlrpc' or 'corba')
# 2) params: A dictionary containing parameters specific to
# the commdriver (e.g., {'port':'8888'} )
#
! # bindings A dictionary containing binding definitions. The dictionary
! # is of the form: {server:handler} where:
! # 1) service: Name of the service being bound/exposed
# 2) handler: Method that when called returns a class instance
#
! def bind(rpcdef, drivers, bindings):
!
servers = {}
!
! for interface in drivers.keys():
! params = drivers[interface]
!
! for service in bindings.keys():
! binding = bindings[service]
try:
driver = dyn_import('gnue.common.commdrivers.%s' % interface)
except ImportError, mesg:
GDebug.printMesg(1, \
! "Unable to import GComm Adapter '%s': \n%s" % (interface,mesg))
raise InvalidAdapter, mesg
if not (hasattr(driver,'SERVER') and driver.SERVER):
raise NoServerAdapter, \
! "GComm adapter '%s' does not support servers" % interface
! adapter = driver.ServerAdapter(params)
servers[interface] = adapter
return servers
#
# To keep everything that a client/server app will need in this
! # file, any convenience functions from the commdrivers directory.
! # (i.e., a user app should never need to access the commdrivers
! # directory.)
#
#
***************
*** 104,109 ****
--- 113,119 ----
+
##############################################################################
#
# Exception hierarchy:
***************
*** 115,147 ****
--- 125,194 ----
# |__ UserError (base for user-defined errors)
#
+ #
+ # The basis of all GComm exceptions
+ #
class Error(StandardError):
pass
+ #
+ # The requested adapter does not exist...
+ #
class InvalidAdapter(Error):
pass
+ #
+ # The requested adapter could not initialize. Perhaps the
+ # supplied parameters do not point to a valid server, etc.
+ #
class AdapterInitializationError(Error):
pass
+ #
+ # The parameters supplied to the adapter are not in the
+ # correct format, or all the needed parameters were not
+ # supplied.
+ #
class AdapterConfigurationError(AdapterInitializationError):
pass
+ #
+ # The application requested a "client" adapter, but the
+ # adapter only supports "server" adapters.
+ #
class NoClientAdapter(Error):
pass
+ #
+ # The application requested a "server" adapter, but the
+ # adapter only supports "client" adapters.
+ #
class NoServerAdapter(Error):
pass
+ #
+ # TBD..
+ #
class ProgrammingError(Error):
pass
+ #
+ # A client application requested a service that is not
+ # exposed by the server.
+ #
class InvalidService(ProgrammingError):
pass
+ #
+ # A communications error interfered with the client and
+ # server's transaction.
+ #
class CommunicationsError(Error):
pass
+ #
+ # Hmm... I had something in mind when I put this down...
+ #
class UserError(Error):
pass
Index: gnue/common/src/commdrivers/GCommBase.py
diff -c gnue/common/src/commdrivers/GCommBase.py:1.9
gnue/common/src/commdrivers/GCommBase.py:1.10
*** gnue/common/src/commdrivers/GCommBase.py:1.9 Wed Dec 5 18:15:58 2001
--- gnue/common/src/commdrivers/GCommBase.py Thu Dec 6 18:19:41 2001
***************
*** 78,84 ****
try:
self._subobject = params['subobject']
! else:
self._subobject = 0
--- 78,84 ----
try:
self._subobject = params['subobject']
! except KeyError:
self._subobject = 0
***************
*** 107,111 ****
def __call__(self, *args, **params):
! self._server.runMethod(self, *args, **params):
--- 107,111 ----
def __call__(self, *args, **params):
! self._server.runMethod(self, *args, **params)
Index: gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py
diff -c gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.2
gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.3
*** gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py:1.2 Wed Nov
28 23:40:39 2001
--- gnue/common/src/commdrivers/_helpers/AsyncSocketServer.py Thu Dec 6
18:19:41 2001
***************
*** 32,37 ****
--- 32,42 ----
from gnue.common.commdrivers import GCommBase
import asyncore
+ import socket
+ import string
+
+ from gnue.common import GDebug
+
class AsyncSocketServer(GCommBase.Server):
def __init__(self):
Index: gnue/common/src/commdrivers/_parser/Objects.py
diff -c gnue/common/src/commdrivers/_parser/Objects.py:1.1
gnue/common/src/commdrivers/_parser/Objects.py:1.2
*** gnue/common/src/commdrivers/_parser/Objects.py:1.1 Wed Dec 5 18:15:58 2001
--- gnue/common/src/commdrivers/_parser/Objects.py Thu Dec 6 18:19:42 2001
***************
*** 27,80 ****
# NOTES:
#
! from gnue.common.GObjects import GObject
# Top-level object
! class GnuRpc (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpGnuRpc")
# service object
! class RpcService (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpService")
# method object
! class RpcMethod (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpMethod")
# argument object
! class RpcArgument (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpArgument")
# attribute object
! class RpcAttribute (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpAttribute")
# object object (hehe)
! class RpcObject (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpObject")
# exception object
! class RpcException (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpException")
# exception object
! class RpcRaises (GObject):
! def __init__(self, parent):
! GObject.__init__(self, parent, type="RpException")
--- 27,80 ----
# NOTES:
#
! from gnue.common.GObjects import GObj
# Top-level object
! class GnuRpc (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpGnuRpc")
# service object
! class RpcService (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpService")
# method object
! class RpcMethod (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpMethod")
# argument object
! class RpcArgument (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpArgument")
# attribute object
! class RpcAttribute (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpAttribute")
# object object (hehe)
! class RpcObject (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpObject")
# exception object
! class RpcException (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpException")
# exception object
! class RpcRaises (GObj):
! def __init__(self, parent=None):
! GObj.__init__(self, parent, type="RpException")
Index: gnue/common/src/commdrivers/_parser/Parser.py
diff -c gnue/common/src/commdrivers/_parser/Parser.py:1.2
gnue/common/src/commdrivers/_parser/Parser.py:1.3
*** gnue/common/src/commdrivers/_parser/Parser.py:1.2 Thu Dec 6 01:26:35 2001
--- gnue/common/src/commdrivers/_parser/Parser.py Thu Dec 6 18:19:42 2001
***************
*** 77,86 ****
'BaseClass': Objects.GnuRpc,
'Required': 1,
'SingleInstance': 1,
- 'Attributes': {
- 'name': {
- 'Typecast': GTypecast.name,
- 'Required': 1 } },
'ParentTags': None },
'service': {
--- 77,82 ----
***************
*** 101,107 ****
'Typecast': GTypecast.name,
'Required': 1 },
'return': {
! 'Typecast': GTypecast.text } },
'ParentTags': ('gnurpc','service') },
'object': {
--- 97,103 ----
'Typecast': GTypecast.name,
'Required': 1 },
'return': {
! 'Typecast': GTypecast.name } },
'ParentTags': ('gnurpc','service') },
'object': {
***************
*** 120,127 ****
'Typecast': GTypecast.name,
'Required': 1 },
'type': {
! 'Typecast': GTypecast.text,
! 'Required': 1 } },
'ParentTags': ('method',) },
'attribute': {
--- 116,125 ----
'Typecast': GTypecast.name,
'Required': 1 },
'type': {
! 'Typecast': GTypecast.name,
! 'Required': 1 },
! 'default': {
! 'Typecast': GTypecast.text } },
'ParentTags': ('method',) },
'attribute': {
***************
*** 131,140 ****
'Typecast': GTypecast.name,
'Required': 1 },
'type': {
! 'Typecast': GTypecast.text,
! 'Required': 1 }
'readonly': {
! 'Typecast': GTypecast.boolean } },
'ParentTags': ('object',) },
'exception': {
--- 129,138 ----
'Typecast': GTypecast.name,
'Required': 1 },
'type': {
! 'Typecast': GTypecast.name,
! 'Required': 1 },
'readonly': {
! 'Typecast': GTypecast.boolean } },
'ParentTags': ('object',) },
'exception': {
***************
*** 161,167 ****
#######################################################
#
! # xmlFormsHandler
#
# This class is called by the XML parser to
# process the xml file.
--- 159,165 ----
#######################################################
#
! # xmlHandler
#
# This class is called by the XML parser to
# process the xml file.
Index: gnue/common/src/commdrivers/_test/donuts.grpc
diff -c gnue/common/src/commdrivers/_test/donuts.grpc:1.2
gnue/common/src/commdrivers/_test/donuts.grpc:1.3
*** gnue/common/src/commdrivers/_test/donuts.grpc:1.2 Thu Dec 6 01:26:35 2001
--- gnue/common/src/commdrivers/_test/donuts.grpc Thu Dec 6 18:19:42 2001
***************
*** 25,31 ****
</method>
</object>
! <method name="getBakingUnit" return="BakingUnit"/>
<argument name="flavor" type="string"/>
</method>
--- 25,31 ----
</method>
</object>
! <method name="getBakingUnit" return="BakingUnit">
<argument name="flavor" type="string"/>
</method>
Index: gnue/common/src/commdrivers/_test/server.py
diff -c gnue/common/src/commdrivers/_test/server.py:1.3
gnue/common/src/commdrivers/_test/server.py:1.4
*** gnue/common/src/commdrivers/_test/server.py:1.3 Thu Dec 6 01:58:33 2001
--- gnue/common/src/commdrivers/_test/server.py Thu Dec 6 18:19:42 2001
***************
*** 5,12 ****
################################################
class DonutPlace:
! Bakery = BakingUnit()
! Management = Management()
class Management:
--- 5,13 ----
################################################
class DonutPlace:
! def __init__(self):
! self.Bakery = BakingUnit()
! self.Management = Management()
class Management:
***************
*** 61,75 ****
def run(self):
! fin = openResource("donuts.grpc","r")
rpcdef = GComm.loadDefinition(fin,1)
fin.close()
# Expose our services to the world
params = { 'port': 8765 }
! GComm.export( [ ('xmlrpc', params) ],
! [ ('DonutPlace', self.requestDonutPlace, rpcdef) ] )
# Daemonize (if appropriate)
GServerApp.run(self)
--- 62,77 ----
def run(self):
! fin = openResource("donuts.grpc")
rpcdef = GComm.loadDefinition(fin,1)
fin.close()
# Expose our services to the world
params = { 'port': 8765 }
! GComm.bind ( rpcdef,
! {'xmlrpc': params },
! {'DonutPlace': self.requestDonutPlace })
# Daemonize (if appropriate)
GServerApp.run(self)
Index: gnue/common/src/commdrivers/xmlrpc/CommDriver.py
diff -c gnue/common/src/commdrivers/xmlrpc/CommDriver.py:1.9
gnue/common/src/commdrivers/xmlrpc/CommDriver.py:1.10
*** gnue/common/src/commdrivers/xmlrpc/CommDriver.py:1.9 Thu Dec 6
01:26:36 2001
--- gnue/common/src/commdrivers/xmlrpc/CommDriver.py Thu Dec 6 18:19:42 2001
***************
*** 55,69 ****
from gnue.common.commdrivers import GCommBase
from gnue.common import GComm
! import string
try:
import xmlrpclib
except ImportError:
print "-" * 79
! print "\nUnable to load xmlrpclib. To use the XML-RPC interface, \n"
! "please install xmlrpc from:\n"
! " http://www.pythonware.com/products/xmlrpc/\n"
print "-" * 79
sys.exit()
--- 55,69 ----
from gnue.common.commdrivers import GCommBase
from gnue.common import GComm
! import string, sys
try:
import xmlrpclib
except ImportError:
print "-" * 79
! print "\nUnable to load xmlrpclib. To use the XML-RPC interface, \n" \
! + "please install xmlrpc from:\n" \
! + " http://www.pythonware.com/products/xmlrpc/\n"
print "-" * 79
sys.exit()
***************
*** 131,137 ****
#
class ServerAdapter(AsyncHTTPServer):
! def raiseException(self, exception, message, event=None)
xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
--- 131,140 ----
#
class ServerAdapter(AsyncHTTPServer):
! def __init__(self, params):
! pass
!
! def raiseException(self, exception, message, event=None):
xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
***************
*** 148,154 ****
# Server raised an exception...
# Translate the exception into a local python
# exception and raise it...
! def _exceptionRaised(self, data)
if data.isGNUeGenerated():
name, text = string.split(data.message,': ',1)
# TODO: _lookup???
--- 151,157 ----
# Server raised an exception...
# Translate the exception into a local python
# exception and raise it...
! def _exceptionRaised(self, data):
if data.isGNUeGenerated():
name, text = string.split(data.message,': ',1)
# TODO: _lookup???
***************
*** 161,166 ****
def __call__(self, *args, **params):
return self._server.runMethod(self, string.join(self._attrPath,'.'),
! *args, **params):
--- 164,169 ----
def __call__(self, *args, **params):
return self._server.runMethod(self, string.join(self._attrPath,'.'),
! *args, **params)
- gnue/common/src GComm.py commdrivers/GCommBase....,
Jason Cater <=