[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5533 - in trunk/gnue-common/src/rpc: . drivers drivers/_helpers drivers
From: |
reinhard |
Subject: |
r5533 - in trunk/gnue-common/src/rpc: . drivers drivers/_helpers drivers/proxy drivers/pyro drivers/soap drivers/sockets drivers/xmlrpc drivers/xmlrpc/pw_xmlrpc drivers/xmlrpc/py_xmlrpc |
Date: |
Fri, 26 Mar 2004 10:19:18 -0600 (CST) |
Author: reinhard
Date: 2004-03-26 10:19:16 -0600 (Fri, 26 Mar 2004)
New Revision: 5533
Removed:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/Driver.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/Driver.py
Modified:
trunk/gnue-common/src/rpc/client.py
trunk/gnue-common/src/rpc/drivers/Base.py
trunk/gnue-common/src/rpc/drivers/__init__.py
trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py
trunk/gnue-common/src/rpc/drivers/proxy/__init__.py
trunk/gnue-common/src/rpc/drivers/pyro/__init__.py
trunk/gnue-common/src/rpc/drivers/soap/__init__.py
trunk/gnue-common/src/rpc/drivers/sockets/__init__.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/RpcDoc.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/__init__.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/__init__.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
trunk/gnue-common/src/rpc/server.py
Log:
Changed the rpc drivers to use common's new plugin system.
Modified: trunk/gnue-common/src/rpc/client.py
===================================================================
--- trunk/gnue-common/src/rpc/client.py 2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/client.py 2004-03-26 16:19:16 UTC (rev 5533)
@@ -23,78 +23,9 @@
import string
-from gnue.common.apps import GDebug
-from gnue.common.utils.FileUtils import dyn_import, openResource
+from gnue.common.apps import GDebug, plugin
# =============================================================================
-# TODO: Remove this, use gnue.common.plugin instead
-# =============================================================================
-
-from gnue.common.rpc.drivers import DRIVERS as ALLDRIVERS
-
-###################################################
-#
-# load driver from path which passes test 'test'
-# f.e. _get_driver('xmlrpc','gnue.common.rpc.drivers',lambda x: return
x.CLIENT==1))
-
-def _get_driver(drivername, baselist, path, test=lambda x:1):
-
- d = drivername.split('.')
- basedriver = d[0]
- if len(d) > 1:
- extradriver = "." + string.join(d[1:],'.')
- else:
- extradriver = ""
-
- driver = None
-
- basemodule = _find_base_driver(basedriver, baselist, [path])
- GDebug.printMesg(1,'Using %s as base driver for %s' % (basemodule, driver))
-
- if basemodule:
- driver = _import_driver(basemodule + extradriver, test)
-
- if not driver:
- tmsg = _("No rpc driver found for provider type '%s'") % drivername
- raise Exception, tmsg
-
- return driver
-
-def _find_base_driver (driver, modules, path=[]):
- if driver in modules:
- return string.join(path + [driver],'.')
- else:
- for module in modules:
- try:
- m = dyn_import (string.join(path + [module],'.')).DRIVERS
- rs = _find_base_driver(driver, m, path + [module])
- if rs:
- return rs
- except (AttributeError, ImportError), err:
- pass
-
-
-def _import_driver (drivername,test):
- driver = None
- try:
- driver = dyn_import("%s.Driver" % (drivername))
- except:
- GDebug.printMesg(1,'%s is not a dbdriver' % ( drivername))
- try:
- drivers = dyn_import("%s" % (drivername)).DRIVERS
- for d in drivers:
- driver = _import_driver(drivername + "." + d, test )
- try:
- if driver:
- if test(driver):
- return driver
- except Exception,msg:
- print msg
- except (ImportError, AttributeError):
- GDebug.printMesg(1,'%s does not contain drivers' % (drivername))
- return driver
-
-# =============================================================================
# Public functions
# =============================================================================
@@ -103,19 +34,9 @@
# -----------------------------------------------------------------------------
def attach (interface, params):
- try:
- driver = _get_driver (interface, ALLDRIVERS,
'gnue.common.rpc.drivers',lambda x:x.CLIENT==1 )
- if driver == None:
- raise ImportError
- except ImportError, mesg:
- GDebug.printMesg(1, \
- "Unable to import GComm Adapter '%s': \n%s" % (interface,mesg))
- raise InvalidAdapter, mesg
+ driver = plugin.find (interface, 'gnue.common.rpc.drivers', 'ClientAdapter')
+ return driver.ClientAdapter (params)
- adapter = driver.ClientAdapter (params)
-
- return adapter
-
# =============================================================================
# Exceptions
# =============================================================================
@@ -189,7 +110,7 @@
import traceback
- connection = attach ('py_xmlrpc', {})
+ connection = attach ('xmlrpc', {})
obj = connection.request ('test')
Modified: trunk/gnue-common/src/rpc/drivers/Base.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/Base.py 2004-03-26 15:23:29 UTC (rev
5532)
+++ trunk/gnue-common/src/rpc/drivers/Base.py 2004-03-26 16:19:16 UTC (rev
5533)
@@ -31,6 +31,9 @@
from gnue.common.apps import GDebug
+# Indicate that this is not a valid plugin
+__noplugin__ = True
+
# =============================================================================
# Client adapter
# =============================================================================
Modified: trunk/gnue-common/src/rpc/drivers/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/__init__.py 2004-03-26 15:23:29 UTC
(rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/__init__.py 2004-03-26 16:19:16 UTC
(rev 5533)
@@ -1 +0,0 @@
-DRIVERS = [ 'xmlrpc','proxy','sockets','soap','pyro']
Modified: trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py 2004-03-26
15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py 2004-03-26
16:19:16 UTC (rev 5533)
@@ -0,0 +1,2 @@
+# Indicate that these are no valid plugins
+__noplugin__ = True
Modified: trunk/gnue-common/src/rpc/drivers/proxy/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/proxy/__init__.py 2004-03-26 15:23:29 UTC
(rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/proxy/__init__.py 2004-03-26 16:19:16 UTC
(rev 5533)
@@ -1 +1,2 @@
-DRIVER=['proxy']
+# This is not ready yet
+__noplugin__ = True
Modified: trunk/gnue-common/src/rpc/drivers/pyro/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/pyro/__init__.py 2004-03-26 15:23:29 UTC
(rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/pyro/__init__.py 2004-03-26 16:19:16 UTC
(rev 5533)
@@ -1 +1,2 @@
-DRIVERS = ['pyro']
+# Not functional at the moment
+__noplugin__ = True
Modified: trunk/gnue-common/src/rpc/drivers/soap/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/soap/__init__.py 2004-03-26 15:23:29 UTC
(rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/soap/__init__.py 2004-03-26 16:19:16 UTC
(rev 5533)
@@ -1 +1,2 @@
-DRIVERS=['soapy','zsi']
+# Not functional at the moment
+__noplugin__ = True
Modified: trunk/gnue-common/src/rpc/drivers/sockets/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/sockets/__init__.py 2004-03-26
15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/sockets/__init__.py 2004-03-26
16:19:16 UTC (rev 5533)
@@ -1 +1,2 @@
-DRIVER=['socket']
+# Not functional at the moment
+__noplugin__ = True
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/RpcDoc.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/RpcDoc.py 2004-03-26 15:23:29 UTC
(rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/RpcDoc.py 2004-03-26 16:19:16 UTC
(rev 5533)
@@ -29,7 +29,7 @@
import string
import sys
-from gnue.common.rpc import GComm
+from gnue.common.rpc import server
# a global output file (small hack, to be removed a soon as possible)
gloutfile=sys.stdout
@@ -63,7 +63,7 @@
elif command == 'doc':
try:
- rpcdef = GComm.loadDefinition(arguments[0])
+ rpcdef = server.loadDefinition(arguments[0])
except IndexError:
print _("'doc' command expects a .grpc file as its argument.")
@@ -74,7 +74,7 @@
elif command == 'doc-py':
try:
- rpcdef = GComm.loadDefinition(arguments[0])
+ rpcdef = server.loadDefinition(arguments[0])
except IndexError:
print _("'doc' command expects a .grpc file as its argument.")
@@ -85,7 +85,7 @@
elif command == 'doc-c':
try:
- rpcdef = GComm.loadDefinition(arguments[0])
+ rpcdef = server.loadDefinition(arguments[0])
except IndexError:
print _("'doc' command expects a .grpc file as its argument.")
@@ -96,7 +96,7 @@
elif command == 'doc-php':
try:
- rpcdef = GComm.loadDefinition(arguments[0])
+ rpcdef = server.loadDefinition(arguments[0])
except IndexError:
print _("'doc-php' command expects a .grpc file as its argument.")
@@ -107,7 +107,7 @@
elif command == 'js-stub':
try:
- rpcdef = GComm.loadDefinition(arguments[0])
+ rpcdef = server.loadDefinition(arguments[0])
except IndexError:
print _("'js-stub' command expects a .grpc file as its argument.")
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/__init__.py 2004-03-26
15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/__init__.py 2004-03-26
16:19:16 UTC (rev 5533)
@@ -1 +0,0 @@
-DRIVERS=['py_xmlrpc','pw_xmlrpc']
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -35,14 +35,9 @@
# port The port that the service is located on
#
-# We provide a client driver...
-CLIENT = 1 # ClientAdapter
-
import string
import sys
-from gnue import paths
-from gnue.common.apps import GDebug
from gnue.common.rpc import client
from gnue.common.rpc.drivers import Base
Deleted: trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/Driver.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/Driver.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/Driver.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -1,32 +0,0 @@
-#
-# 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
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# __init__.py
-#
-# DESCRIPTION:
-# __init__ class for commdrivers.
-#
-# NOTES:
-#
-
-from ClientAdapter import *
-from ServerAdapter import *
-
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -33,14 +33,6 @@
# port The port that the service is located on
#
-
-
-##############################################################################
-#
-# We provide a server driver...
-#
-SERVER = 1 # ServerAdapter
-
from gnue.common.rpc import server
from gnue.common.apps import GDebug
from gnue.common.rpc.drivers._helpers import ObjectLibrarian, DirectoryServer
@@ -51,22 +43,15 @@
import string, sys, os, posixpath, urllib, socket, types
-import typeconv
-
try:
-
- # xmlrpclib could be in a package, so try both
- try:
- import xmlrpclib
- except ImportError:
- from xmlrpclib import xmlrpclib
-
+ import xmlrpclib
except ImportError:
- tmsg = _("\nUnable to load xmlrpclib. To use the XML-RPC interface, \n") \
- + _("please install xmlrpc from:\n") \
- + " http://www.pythonware.com/products/xmlrpc/"
+ tmsg = _("\nUnable to load xmlrpclib. To use the XML-RPC interface, \n"
+ "please install xmlrpc from:\n"
+ " http://www.pythonware.com/products/xmlrpc/")
raise server.AdapterInitializationError, tmsg
+import typeconv
# Mapping from GRPC's datatype to XML-RPC datatypes
_datatypeMap = {
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/__init__.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/__init__.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -0,0 +1,2 @@
+from ServerAdapter import *
+from ClientAdapter import *
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -33,8 +33,7 @@
# port The port that the service is located on
#
-# We provide a client driver...
-CLIENT = 1
+from types import *
import string
import sys
@@ -100,10 +99,11 @@
except:
# Bah! py_xmlrpc uses string exceptions!!
if sys.exc_info () [0] == 'xmlrpc.error':
- parts = string.split (sys.exc_info () [1], ':', 2)
- if parts [0] == '1':
- raise client.DistantError (parts [2])
- raise sys.exc_info () [2]
+ if isinstance (sys.exc_info () [1], StringType):
+ parts = string.split (sys.exc_info () [1], ':', 2)
+ if parts [0] == '1':
+ raise client.DistantError (parts [2])
+ raise
# check, if an object handle is sent
# TODO: make a better check
Deleted: trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/Driver.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/Driver.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/Driver.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -1,32 +0,0 @@
-#
-# 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
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# __init__.py
-#
-# DESCRIPTION:
-# __init__ class for commdrivers.
-#
-# NOTES:
-#
-
-from ClientAdapter import *
-from ServerAdapter import *
-
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -27,9 +27,6 @@
# loglevel Loglevel of the internal server
#
-# We provide a server driver...
-SERVER = 1 # ServerAdapter
-
from types import *
import string
Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
2004-03-26 16:19:16 UTC (rev 5533)
@@ -0,0 +1,2 @@
+from ServerAdapter import *
+from ClientAdapter import *
Modified: trunk/gnue-common/src/rpc/server.py
===================================================================
--- trunk/gnue-common/src/rpc/server.py 2004-03-26 15:23:29 UTC (rev 5532)
+++ trunk/gnue-common/src/rpc/server.py 2004-03-26 16:19:16 UTC (rev 5533)
@@ -25,78 +25,10 @@
import string
-from gnue.common.apps import GDebug
-from gnue.common.utils.FileUtils import dyn_import, openResource
+from gnue.common.apps import GDebug, plugin
+from gnue.common.utils.FileUtils import openResource
# =============================================================================
-# TODO: Remove this, use gnue.common.plugin instead
-# =============================================================================
-
-from gnue.common.rpc.drivers import DRIVERS as ALLDRIVERS
-
-###################################################
-#
-# load driver from path which passes test 'test'
-# f.e. _get_driver('xmlrpc','gnue.common.rpc.drivers',lambda x: return
x.CLIENT==1))
-
-def _get_driver(drivername, baselist, path, test=lambda x:1):
-
- d = drivername.split('.')
- basedriver = d[0]
- if len(d) > 1:
- extradriver = "." + string.join(d[1:],'.')
- else:
- extradriver = ""
-
- driver = None
-
- basemodule = _find_base_driver(basedriver, baselist, [path])
- GDebug.printMesg(1,'Using %s as base driver for %s' % (basemodule, driver))
-
- if basemodule:
- driver = _import_driver(basemodule + extradriver, test)
-
- if not driver:
- tmsg = _("No rpc driver found for provider type '%s'") % drivername
- raise Exception, tmsg
-
- return driver
-
-def _find_base_driver (driver, modules, path=[]):
- if driver in modules:
- return string.join(path + [driver],'.')
- else:
- for module in modules:
- try:
- m = dyn_import (string.join(path + [module],'.')).DRIVERS
- rs = _find_base_driver(driver, m, path + [module])
- if rs:
- return rs
- except (AttributeError, ImportError), err:
- pass
-
-
-def _import_driver (drivername,test):
- driver = None
- try:
- driver = dyn_import("%s.Driver" % (drivername))
- except:
- GDebug.printMesg(1,'%s is not a dbdriver' % ( drivername))
- try:
- drivers = dyn_import("%s" % (drivername)).DRIVERS
- for d in drivers:
- driver = _import_driver(drivername + "." + d, test )
- try:
- if driver:
- if test(driver):
- return driver
- except Exception,msg:
- print msg
- except (ImportError, AttributeError):
- GDebug.printMesg(1,'%s does not contain drivers' % (drivername))
- return driver
-
-# =============================================================================
# Public functions
# =============================================================================
@@ -151,18 +83,9 @@
for interface in drivers.keys ():
params = drivers [interface]
- try:
- driver = _get_driver(interface, ALLDRIVERS,
'gnue.common.rpc.drivers',lambda x:x.SERVER==1 )
- if driver == None:
- raise ImportError
- except ImportError, mesg:
- GDebug.printMesg(1, \
- "Unable to import GComm Adapter '%s': \n%s" %
(interface,mesg))
- raise InvalidAdapter, mesg
+ driver = plugin.find (interface, 'gnue.common.rpc.drivers',
'ServerAdapter')
+ servers [interface] = driver.ServerAdapter (mapping, bindings, params)
- adapter = driver.ServerAdapter (mapping, bindings, params)
- servers [interface] = adapter
-
return servers
# To keep everything that a client/server app will need in this
@@ -295,7 +218,7 @@
# '</service>'
'</gnurpc>')
- drivers = {'py_xmlrpc': {'port': 8765}}
+ drivers = {'xmlrpc': {'port': 8765}}
bindings = {'test': servertest}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5533 - in trunk/gnue-common/src/rpc: . drivers drivers/_helpers drivers/proxy drivers/pyro drivers/soap drivers/sockets drivers/xmlrpc drivers/xmlrpc/pw_xmlrpc drivers/xmlrpc/py_xmlrpc,
reinhard <=