[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-common/src/commdrivers GCommBase.py x...
From: |
Jason Cater |
Subject: |
gnue/gnue-common/src/commdrivers GCommBase.py x... |
Date: |
Sun, 04 Nov 2001 13:34:38 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/11/04 13:34:37
Modified files:
gnue-common/src/commdrivers: GCommBase.py
gnue-common/src/commdrivers/xmlrpc: CommDriver.py
Added files:
gnue-common/src/commdrivers/_helpers: ObjectLibrarian.py
Log message:
further implementation of commdrivers
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/commdrivers/GCommBase.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/commdrivers/_helpers/ObjectLibrarian.py?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gnue/gnue-common/src/commdrivers/GCommBase.py
diff -u gnue/gnue-common/src/commdrivers/GCommBase.py:1.5
gnue/gnue-common/src/commdrivers/GCommBase.py:1.6
--- gnue/gnue-common/src/commdrivers/GCommBase.py:1.5 Thu Nov 1 22:37:49 2001
+++ gnue/gnue-common/src/commdrivers/GCommBase.py Sun Nov 4 13:34:37 2001
@@ -30,9 +30,12 @@
from gnue.common import GComm
class Client:
- def requestService(self, method, data={}):
+ def requestService(self, service, params={}):
pass
+ def close():
+ pass
+
def runMethod(self, method, params):
pass
@@ -41,8 +44,15 @@
def setAttribute(self, attribute
pass
+
+ # Try to shut our services down
+ def __del__(self):
+ try:
+ self.close()
+ except:
+ pass
-
+
class Server:
def runService(self, method, data):
pass
@@ -52,7 +62,8 @@
class ProxyObject:
- def __init__(self, client):
- self._client = client
-
-
+ def __init__(self, adapter, parent=None, **params):
+ for param in params.keys():
+ self.__dict__["_%s" % param] = params[param]
+ self._adapter = adapter
+ self._parent = parent
Index: gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py
diff -u gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py:1.3
gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py:1.4
--- gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py:1.3 Tue Oct 30
01:13:21 2001
+++ gnue/gnue-common/src/commdrivers/xmlrpc/CommDriver.py Sun Nov 4
13:34:37 2001
@@ -25,9 +25,20 @@
# Class that implements the XML-RPC driver for GNUe Comm.
#
# NOTES:
-# http://www.pythonware.com/products/xmlrpc/
+# Requires xmlrpclib from http://www.pythonware.com/products/xmlrpc/
+#
+# Client parameters:
+#
+# url The complete URI address of the XML-RPC service.
+# e.g, url="https://www.domain.com:8888/service.php"
+# ..or..
+# transport The service transport (either "http" or "https")
+# host The hostname or IP address of the service
+# port The port that the service is located on
+#
+
#
# We provide both a client and a server driver...
#
@@ -35,15 +46,19 @@
SERVER = 1 # ServerAdapter
from gnue.common.commdrivers._helpers.AsyncHTTPServer import AsyncHTTPServer
+from gnue.common.commdrivers._helpers import ObjectLibrarian
+
from gnue.common.commdrivers import GCommBase
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()
@@ -51,8 +66,40 @@
# ClientAdapter
#
class ClientAdapter(GCommBase.Client):
- pass
+ def __init__(self, params):
+ try:
+ url = params['url']
+ if not len(url):
+ raise KeyError
+ except KeyError:
+ try:
+ transport = params['transport']
+ except KeyError:
+ transport = 'https'
+
+ url = "%s://%s:%s/" % ( transport, params['host'], params['port'] )
+
+ self._server = xmlrpclib.Server(url)
+
+
+ def requestService(self, service, params={}):
+ proxy = _ProxyObject(self, None,
servicer=self._server.__getattr__(service))
+
+
+ def close():
+ pass
+
+ def runMethod(self, method, *args, **params):
+ pass
+
+ def getAttribute(self, attribute):
+ pass
+
+ def setAttribute(self, attribute):
+ pass
+
+
#
# ServerAdapter
#
@@ -61,10 +108,18 @@
def raiseException(self, exception, message, event=None)
xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
+
#
# ProxyObject
#
-class ProxyObject(GCommBase.ProxyObject):
+class _ProxyObject(GCommBase.ProxyObject):
+
+ def __getattr__(self, attr):
+ self.__dict__[attr] = _ProxyObject(self._server, self, name=attr)
+ return self.__dict__[attr]
+
+ def __call__(self, *args, **params):
+ self._server.runMethod(self, args, params):
# Server raised an exception...
# Translate the exception into a local python
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnue-common/src/commdrivers GCommBase.py x...,
Jason Cater <=