[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5353 - in trunk/gnue-common/src: datasources/drivers/appserver/appserve
From: |
reinhard |
Subject: |
r5353 - in trunk/gnue-common/src: datasources/drivers/appserver/appserver rpc rpc/drivers rpc/drivers/_helpers rpc/drivers/proxy rpc/drivers/pyro rpc/drivers/soap rpc/drivers/soap/soappy rpc/drivers/sockets rpc/drivers/xmlrpc rpc/drivers/xmlrpc/pw_xmlrpc rpc/drivers/xmlrpc/py_xmlrpc |
Date: |
Thu, 18 Mar 2004 18:01:40 -0600 (CST) |
Author: reinhard
Date: 2004-03-18 18:01:36 -0600 (Thu, 18 Mar 2004)
New Revision: 5353
Added:
trunk/gnue-common/src/rpc/client.py
trunk/gnue-common/src/rpc/drivers/Base.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/typeconv.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/typeconv.py
trunk/gnue-common/src/rpc/server.py
Removed:
trunk/gnue-common/src/rpc/GCommBase.py
trunk/gnue-common/src/rpc/drivers/corba/
trunk/gnue-common/src/rpc/drivers/pyro/CommDriver.py
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
trunk/gnue-common/src/datasources/drivers/appserver/appserver/ResultSet.py
trunk/gnue-common/src/rpc/GComm.py
trunk/gnue-common/src/rpc/drivers/__init__.py
trunk/gnue-common/src/rpc/drivers/_helpers/AsyncSocketServer.py
trunk/gnue-common/src/rpc/drivers/_helpers/DirectoryServer.py
trunk/gnue-common/src/rpc/drivers/_helpers/ObjectEnabler.py
trunk/gnue-common/src/rpc/drivers/_helpers/ObjectLibrarian.py
trunk/gnue-common/src/rpc/drivers/_helpers/RpcDoc.py
trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py
trunk/gnue-common/src/rpc/drivers/proxy/CommDriver.py
trunk/gnue-common/src/rpc/drivers/proxy/__init__.py
trunk/gnue-common/src/rpc/drivers/pyro/ClientAdapter.py
trunk/gnue-common/src/rpc/drivers/pyro/Driver.py
trunk/gnue-common/src/rpc/drivers/pyro/ServerAdapter.py
trunk/gnue-common/src/rpc/drivers/pyro/__init__.py
trunk/gnue-common/src/rpc/drivers/soap/CommDriver.py
trunk/gnue-common/src/rpc/drivers/soap/__init__.py
trunk/gnue-common/src/rpc/drivers/soap/soappy/Driver.py
trunk/gnue-common/src/rpc/drivers/sockets/CommDriver.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/Driver.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/Driver.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
Log:
Some RPC library cleanup.
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -42,7 +42,7 @@
from gnue.common.datasources import GDataObjects, GConditions
from gnue.common.datasources.drivers.Base import Connection as BaseConnection
from gnue.common.apps import GDebug
-from gnue.common.rpc import GComm
+from gnue.common.rpc import client
from DataObject import *
@@ -73,7 +73,7 @@
class Connection(BaseConnection):
- _DatabaseError = GComm.Error
+ _DatabaseError = client.Error
defaultBehavior = Introspection
supportedDataObjects = {
'object': DataObject
@@ -92,7 +92,7 @@
'port': connectData['port'],
'transport': connectData['transport']}
- self._server = GComm.attach(connectData['rpctype'],params)
+ self._server = client.attach(connectData['rpctype'],params)
if connectData.has_key ('timeout'):
self._server.setTimeout (float (connectData ['timeout']))
@@ -192,17 +192,16 @@
def __rpc_to_native (self, value, typestr):
# Empty strings indicate None
+ if value == None:
+ return None
+
if value == '':
return None
# String: convert to unicode or local encoding
elif typestr [:6] == 'string':
- try:
+ if isinstance (value, types.StringType):
value = unicode (value, 'utf-8')
- except TypeError, msg:
- # if value is already unicode, don't raise TypeError
- if type(value)!=types.UnicodeType:
- raise TypeError, msg
if self._unicodeMode:
return value
else:
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/DataObject.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -34,7 +34,6 @@
from gnue.common.datasources import GConditions, Exceptions
from gnue.common.datasources.drivers.Base import DataObject as BaseDataObject
from gnue.common.apps import GDebug
-from gnue.common.rpc import GComm
import string
import types
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -32,7 +32,6 @@
from gnue.common.datasources import GConditions, Exceptions
from gnue.common.datasources.drivers.Base import RecordSet as BaseRecordSet
from gnue.common.apps import GDebug
-from gnue.common.rpc import GComm
import string
import types
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/ResultSet.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/ResultSet.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -32,7 +32,6 @@
from gnue.common.datasources import GConditions, Exceptions
from gnue.common.datasources.drivers.Base import ResultSet as BaseResultSet
from gnue.common.apps import GDebug
-from gnue.common.rpc import GComm
import string
import types
Modified: trunk/gnue-common/src/rpc/GComm.py
===================================================================
--- trunk/gnue-common/src/rpc/GComm.py 2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/GComm.py 2004-03-19 00:01:36 UTC (rev 5353)
@@ -1,4 +1,7 @@
+# GNU Enterprise RPC interface - Server adapter
#
+# Copyright 2001-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,339 +19,10 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# GComm.py
-#
-# DESCRIPTION:
-# Class that provides a basis for GNUe Comm clients & servers.
-#
-# NOTES:
-#
+# $Id: $
-import string
-from gnue.common.apps import GDebug
-from gnue.common.utils.FileUtils import dyn_import, openResource
+print 'The use of the "common.rpc.GComm" module is deprecated. Please use the'
+print '"common.rpc.server" or "common.rpc.client" module instead.'
-
-#####################################################################
-#
-# Helper functions to load appropriate driver
-#
-# TODO: add to FileUtils as they are almost the same function as in
GConnection.py
-
-#
-# Load the correct driver from gnue/common/datasources/drivers/*/
-#
-
-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
-
-
-
-
-##############################################################################
-#
-# Attach to a client driver
-#
-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
-
- adapter = driver.ClientAdapter(params)
-
- return adapter
-
-
-
-##############################################################################
-#
-# Bind/export our services
-#
-# Attributes:
-#
-# rpcdef The RPC definition loaded from an XML file. This can be
-# 1) a string that contains the location of the XML file
-# (can be a URL or pathname)
-# 2) a file-handle (or file-like handle; e.g. StringBuffer)
-# referencing an XML definition
-# 3) a GnuRpc object created from GComm.loadDefinition()
-#
-# 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 i.e. {'DonutPlace',getDonutPlaceObj}
-#
-def bind(rpcdef, drivers, bindings):
-
- if type(rpcdef) == type(""):
-
- # Application supplied the location of their rpcdef.. load it
- fin = openResource(rpcdef)
- mapping = loadDefinition(fin,1)
- fin.close()
-
- elif rpcdef.hasattr("read"):
-
- # Application provided us a file-like object
- mapping = loadDefinition(rpcdef)
-
- else:
-
- # Otherwise, they must have specified a GnuRpc object
- mapping = rpcdef
-
-
- servers = {}
-
- 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
-
- adapter = driver.ServerAdapter(mapping, bindings, 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.)
-#
-
-#
-# Load an XML-based interface definition
-#
-from gnue.common.rpc.parser.Parser import loadDefinition
-
-
-
-
-##############################################################################
-#
-# Exception hierarchy:
-#
-# Error
-# |__ ProgrammingError
-# | |__ InvalidService
-# |__ CommunicationsError
-# |__ 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
-
-
-#
-# An error which has occured on the server and which is
-# raised again on the server
-#
-class DistantError(Error):
- pass
-
-
-#
-# Hmm... I had something in mind when I put this down...
-#
-class UserError(Error):
- pass
-
-
-
-#
-# Some conversion functions to allow a client to describe the type of
-# the argument that should be passed instead of autodetection
-# TODO: should be moved to GTypeCast
-#
-# i.e. Donutplace.send(base64(photo.jpg))
-
-class base64:
- def __init__(self,value):
- self._type='base64'
- self._value=value
-
-class binary:
- def __init__(self,value):
- self._type='binary'
- self._value=value
-
-class date:
- def __init__(self,value):
- self._type='date'
- self._value=value
-
-# value has to be a 6 tuple: ex: datetime(1,1,1,1,1,1)
-class datetime:
- def __init__(self,value):
- self._type='date'
- self._value=value
-
-class boolean:
- def __init__(self,value):
- self._type='boolean'
- self._value=value
-
-class integer:
- def __init__(self,value):
- self._type='integer'
- self._value=value
-
-class number:
- def __init__(self,value):
- self._type='number'
- self._value=value
-
-class string_type:
- def __init__(self,value):
- self._type='string'
- self._value=value
-
-class none:
- def __init__(self,value):
- self._type='none'
- self._value=value
+from client import attach
+from server import bind
Deleted: trunk/gnue-common/src/rpc/GCommBase.py
===================================================================
--- trunk/gnue-common/src/rpc/GCommBase.py 2004-03-18 23:07:27 UTC (rev
5352)
+++ trunk/gnue-common/src/rpc/GCommBase.py 2004-03-19 00:01:36 UTC (rev
5353)
@@ -1,187 +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:
-# GCommBase.py
-#
-# DESCRIPTION:
-# Class that provides a basis for GNUe Comm Drivers.
-#
-# NOTES:
-#
-
-
-from gnue.common.rpc import GComm
-from gnue.common.apps import GDebug
-import string, sys, thread, traceback
-
-
-##############################################################################
-#
-# ClientAdapter
-#
-class Client:
- """basic client adapter"""
- def request(self, service, params={}):
- pass
-
- def close():
- """
- Close the connection to the server
- """
- pass
-
- def runMethod(self, method, path, *args, **params):
- """
- execute a remote method
- """
- pass
-
- def setLocalArgumentChecking(self,enable):
- """
- Enable/Disable local argument checking. If enabled the client will check
- the number and the type of parameter before they are passed to the server.
-
- If this feature isn't supported by the driver, an exception will be raised.
- """
- pass
-
- # Try to shut our services down
- def __del__(self):
- """
- If the client adapter is deleted manually or by the garbage collector,
- the connection is closed down.
- """
- try:
- self.close()
- except:
- pass
-
-
-
-##############################################################################
-#
-# ServerAdapter
-#
-class Server:
- def __init__(self, rpcdef, bindings, params):
- self._bindings = bindings
- self._rpcdef = rpcdef
- self._dispatchers = []
-
- def allowObjectIntrospection(self,allow):
- # allow the remote client to get the type of an object by its handle
- # an to get other introspection details by that
- pass
-
- def serve(self):
- pass
-
- def serveAsNewThread(self):
- thread.start_new_thread(self.serve,())
-
- # add an function which accepts the parameter (method, params)
- # which is called to dispatch incoming method requests
- # and returns a tuple (result,rtype,method,params)
- def addDispatcher(self,func):
- self._dispatchers=[func]+self._dispatchers
-
- def runService(self, method, data):
- pass
-
-
- #
- # Return an exception
- #
- def raiseException(self, exception, message, event=None):
- raise exception, message
-
-
-
-##############################################################################
-#
-# ProxyObject
-#
-class ProxyObject:
- def __init__(self, adapter, attr, parent=None, **params):
- for param in params.keys():
- self.__dict__["_%s" % param] = params[param]
- self._adapter = adapter
- self._parent = parent
- self._attr = attr
-
- try:
- self._attrPath = parent._attrPath[:]
- except AttributeError:
- self._attrPath = []
-
- self._attrPath.append(attr)
-
- # print "Creating ProxyObject %s" % string.join(self._attrPath,'.')
-
- try:
- self._subobject = params['subobject']
- except KeyError:
- self._subobject = 0
-
-
- def __getattr__(self, attr):
- try:
- if attr[0] == '_':
- raise AttributeError, attr
- else:
- try:
- return self.__dict__[attr]
- except KeyError:
- po = self.__class__(self._adapter, attr, self,
- subobject=1)
- self.__dict__[attr] = po
- return po
-
- except KeyError, mesg:
- raise AttributeError, mesg
-
- def __setattr__(self, attr, value):
- if attr[0] == '_':
- self.__dict__[attr] = value
- else:
- raise GComm.ProgrammingError
-
- def __call__(self, *args, **params):
- return self._adapter.runMethod(string.join(self._attrPath,'.'),
- *args, **params)
-
-
-# Support to pass exception over the wire
-# TODO: write a decode exception, or a function to build a fake traceback
-
-def encodeExc():
- exc = sys.exc_info()
-
- GDebug.printMesg(1,'RPC detected Exception of type "%s", value: "%s".' % \
- (exc[0],exc[1]))
-
- error = string.join(traceback.format_exception(exc[0],exc[1], exc[2]),'\n')
-
- # remove exception object, because garbage collector can't remove it
- del(exc)
-
- return error
-
Added: trunk/gnue-common/src/rpc/client.py
===================================================================
--- trunk/gnue-common/src/rpc/client.py 2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/client.py 2004-03-19 00:01:36 UTC (rev 5353)
@@ -0,0 +1,212 @@
+# GNU Enterprise RPC interface - Client adapter
+#
+# Copyright 2001-2004 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import string
+
+from gnue.common.apps import GDebug
+from gnue.common.utils.FileUtils import dyn_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
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Attach to a client driver
+# -----------------------------------------------------------------------------
+
+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
+
+ adapter = driver.ClientAdapter (params)
+
+ return adapter
+
+# =============================================================================
+# Exceptions
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# The basis of all rpc.client exceptions
+# -----------------------------------------------------------------------------
+
+class Error(StandardError):
+ pass
+
+# -----------------------------------------------------------------------------
+# 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
+
+# -----------------------------------------------------------------------------
+# Parent for all caller errors
+# -----------------------------------------------------------------------------
+
+class ProgrammingError(Error):
+ pass
+
+# -----------------------------------------------------------------------------
+# A client application requested a service that is not
+# exposed by the server.
+# -----------------------------------------------------------------------------
+
+class InvalidService(ProgrammingError):
+ pass
+
+# -----------------------------------------------------------------------------
+# An invalid parameter was passed to a RPC
+# -----------------------------------------------------------------------------
+
+class InvalidParameter(ProgrammingError):
+ pass
+
+# -----------------------------------------------------------------------------
+# An error which has occured on the server and which is
+# raised again on the server
+# -----------------------------------------------------------------------------
+
+class DistantError(Error):
+ pass
+
+# =============================================================================
+# Self test code - requires server.py running
+# =============================================================================
+
+if __name__ == '__main__':
+
+ connection = attach ('py_xmlrpc', {})
+
+ obj = connection.request ('test')
+
+ print 'stringtest:', repr (obj.stringtest ())
+ print 'ustringtest:', repr (obj.ustringtest ())
+ print 'inttest:', repr (obj.inttest ())
+ print 'floattest:', repr (obj.floattest ())
+ print 'datetimetest:', repr (obj.datetimetest ())
+ print 'booltest:', repr (obj.booltest ())
+ subobj = obj.objtest ()
+ print 'objtest:', repr (subobj)
+# print 'subobj.test'
+# subobj.test ()
+ del subobj
+
+ print 'shutting donwn server ...'
+ try:
+ # This will raise an exception because the server will not even answer any
+ # more. Need to find a better way to shutdown the server.
+ obj.shutdown ()
+ except:
+ pass
Property changes on: trunk/gnue-common/src/rpc/client.py
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: trunk/gnue-common/src/rpc/drivers/Base.py (from rev 5312,
trunk/gnue-common/src/rpc/GCommBase.py)
===================================================================
--- trunk/gnue-common/src/rpc/GCommBase.py 2004-03-12 18:21:38 UTC (rev
5312)
+++ trunk/gnue-common/src/rpc/drivers/Base.py 2004-03-19 00:01:36 UTC (rev
5353)
@@ -0,0 +1,303 @@
+# GNU Enterprise RPC interface - Base for all drivers
+#
+# Copyright 2001-2004 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+from types import *
+
+import string
+import sys
+import thread
+import traceback
+import urlparse
+
+from gnue.common.apps import GDebug
+
+# =============================================================================
+# Client adapter
+# =============================================================================
+
+class Client:
+ """
+ Basic client adapter
+ """
+ _default_transport = None
+ _default_host = 'localhost'
+ _default_port = None
+ _default_path = '/'
+
+ # ---------------------------------------------------------------------------
+ # Initialize object
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, params):
+
+ checktype (params, DictionaryType)
+
+ self._url = None
+ self._transport = None
+ self._host = None
+ self._port = None
+ self._path = None
+
+ if params.has_key ('url'):
+
+ # Connection defined as URL
+ (self._transport, netloc, self._path, params, query, fragment) \
+ = urlparse.urlparse (params ['url'])
+ (self._host, self._port) = split (netloc, ':', 1)
+
+ else:
+
+ # Connection defined as transport/host/port/path info
+ if params.has_key ('transport'): self._transport = params ['transport']
+ if params.has_key ('host' ): self._host = params ['host' ]
+ if params.has_key ('port' ): self._port = params ['port' ]
+ if params.has_key ('path' ): self._path = params ['path' ]
+
+ # If some info isn't given, fall back to default values
+ if not self._transport: self._transport = self._default_transport
+ if not self._host: self._host = self._default_host
+ if not self._port: self._port = self._default_port
+ if not self._path: self._path = self._default_path
+
+ # Make sure port is an integer
+ self._port = int (self._port)
+
+ # Now build the full URL
+ self._url = '%s://%s:%d%s' % (self._transport, self._host, self._port,
+ self._path)
+
+ if params.has_key ('timeout'):
+ self._timeout = params ['timeout']
+ else:
+ self._timeout = 1.0
+
+ self.__open = True
+
+ # ---------------------------------------------------------------------------
+ # Set timeout
+ # ---------------------------------------------------------------------------
+
+ def setTimeout (self, timeout):
+
+ self._timeout = timeout
+
+ # ---------------------------------------------------------------------------
+ # Request a (static) proxy object
+ # ---------------------------------------------------------------------------
+
+ def request (self, service):
+
+ return ProxyObject (self, service, False)
+
+ # ---------------------------------------------------------------------------
+ # Close the connection
+ # ---------------------------------------------------------------------------
+
+ def close ():
+ """
+ Close the connection to the server
+ """
+ if self.__open:
+ self._close ()
+
+ # ---------------------------------------------------------------------------
+ # Clean up
+ # ---------------------------------------------------------------------------
+
+ def __del__ (self):
+
+ if self.__open:
+ self._close ()
+
+ # ---------------------------------------------------------------------------
+ # Run a procedure on the server (abstract)
+ # ---------------------------------------------------------------------------
+
+ def _runMethod (self, method, *args, **params):
+ """
+ execute a remote method
+ """
+ pass
+
+ # ---------------------------------------------------------------------------
+ # Close the server (virtual)
+ # ---------------------------------------------------------------------------
+
+ def _close (self):
+
+ pass
+
+ # ---------------------------------------------------------------------------
+ # Create a dynamic proxy object
+ # ---------------------------------------------------------------------------
+
+ def _createproxy (self, service):
+
+ return ProxyObject (self, service, True)
+
+# =============================================================================
+# Proxy object for clients
+# =============================================================================
+
+class ProxyObject:
+
+ # ---------------------------------------------------------------------------
+ # Initialize proxy object
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, adapter, service, dynamic):
+
+ self.__adapter = adapter
+ self.__service = service
+ self.__dynamic = dynamic
+
+ # ---------------------------------------------------------------------------
+ # Get a (proxy) method
+ # ---------------------------------------------------------------------------
+
+ def __getattr__ (self, attr):
+
+ if attr[0] == '_':
+ raise AttributeError, attr
+
+ method = ProxyMethod (self.__adapter, self.__service + '.' + attr)
+ self.__dict__ [attr] = method
+ return method
+
+ # ---------------------------------------------------------------------------
+ # Set an object attribute (must start with '_')
+ # ---------------------------------------------------------------------------
+
+ def __setattr__ (self, attr, value):
+
+ # FIXME: what do we need this for?
+
+ if attr[0] == '_':
+ self.__dict__[attr] = value
+ else:
+ raise AttributeError, attr
+
+ # ---------------------------------------------------------------------------
+ # Clean up
+ # ---------------------------------------------------------------------------
+
+ def __del__ (self):
+
+ if self.__dynamic:
+ self.__adapter._runMethod (self.__service + '._close')
+
+# =============================================================================
+# Proxy method for clients
+# =============================================================================
+
+class ProxyMethod:
+
+ # ---------------------------------------------------------------------------
+ # Initialize proxy method
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, adapter, methodname):
+
+ self._adapter = adapter
+ self._methodname = methodname
+
+ # ---------------------------------------------------------------------------
+ # Run the method
+ # ---------------------------------------------------------------------------
+
+ def __call__ (self, *args, **params):
+ return self._adapter._runMethod (self._methodname, *args, **params)
+
+# =============================================================================
+# Server adapter
+# =============================================================================
+
+class Server:
+ """
+ Basic server adapter
+ """
+ _default_transport = None
+ _default_port = None
+
+ # ---------------------------------------------------------------------------
+ # Initialize server object
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, rpcdef, bindings, params):
+ self._bindings = bindings
+ self._rpcdef = rpcdef
+
+ checktype (params, DictionaryType)
+
+ self._transport = None
+ self._port = None
+
+ if params.has_key ('transport'): self._transport = params ['transport']
+ if params.has_key ('port' ): self._port = params ['port' ]
+
+ # If some info isn't given, fall back to default values
+ if not self._transport: self._transport = self._default_transport
+ if not self._port: self._port = self._default_port
+
+ # Make sure port is an integer
+ self._port = int (self._port)
+
+ # ---------------------------------------------------------------------------
+ # Start server
+ # ---------------------------------------------------------------------------
+
+ def serve (self):
+ pass
+
+ # ---------------------------------------------------------------------------
+ # Start server as new thread
+ # ---------------------------------------------------------------------------
+
+ def serveAsNewThread (self):
+ thread.start_new_thread (self.serve, ())
+
+ # ---------------------------------------------------------------------------
+ # Return an exception
+ # ---------------------------------------------------------------------------
+
+ def raiseException(self, exception, message, event=None):
+ raise exception, message
+
+# =============================================================================
+# Support to pass exception over the wire
+# =============================================================================
+
+# TODO: write a decode exception, or a function to build a fake traceback
+
+def encodeExc():
+ exc = sys.exc_info()
+
+ GDebug.printMesg(1,'RPC detected Exception of type "%s", value: "%s".' % \
+ (exc[0],exc[1]))
+
+ error = string.join(traceback.format_exception(exc[0],exc[1], exc[2]),'\n')
+
+ # remove exception object, because garbage collector can't remove it
+ del(exc)
+
+ return error
Property changes on: trunk/gnue-common/src/rpc/drivers/Base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-common/src/rpc/drivers/__init__.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/__init__.py 2004-03-18 23:07:27 UTC
(rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/__init__.py 2004-03-19 00:01:36 UTC
(rev 5353)
@@ -1 +1 @@
-DRIVERS = [ 'xmlrpc','proxy','sockets','corba','soap','pyro']
+DRIVERS = [ 'xmlrpc','proxy','sockets','soap','pyro']
Property changes on: trunk/gnue-common/src/rpc/drivers/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-common/src/rpc/drivers/_helpers/AsyncSocketServer.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/_helpers/AsyncSocketServer.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/_helpers/AsyncSocketServer.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -29,7 +29,7 @@
# Pretty cool, eh?
#
-from gnue.common.rpc.drivers import GCommBase
+from gnue.common.rpc.drivers import Base
import asyncore
import asynchat
@@ -39,10 +39,10 @@
from gnue.common.apps import GDebug
-class AsyncSocketServer(GCommBase.Server):
+class AsyncSocketServer(Base.Server):
def __init__(self, bindings, params):
- GCommBase.Server.__init__(self, bindings, params)
+ Base.Server.__init__(self, bindings, params)
# TODO: This should probably allow you to connect
# TODO: to both a Unix-style socket file and to a
Property changes on:
trunk/gnue-common/src/rpc/drivers/_helpers/AsyncSocketServer.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-common/src/rpc/drivers/_helpers/DirectoryServer.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/_helpers/DirectoryServer.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/_helpers/DirectoryServer.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -28,19 +28,17 @@
#
-from gnue.common.rpc import GComm
from gnue.common.apps import GDebug
-from gnue.common.rpc import GCommBase
+from gnue.common.rpc.drivers import Base
import string
##############################################################################
#
# ServerAdapter
#
-class DirectoryServer(GCommBase.Server):
+class DirectoryServer(Base.Server):
def __init__(self, rpcdef, bindings, params):
- self._bindings = bindings
- self._rpcdef = rpcdef
+ Base.Server.__init__ (self, rpcdef, bindings, params)
# Keep a directory of all methods we expose and
# various attributes of those methods (such as
Property changes on:
trunk/gnue-common/src/rpc/drivers/_helpers/DirectoryServer.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/_helpers/ObjectEnabler.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
trunk/gnue-common/src/rpc/drivers/_helpers/ObjectLibrarian.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/_helpers/RpcDoc.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/_helpers/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/proxy/CommDriver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/proxy/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-common/src/rpc/drivers/pyro/ClientAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/pyro/ClientAdapter.py 2004-03-18
23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/pyro/ClientAdapter.py 2004-03-19
00:01:36 UTC (rev 5353)
@@ -281,20 +281,6 @@
#
class _ProxyObject(GCommBase.ProxyObject):
-
- # 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???
- exception = _lookup[name]
- raise exception, text
- else:
- # TODO:
- raise StandardError, data.message
-
def __call__(self, *args, **params):
if not hasattr(self,'_parent'):
return
Property changes on: trunk/gnue-common/src/rpc/drivers/pyro/ClientAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: trunk/gnue-common/src/rpc/drivers/pyro/CommDriver.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/pyro/CommDriver.py 2004-03-18
23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/pyro/CommDriver.py 2004-03-19
00:01:36 UTC (rev 5353)
@@ -1,57 +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:
-# pyro/CommDriver.py
-#
-# DESCRIPTION:
-# Class that implements the PYRO driver for GNUe Comm.
-#
-# NOTES:
-# http://pyro.sourceforge.net/
-
-
-#
-# We provide both a client and a server driver
-#
-CLIENT = 1 # ClientDriver
-SERVER = 1 # ServerDriver
-
-from gnue.common.rpc.drivers import GCommBase
-
-try:
- import pyro
-except ImportError:
- print _("\nUnable to load pyro. To use the PYRO interface, \n") \
- + _("please install Pyro from:\n") \
- + " http://pyro.sourceforge.net/\n"
- sys.exit()
-
-
-
-class ClientAdapter(GCommBase.Client):
- pass
-
-
-class ServerAdapter(GCommBase.Server):
-
- def raiseException(self, exception, message):
- raise exception, message
-
Property changes on: trunk/gnue-common/src/rpc/drivers/pyro/Driver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/pyro/ServerAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/pyro/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/soap/CommDriver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/soap/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/soap/soappy/Driver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/sockets/CommDriver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/sockets/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/xmlrpc/RpcDoc.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-common/src/rpc/drivers/xmlrpc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
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-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -1,4 +1,7 @@
+# GNU Enterprise RPC interface - Pythonware-XMLRPC client adapter
#
+# Copyright 2001-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,14 +19,8 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# xmlrpc/ClientAdapter.py
-#
-# DESCRIPTION:
-# Set of classes that implement the XML-RPC client adapter for GNUe Comm.
-#
+# $Id$
+
# NOTES:
# Requires xmlrpclib from http://www.pythonware.com/products/xmlrpc/
# or Python 2.2
@@ -38,181 +35,66 @@
# port The port that the service is located on
#
-
-
-#
# We provide a client driver...
-#
CLIENT = 1 # ClientAdapter
-try:
+import string
+import sys
- # xmlrpclib could be in a package, so try both
- try:
- import xmlrpclib
- except ImportError:
- from 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/"
- raise GComm.AdapterInitializationError, tmsg
-
-
-from gnue.common.rpc import GComm, GCommBase
-from gnue.common.apps import GConfig, GDebug
from gnue import paths
+from gnue.common.apps import GDebug
+from gnue.common.rpc import client
+from gnue.common.rpc.drivers import Base
-import string, sys
-
-#
-# i18n support
-#
-import gettext
-
try:
- gettext.install('gnue',paths.data+'share/locale')
-except IOError:
- GDebug.printMesg(1,'Unable to load locale information falling back to
default English language translations.')
- import __builtin__
- __builtin__.__dict__['_'] = lambda string:string
-
+ 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/")
+ raise client.AdapterInitializationError, tmsg
-##############################################################################
-#
-# ClientAdapter
-#
-class ClientAdapter(GCommBase.Client):
+import typeconv
- def __init__(self, params):
+# =============================================================================
+# Client driver
+# =============================================================================
+class ClientAdapter (Base.Client):
- try:
+ _default_transport = 'http'
+ _default_port = 8765
- try:
- url = params['url']
- if not len(url):
- raise KeyError
- except KeyError:
- try:
- transport = params['transport']
- except KeyError:
- transport = 'https'
+ # ---------------------------------------------------------------------------
+ # Initialize object
+ # ---------------------------------------------------------------------------
- url = "%s://%s:%s/" % \
- ( transport, params['host'], params['port'] )
+ def __init__ (self, params):
+ Base.Client.__init__ (self, params)
+ # create the real xmlrpc client
+ self.__proxy = xmlrpclib.Server (self._url)
- # add an list to store references to proxys for dyn. objects
- self._objectProxys=[]
+ # ---------------------------------------------------------------------------
+ # Run a procedure on the server
+ # ---------------------------------------------------------------------------
- self._server = xmlrpclib.Server(url)
-
-
- except KeyError:
- tmsg = _("To use XML-RPC, you must either specify a 'url' or\n") +\
- _("a 'host' and 'port' setting.")
- raise GComm.AdapterConfigurationError, tmsg
- except:
- tmsg = _("Unable to initialize the XML-RPC interface at %s") % url
- raise GComm.AdapterInitializationError, tmsg
-
-
- def request(self, service, params={}):
- self._baseproxy = _ProxyObject(self, service, \
- servicer=self._server.__getattr__(service))
- return self._baseproxy
-
- def close(self):
- # do a cleanup of the proxy objects and the object stubs
- # on the XMLRPC server side
-
- # 1. close the proxy objects for services (static, client only)
- self._baseproxy=None
+ def _runMethod (self, method, *args, **params):
- # 2. close the proxy objects for objects (dynamic, client+server)
- for i in self._objectProxys:
- i._close()
- self._objectProxys=[]
-
- # close the client it self
- self._client=None
+ __args = [typeconv.python_to_rpc (arg, client.InvalidParameter)
+ for arg in args]
- # just in case the user forgot to delete some objects
- def __del__(self):
- if self._client!=None:
- self.close()
-
- def setTimeout(self,timeout):
- self._timeout=timeout
-
-
- def runMethod(self, method, *args, **params):
- # print "Calling method: %s with attr %s " % method,string.join(args,",")
-
- # check for special parameters
- i=0
- while i<len(args):
- # care for special types
- if hasattr(args[i],'_type'):
- if args[i]._type=='base64':
- args[i]=xmlrpclib.Binary(args[i]._value)
- elif args[i]._type=='binary':
- args[i]=xmlrpclib.Binary(args[i]._value)
- elif args[i]._type=='boolean':
- args[i]=xmlrpc.Boolean(args[i]._value)
- elif args[i]._type=='datetime':
- args[i]=xmlrpc.Datetime(args[i]._value)
- else:
- if hasattr(args[i],'_value'):
- args[i]=args[i]._value
- i=i+1
-
-
- to_call=getattr(self._server,method);
+ to_call = getattr (self.__proxy, method);
- result=to_call.__call__(*args, **params)
- # print "the result is",result,"of type",type(result)
-
- # check, if an object handle is send
+ result = to_call (*__args, **params)
+
+ # check, if an object handle is sent
# TODO: make a better check
if type(result)==type("String") and len(result)==40 :
- # create an proxy for this handle
- result = _ProxyObject(self, "[%s]" % result)
- # store proxy in list
- self._objectProxys.append(result)
-
- return result
+ # create an proxy for this handle
+ return self._createproxy ("[%s]" % result)
-
-
-
-##############################################################################
-#
-# ProxyObject
-#
-class _ProxyObject(GCommBase.ProxyObject):
-
-
- # 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???
- exception = _lookup[name]
- raise exception, text
else:
- # TODO:
- raise StandardError, data.message
-
-
- def _close(self):
- # if it is a dynamic object then close it
- if self._attrPath==[self._attr]:
- self._adapter.runMethod(self._attr+'._close')
-
+ return typeconv.rpc_to_python (result, client.InvalidParameter)
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ClientAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/Driver.py
___________________________________________________________________
Name: svn:keywords
+ Id
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-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -41,10 +41,10 @@
#
SERVER = 1 # ServerAdapter
-from gnue.common.rpc import GComm
+from gnue.common.rpc import server
from gnue.common.apps import GDebug
from gnue.common.rpc.drivers._helpers import ObjectLibrarian, DirectoryServer
-from gnue.common.rpc.GCommBase import encodeExc
+from gnue.common.rpc.drivers.Base import encodeExc
from BaseHTTPServer import BaseHTTPRequestHandler;
from SimpleHTTPServer import SimpleHTTPRequestHandler;
@@ -52,6 +52,8 @@
import string, sys, os, posixpath, urllib, socket
+import typeconv
+
try:
# xmlrpclib could be in a package, so try both
@@ -64,7 +66,7 @@
tmsg = _("\nUnable to load xmlrpclib. To use the XML-RPC interface, \n") \
+ _("please install xmlrpc from:\n") \
+ " http://www.pythonware.com/products/xmlrpc/"
- raise GComm.AdapterInitializationError, tmsg
+ raise server.AdapterInitializationError, tmsg
# Mapping from GRPC's datatype to XML-RPC datatypes
@@ -126,7 +128,7 @@
self._port = params['port']
except KeyError:
tmsg = _('Required parameter "port" not supplied')
- raise GComm.AdapterConfigurationError, tmsg
+ raise server.AdapterConfigurationError, tmsg
if params.has_key('bindto'):
self._bindto = params['bindto']
@@ -157,7 +159,7 @@
# elif params['servertype']=='asyncore':
# self._httpserver=MyAsyncoreDispatcher
else:
- raise GComm.AdapterConfigurationError, \
+ raise server.AdapterConfigurationError, \
_('Value %s for parameter "servertype" is not supported.') \
% params['servertype'] + _('Valid values are: threading,'+ \
'forking.') # ',asyncore.')
@@ -307,11 +309,15 @@
# check if it is an real method (binding -> method)
# or an get/set method for an attribut (binding-> attribut)
+ __params = typeconv.rpc_to_python (params, server.InvalidParameter)
+
if (server_method!=None):
# call method with params
- result=server_method(*params)
+ result=server_method(*__params)
+ result = typeconv.python_to_rpc (result, server.InvalidParameter)
+
# check if it's the close object method
elif (method=="_close"):
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/ServerAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/typeconv.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/typeconv.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/typeconv.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -0,0 +1,131 @@
+# GNU Enterprise RPC interface - Py-XMLRPC type conversion rules
+#
+# Copyright 2001-2004 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import types
+import mx.DateTime
+import xmlrpclib
+
+# -----------------------------------------------------------------------------
+# Convert native Python type to xmlrpc's type
+# -----------------------------------------------------------------------------
+
+def python_to_rpc (value, exception):
+
+ # None
+ if value is None:
+ return ''
+
+ # String
+ elif isinstance (value, types.StringType):
+ return value
+ elif isinstance (value, types.UnicodeType):
+ return value
+
+ # Number
+ elif isinstance (value, types.IntType):
+ return value
+ elif isinstance (value, types.FloatType):
+ return value
+
+ # Date/Time
+ elif isinstance (value, mx.DateTime.DateTimeType):
+ return xmlrpclib.DateTime ((value.year, value.month, value.day, value.hour,
+ value.minute, int (value.second), 0, 0, 0))
+
+ # Boolean
+ elif hasattr (types, 'BooleanType') and \
+ isinstance (value, types.BooleanType):
+ return xmlrpclib.boolean (value)
+
+ # List
+ elif isinstance (value, types.ListType):
+ return [python_to_rpc (element, exception) for element in value]
+
+ # Tuple
+ elif isinstance (value, types.TupleType):
+ result = ()
+ for element in value:
+ result += (python_to_rpc (element, exception), )
+ return result
+
+ # Dictionary
+ elif isinstance (value, types.DictionaryType):
+ result = {}
+ for (key, val) in value.items ():
+ result [python_to_rpc (key, exception)] = python_to_rpc (val, exception)
+ return result
+
+ else:
+ raise exception, repr (value)
+
+# -----------------------------------------------------------------------------
+# Convert xmlrpc's type to native Python type
+# -----------------------------------------------------------------------------
+
+def rpc_to_python (value, exception):
+
+ # None or String
+ if isinstance (value, types.StringType) or \
+ isinstance (value, types.UnicodeType):
+ if value:
+ return value
+ else:
+ return None
+
+ # Number
+ elif isinstance (value, types.IntType):
+ return value
+ elif isinstance (value, types.FloatType):
+ return value
+
+ # Date/Time
+ elif isinstance (value, xmlrpclib.DateTime):
+ return mx.DateTime.strptime (value.value, '%Y%m%dT%H:%M:%S')
+
+ # Boolean
+ elif isinstance (value, xmlrpclib.boolean):
+ if value:
+ return True
+ else:
+ return False
+
+ # List
+ elif isinstance (value, types.ListType):
+ return [rpc_to_python (element, exception) for element in value]
+
+ # Tuple
+ elif isinstance (value, types.TupleType):
+ result = ()
+ for element in value:
+ result += (rpc_to_python (element, exception), )
+ return result
+
+ # Dictionary
+ elif isinstance (value, types.DictionaryType):
+ result = {}
+ for (key, val) in value.items ():
+ result [python_to_rpc (key, exception)] = python_to_rpc (val, exception)
+ return result
+
+ else:
+ raise exception, repr (value)
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/pw_xmlrpc/typeconv.py
___________________________________________________________________
Name: svn:keywords
+ Id
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-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -1,4 +1,7 @@
+# GNU Enterprise RPC interface - Py-XMLRPC client adapter
#
+# Copyright 2001-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,15 +19,8 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# xmlrpc/ClientAdapter.py
-#
-# DESCRIPTION:
-# Set of classes that implement the XML-RPC client adapter for GNUe Comm.
-#
-# NOTES:
+# $Id$
+
# Requires py-xmlrpc from http://sourceforge.net/Projects/py-xmlrpc
#
# Client Parameters:
@@ -37,319 +33,121 @@
# port The port that the service is located on
#
-
-
-#
# We provide a client driver...
-#
-CLIENT = 1 # Client Adapter
+CLIENT = 1
+import sys
+import types
+import mx.DateTime
-from gnue.common.rpc import GCommBase
-from gnue.common.rpc import GComm
-from gnue.common.apps import GConfig, GDebug
-from gnue import paths
+from gnue.common.rpc import client
+from gnue.common.rpc.drivers import Base
-import string, sys
-
-#
-# i18n support
-#
-import gettext
-
try:
- gettext.install('gnue',paths.data+'/share/locale')
-except IOError:
- GDebug.printMesg(1,'Unable to load locale information falling back to
default English language translations.')
- import __builtin__
- __builtin__.__dict__['_'] = lambda string:string
-
-try:
-
- # xmlrpclib could be in a package, so try both
- try:
- import xmlrpc
- except ImportError:
- from xmlrpc import xmlrpc
-
+ import xmlrpc
except ImportError:
- tmsg = _("\nUnable to load xmlrpc. To use the XML-RPC interface, \n") \
- + _("please install xmlrpc from:\n") \
- + " http://sourceforge.net/projects/py-xmlrpc " \
- + _("the appropriate DEBIAN package is python-xmlrpc.deb")
- raise GComm.AdapterInitializationError, tmsg
+ tmsg = _("\nUnable to load xmlrpc. To use the XML-RPC interface, \n"
+ "please install xmlrpc from:\n"
+ " http://sourceforge.net/projects/py-xmlrpc\n"
+ "the appropriate DEBIAN package is python-xmlrpc.deb")
+ raise client.AdapterInitializationError, tmsg
+import typeconv
-##############################################################################
-#
-# ClientAdapter
-#
-class ClientAdapter(GCommBase.Client):
+# =============================================================================
+# Client driver
+# =============================================================================
- def __init__(self, params):
+class ClientAdapter(Base.Client):
- self._timeout = 1.0
-
- #
- # check for the correct parameters
- #
-
- try:
+ _default_transport = 'http'
+ _default_port = 8765
- #
- # test for an url parameter
- #
- try:
- url = params['url']
- if not len(url):
- raise KeyError
+ # ---------------------------------------------------------------------------
+ # Initialize object
+ # ---------------------------------------------------------------------------
- # split url into server + host + path parts
- import urlparse
-
- transport, netloc, path, params, query, fragment = \
- urlparse.urlparse(url)
- host, port=split(netloc,':',1)
-
- except KeyError:
- #
- # transport parameter
- #
- try:
- transport = params['transport']
- except KeyError:
- transport = 'http'
+ def __init__ (self, params):
- if (transport!='http'):
- tmsg = _("py-xmlrpc just support http as a transport. ") +\
- _("If you need https please have a look at the ") +\
- _("'pw_xmlrpc' adapter.")
- raise GComm.AdapterConfigurationError, tmsg
- #
- # path parameter
- #
- try:
- path = params['path']
- except KeyError:
- path = '/'
+ Base.Client.__init__ (self, params)
- #
- # port parameter
- #
- try:
- port = params['port']
- except KeyError:
- port = 8765
-
-
- #
- # host parameter
- #
- try:
- host = params['host']
- except KeyError:
- host = 'localhost'
+ if (self._transport != 'http'):
+ msg = _("py-xmlrpc only supports http as a transport. If you need "
+ "https, please have a look at the 'pw_xmlrpc' adapter.")
+ raise client.AdapterConfigurationError, msg
-
+ # setLoglevel
+ if hasattr (params, 'loglevel'):
+ xmlrpc.setLogLevel (params ['loglevel'])
+ else:
+ xmlrpc.setLogLevel (0)
- self._url = "%s://%s:%s%s" % \
- ( transport, params['host'], port,path )
-
- # setLoglevel
- if hasattr(params,'loglevel'):
- xmlrpc.setLogLevel(params['loglevel'])
- else:
- xmlrpc.setLogLevel(0)
+ # create the real xmlrpc client
+ self._client = xmlrpc.client (self._host, self._port, self._path)
- # care for non-integer port settings
- if type(port)!=type(12):
- port=string.atoi(port)
+ # ---------------------------------------------------------------------------
+ # Run a procedure on the server
+ # ---------------------------------------------------------------------------
- # add an list to store references to proxys for dyn. objects
- self._objectProxys=[]
-
- # create the real xmlrpc client
- self._client = xmlrpc.client(host,port,path)
-
- # add an error handler ( is disabled because of wrong c implementation)
- # self._client.setOnErr(self.errorHandler)
+ def _runMethod (self, method, *args, **params):
- except KeyError:
- tmsg = _("To use XML-RPC, you must either specify a 'url' or\n") +\
- _("a 'host' and 'port' setting.")
- raise GComm.AdapterConfigurationError, tmsg
- except:
- tmsg = _("Unable to initialize the XML-RPC interface at %s") % url
- raise GComm.AdapterInitializationError, tmsg
+ __args = [typeconv.python_to_rpc (arg, client.InvalidParameter)
+ for arg in args]
+ result = self._client.execute (method, __args, self._timeout)
- def request(self, service, params={}):
- # TODO: add support for more than one baseproxy
- self._baseproxy = _ProxyObject(self, service)
- return self._baseproxy
+ # FIXME: catch Exceptions?
+# except:
+# if str(sys.exc_type)=="xmlrpc.error":
+# if sys.exc_value==(111, 'Connection refused'):
+# msg= _("Unable to connect to XML-RPC server ") + \
+# _("at '%s' \n(connection refused)\n") % self._url + \
+# _("please check if the server is running")
+# else:
+# msg="Error: %s" % (sys.exc_value,)
+#
+# print
+# print "********************************************\n"
+# print msg,"\n\n"
+# print "********************************************"
+# sys.exit(0)
+#
+# elif str(sys.exc_type)=="xmlrpc.fault":
+# #
+# # Distinguish between different kinds of distant RPC errors
+# #
+#
+# # catch unknown service faults created by xmlrpc/ServerAdapter
+# if sys.exc_value.faultString[:30]=='xmlrpc.error: unknown command:':
+# msg=_("Service/Command %s does not exist on the server")\
+# % sys.exc_value.faultString[31:]
+# raise client.InvalidService,msg,sys.exc_traceback
+#
+# # catch unknown service faults created by pw_xmlrpc/ServerAdapter
+# elif sys.exc_value.faultString[:26]== \
+# 'exceptions.AttributeError:':
+# msg="%s"\
+# % sys.exc_value.faultString[26:]
+# raise client.InvalidService,msg,sys.exc_traceback
+#
+# # catch every other distant error
+# else:
+# msg =_("Error '%s' occured on server connected"+ \
+# " by XMLRPC") % sys.exc_value.faultString
+# raise client.DistantError,msg,sys.exc_traceback
+#
+#
+# else:
+# raise client.Error, _("Unknown XMLRPC Error: '%s' of type '%s'") % \
+# (sys.exc_value, sys.exc_type), \
+# sys.exc_traceback
-
- def errorHandler(self,src, exc):
- # doesn't work correct, so is being disabled
- if exc[1]==(111, 'Connection refused'):
- # cannot raise a new error, so I try to change it
- exc=(GComm.AdapterInitializationError,
- _("Unable to initialize the XML-RPC interface at %s: ")\
- % src.getDesc() + _("Connection refused"), None )
- print "Connection to ",src.getDesc()," failed."
- print exc
- # sys.exit(0)
- #import traceback
- #sys.stderr.write()
- #traceback.print_exception(exc[0], exc[1], exc[2])
- #return xmlrpc.ONERR_KEEP_WORK
- return xmlrpc.ONERR_KEEP_DEF
-
- def close(self):
- # do a cleanup of the proxy objects and the object stubs
- # on the XMLRPC server side
-
- # 1. close the proxy objects for services (static, client only)
- self._baseproxy=None
-
- # 2. close the proxy objects for objects (dynamic, client+server)
- for i in self._objectProxys:
- i._close()
- self._objectProxys=[]
-
- # close the client it self
- self._client=None
-
- # just in case the user forgot to delete some objects
- def __del__(self):
- if self._client!=None:
- self.close()
- GCommBase.Client.__del__()
-
- def setTimeout(self,timeout):
- self._timeout=timeout
-
- def setAuthentification(self,name,passw):
- self._auth_name=name
- self._auth_passw=passw
-
-
- def runMethod(self, method, *args, **params):
- # print "Calling method: %s with attr %s " % method,string.join(args,",")
-
- # check for special parameters
- i=0
- while i<len(args):
- # care for special types
- if hasattr(args[i],'_type'):
- if args[i]._type=='base64':
- args[i]=xmlrpc.base64(args[i]._value)
- elif args[i]._type=='binary':
- args[i]=xmlrpc.base64(args[i]._value)
- elif args[i]._type=='boolean':
- args[i]=xmlrpc.boolean(args[i]._value)
- elif args[i]._type=='datetime':
- args[i]=xmlrpc.datetime(args[i]._value)
- else:
- if hasattr(args[i],'_value'):
- args[i]=args[i]._value
- i=i+1
-
-
- # call the method
- try:
- # send authentication info?
- if hasattr(self,'_auth_name'):
- result = self._client.execute(method, args, self._timeout, \
- self._auth_name, self._auth_passw)
- else:
- result = self._client.execute(method, args,self._timeout)
-
- except:
- if str(sys.exc_type)=="xmlrpc.error":
- if sys.exc_value==(111, 'Connection refused'):
- msg= _("Unable to connect to XML-RPC server ") + \
- _("at '%s' \n(connection refused)\n") % self._url + \
- _("please check if the server is running")
- else:
- msg="Error: %s" % (sys.exc_value,)
-
- print
- print "********************************************\n"
- print msg,"\n\n"
- print "********************************************"
- sys.exit(0)
-
- elif str(sys.exc_type)=="xmlrpc.fault":
- #
- # Distinguish between different kinds of distant RPC errors
- #
-
- # catch unknown service faults created by xmlrpc/ServerAdapter
- if sys.exc_value.faultString[:30]=='xmlrpc.error: unknown command:':
- msg=_("Service/Command %s does not exist on the server")\
- % sys.exc_value.faultString[31:]
- raise GComm.InvalidService,msg,sys.exc_traceback
-
- # catch unknown service faults created by pw_xmlrpc/ServerAdapter
- elif sys.exc_value.faultString[:26]== \
- 'exceptions.AttributeError:':
- msg="%s"\
- % sys.exc_value.faultString[26:]
- raise GComm.InvalidService,msg,sys.exc_traceback
-
- # catch every other distant error
- else:
- msg =_("Error '%s' occured on server connected"+ \
- " by XMLRPC") % sys.exc_value.faultString
- raise GComm.DistantError,msg,sys.exc_traceback
-
-
- else:
- raise GComm.Error, _("Unknown XMLRPC Error: '%s' of type '%s'") % \
- (sys.exc_value, sys.exc_type), \
- sys.exc_traceback
-
-
-
- # print "the result is",result,"of type",type(result)
-
- # check, if an object handle is send
+ # check, if an object handle is sent
# TODO: make a better check
if type(result)==type("String") and len(result)==40 :
-
- # create an proxy for this handle
- result = _ProxyObject(self, "[%s]" % result)
- # store proxy in list
- self._objectProxys.append(result)
-
- return result
+ # create an proxy for this handle
+ return self._createproxy ("[%s]" % result)
-
-
-
-##############################################################################
-#
-# ProxyObject
-#
-class _ProxyObject(GCommBase.ProxyObject):
-
-
- # 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???
- exception = _lookup[name]
- raise exception, text
else:
- # TODO:
- raise StandardError, data.message
-
- def _close(self):
- # if it is a dynamic object then close it
- if self._attrPath==[self._attr]:
- self._adapter.runMethod(self._attr+'._close')
+ return typeconv.rpc_to_python (result, client.InvalidParameter)
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ClientAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/Driver.py
___________________________________________________________________
Name: svn:keywords
+ Id
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-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -1,4 +1,7 @@
+# GNU Enterprise RPC interface - Py-XMLRPC client adapter
#
+# Copyright 2001-2004 Free Software Foundation
+#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
@@ -16,54 +19,38 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2001-2004 Free Software Foundation
-#
-# FILE:
-# xmlrpc/ServerAdapter.py
-#
-# DESCRIPTION:
-# Set of classes that implement the XML-RPC server driver for GNUe Comm.
-#
-# NOTES:
-# Requires py-xmlrpc from http://sf.net/projects/py-xmlrpc
-#
-#
+# $Id$
+
# Server Parameters:
#
# port The port that the service is located on
# loglevel Loglevel of the internal server
#
-
-
-##############################################################################
-#
# We provide a server driver...
-#
SERVER = 1 # ServerAdapter
+from types import *
-#from gnue.common.rpc.drivers._helpers.AsyncSocketServer import AsyncHTTPServer
+import string
+import sys
+import thread
+import traceback
-
-from gnue.common.rpc import GComm
from gnue.common.apps import GDebug
+from gnue.common.rpc import server
from gnue.common.rpc.drivers._helpers import ObjectLibrarian, ObjectEnabler,
DirectoryServer
-from gnue.common.rpc import GCommBase
-import string, sys, thread, traceback
-from types import UnicodeType
-
try:
import xmlrpc
-
except ImportError:
- tmsg = _("\nUnable to load xmlrpc. To use the XML-RPC interface, \n") \
- + _("please install xmlrpc from:\n") \
- + " http://sourceforge.net/projects/py-xmlrpc" \
- + _("the appropriate DEBIAN package is python-xmlrpc")
- raise GComm.AdapterInitializationError, tmsg
+ tmsg = _("\nUnable to load xmlrpc. To use the XML-RPC interface, \n"
+ "please install xmlrpc from:\n"
+ " http://sourceforge.net/projects/py-xmlrpc\n"
+ "the appropriate DEBIAN package is python-xmlrpc.deb")
+ raise server.AdapterInitializationError, tmsg
+import typeconv
# Mapping from GRPC's datatype to XML-RPC datatypes
_datatypeMap = {
@@ -76,56 +63,55 @@
'binary': 'base64'
}
+# =============================================================================
+# Server driver
+# =============================================================================
-##############################################################################
-#
-# ServerAdapter
-#
-class ServerAdapter(ObjectEnabler.ObjectEnabler):
+class ServerAdapter (ObjectEnabler.ObjectEnabler):
- def __init__(self, rpcdef, bindings, params):
+ _default_port = 8765
- ## Check parameters
- try:
- self._port = params['port']
- except KeyError:
- tmsg = _('Required parameter "port" not supplied')
- raise GComm.AdapterConfigurationError, tmsg
+ # ---------------------------------------------------------------------------
+ # Initialize object
+ # ---------------------------------------------------------------------------
+ def __init__ (self, rpcdef, bindings, params):
+
# Create Subserver
- self.server=XMLRPC_Server()
+ self.server = XMLRPC_Server ()
-
- ## Build up Service Directory and enable object dispatching
- ObjectEnabler.ObjectEnabler.__init__(self, rpcdef, \
- bindings, params)
-
- if hasattr(params,'loglevel'):
- self._loglevel = params['loglevel']
+ # Build up Service Directory and enable object dispatching
+ ObjectEnabler.ObjectEnabler.__init__ (self, rpcdef, bindings, params)
+
+ if hasattr (params,'loglevel'):
+ self._loglevel = params ['loglevel']
else:
self._loglevel = 1
+ xmlrpc.setLogLevel(self._loglevel)
- if params.has_key('httpbind'):
+ if params.has_key ('httpbind'):
GDebug.printMesg(0,"The Py-XMLRPC RPC Driver doesn't support http
access")
-
- xmlrpc.setLogLevel(self._loglevel)
-
- self.server.setParent(self)
- self.server.bindAndListen(self._port)
- self.server.setOnErr(self.OnErr)
- def serve(self):
- quit=0
- while quit==0:
+ self.server.setParent (self)
+ self.server.bindAndListen (self._port)
+ self.server.setOnErr (self.OnErr)
+
+ # ---------------------------------------------------------------------------
+ # Main loop
+ # ---------------------------------------------------------------------------
+
+ def serve (self):
+
+ quit = False
+ while not quit:
try:
- self.server.work()
+ self.server.work ()
# you could set a timeout if desired
except:
- e = sys.exc_info()
- if e[0] in (KeyboardInterrupt, SystemExit):
+ e = sys.exc_info ()
+ if e [0] in (KeyboardInterrupt, SystemExit):
# shut down server without showing error message
- quit=1
- # raise e[0], e[1], e[2]
+ quit = True
else:
print "*" * 60
print "Error occured on server:"
@@ -134,89 +120,125 @@
print "*" * 60
print "\n\n"
- def addRpMethod(self,object,parent,binding):
+ # ---------------------------------------------------------------------------
+ # Add an attribute to the dictionary
+ # ---------------------------------------------------------------------------
- DirectoryServer.DirectoryServer.addRpMethod(self,object, \
- parent,binding)
- self.server.addMethods({force_str(object._path):binding})
+ def OnErr (self, server, source):
+ print _("Internal server error occured:\n"+
+ " server %s \n on source %s.") % (server, source)
+ return xmlrpc.ONERR_KEEP_WORK
+
- def addRpAttribut(self,object,parent,binding):
+ # ---------------------------------------------------------------------------
+ # Call a method
+ # ---------------------------------------------------------------------------
- DirectoryServer.DirectoryServer.addRpAttribut(self,object,\
- parent,binding)
+ def call (self, method, params):
+ __params = typeconv.rpc_to_python (params, server.InvalidParameter)
+
+ result = ObjectEnabler.ObjectEnabler.call (self, method, params)
+
+ return typeconv.python_to_rpc (result, server.InvalidParameter)
+
+ # ---------------------------------------------------------------------------
+ # Add a method to the dictionary
+ # ---------------------------------------------------------------------------
+
+ def addRpMethod (self, object, parent, binding):
+
+ ObjectEnabler.ObjectEnabler.addRpMethod (self, object, parent, binding)
+
+ # Tell the server that the method exists
+ self.server.addMethods ({force_str (object._path): None})
+
+ # ---------------------------------------------------------------------------
+ # Add an attribute to the dictionary
+ # ---------------------------------------------------------------------------
+
+ def addRpAttribut (self, object, parent, binding):
+
+ ObjectEnabler.ObjectEnabler.addRpAttribut (self, object, parent, binding)
+
if not object.readonly:
# Add the set_* directory entry
- self.server.addMethods({force_str('%s.set_%s' % \
- (parent._path, object.name)):\
- binding})
+ self.server.addMethods ({force_str ('%s.set_%s' % \
+ (parent._path, object.name)): None})
if not object.writeonly:
# Add the get_* directory entry
- self.server.addMethods({force_str('%s.get_%s' % \
- (parent._path, object.name)):\
- binding})
+ self.server.addMethods ({force_str ('%s.get_%s' % \
+ (parent._path, object.name)): None})
+ # ---------------------------------------------------------------------------
+ # Register a newly created dynamic object
+ # ---------------------------------------------------------------------------
- def OnErr(self,server,source):
- print _("Internal server error occured:\n"+
- " server %s \n on source %s.") % (server,source)
- return xmlrpc.ONERR_KEEP_WORK
-
-
- def registerDynamicObject(self,objhandle,type):
+ def registerDynamicObject (self, objhandle, type):
#
# add new methods to the xmlrpc server
#
- tl=len(type)
- for i in self.directory.keys():
- if i[0:tl]==type:
- method=force_str("["+objhandle+"]"+i[tl:])
- GDebug.printMesg(1,'Method %s registered to py-xmlrpc ' \
- % method +\
- ' internal directory.')
- self.server.addMethods({method:None})
+ tl = len (type)
+ for i in self.directory.keys ():
+ if i [0:tl] == type:
+ method = force_str ("[" + objhandle + "]" + i [tl:])
+# GDebug.printMesg (1, 'Method %s registered to py-xmlrpc ' \
+ print 'Method %s registered to py-xmlrpc ' \
+ % method +\
+ ' internal directory.'
+ self.server.addMethods ({method: None})
# add a method to close this object
- self.server.addMethods({"["+objhandle+"]._close":None})
+ self.server.addMethods ({"["+objhandle+"]._close": None})
- def deregisterDynamicObject(self,object):
+ # ---------------------------------------------------------------------------
+ # Unregister a dynamic object
+ # ---------------------------------------------------------------------------
+
+ def deregisterDynamicObject (self, object):
#
# remove the new methods from the xmlrpc server
#
- objhandle=ObjectLibrarian.getObjectReference(object)
- type=object._type
- tl=len(type)
- for i in self.directory.keys():
- if i[0:tl]==type:
- method=force_str("["+objhandle+"]"+i[tl:])
- GDebug.printMesg(1,'Method %s is deleted from py-xmlrpc ' \
- % method +\
- ' internal directory.')
- self.server.removeMethods({method:None})
+ objhandle = ObjectLibrarian.getObjectReference (object)
+ type = object._type
+ tl = len (type)
+ for i in self.directory.keys ():
+ if i[0:tl] == type:
+ method = force_str ("[" + objhandle + "]" + i [tl:])
+ GDebug.printMesg (1, 'Method %s is deleted from py-xmlrpc ' \
+ % method + \
+ ' internal directory.')
+ self.server.removeMethods ({method:None})
# remove the method to close this object
- self.server.removeMethods({"["+objhandle+"]._close":None})
-
+ self.server.removeMethods ({"["+objhandle+"]._close": None})
-class XMLRPC_Server(xmlrpc.server):
- def setParent(self, parent):
- self._parent=parent
+# =============================================================================
+# Subclass of the xmlrpc server
+# =============================================================================
- def dispatch(self, servp, srcp, uri, method, params):
- return self._parent.call(method,params)
+class XMLRPC_Server (xmlrpc.server):
- def removeMethods(self, dict):
- d = {}
- for (name, func) in dict.items():
- del self.comtab[name]
+ # Remember parent
+ def setParent (self, parent):
+ self._parent = parent
+
+ # Do the actual call
+ def dispatch (self, servp, srcp, uri, method, params):
+ return self._parent.call (method, params)
+
+ # Remove methods of dynamic objects
+ def removeMethods (self, dict):
+ for (name, func) in dict.items ():
+ del self.comtab [name]
# TODO: remove method from internal comtab too
- # del self._o.comtab[name]
+ # del self._o.comtab [name]
# or
# self._o.removeMethods(d)
-def force_str(input):
+def force_str (input):
"""converts the parameter @input into a string
UnicodeTypes are converted to a utf-8 representation
"""
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/ServerAdapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/typeconv.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/typeconv.py
2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/typeconv.py
2004-03-19 00:01:36 UTC (rev 5353)
@@ -0,0 +1,134 @@
+# GNU Enterprise RPC interface - Py-XMLRPC type conversion rules
+#
+# Copyright 2001-2004 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import types
+import mx.DateTime
+import xmlrpc
+
+# -----------------------------------------------------------------------------
+# Convert native Python type to xmlrpc's type
+# -----------------------------------------------------------------------------
+
+def python_to_rpc (value, exception):
+
+ # None
+ if value is None:
+ return ''
+
+ # String
+ elif isinstance (value, types.StringType):
+ return value
+ elif isinstance (value, types.UnicodeType):
+ return value.encode ('utf-8')
+
+ # Number
+ elif isinstance (value, types.IntType):
+ return value
+ elif isinstance (value, types.FloatType):
+ return value
+
+ # Date/Time
+ elif isinstance (value, mx.DateTime.DateTimeType):
+ return xmlrpc.dateTime (value.year, value.month, value.day, value.hour,
+ value.minute, int (value.second))
+
+ # Boolean
+ elif hasattr (types, 'BooleanType') and \
+ isinstance (value, types.BooleanType):
+ if value:
+ return xmlrpc.boolean (True)
+ else:
+ return xmlrpc.boolean (False)
+
+ # List
+ elif isinstance (value, types.ListType):
+ return [python_to_rpc (element, exception) for element in value]
+
+ # Tuple
+ elif isinstance (value, types.TupleType):
+ result = ()
+ for element in value:
+ result += (python_to_rpc (element, exception), )
+ return result
+
+ # Dictionary
+ elif isinstance (value, types.DictionaryType):
+ result = {}
+ for (key, val) in value.items ():
+ result [python_to_rpc (key, exception)] = python_to_rpc (val, exception)
+ return result
+
+ else:
+ raise exception, repr (value)
+
+# -----------------------------------------------------------------------------
+# Convert xmlrpc's type to native Python type
+# -----------------------------------------------------------------------------
+
+def rpc_to_python (value, exception):
+
+ # None or String
+ if isinstance (value, types.StringType):
+ if value:
+ return unicode (value, 'utf-8')
+ else:
+ return None
+
+ # Number
+ elif isinstance (value, types.IntType):
+ return value
+ elif isinstance (value, types.FloatType):
+ return value
+
+ # Date/Time
+ elif type (value) == type (xmlrpc.dateTime (1999, 12, 31, 23, 59, 59)):
+ (year, month, day, hour, minute, second) = value.date ()
+ return mx.DateTime.DateTime (year, month, day, hour, minute, second)
+
+ # Boolean
+ elif type (value) == type (xmlrpc.boolean (0)):
+ if value:
+ return True
+ else:
+ return False
+
+ # List
+ elif isinstance (value, types.ListType):
+ return [rpc_to_python (element, exception) for element in value]
+
+ # Tuple
+ elif isinstance (value, types.TupleType):
+ result = ()
+ for element in value:
+ result += (rpc_to_python (element, exception), )
+ return result
+
+ # Dictionary
+ elif isinstance (value, types.DictionaryType):
+ result = {}
+ for (key, val) in value.items ():
+ result [python_to_rpc (key, exception)] = python_to_rpc (val, exception)
+ return result
+
+ else:
+ raise exception, repr (value)
Property changes on:
trunk/gnue-common/src/rpc/drivers/xmlrpc/py_xmlrpc/typeconv.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-common/src/rpc/server.py
===================================================================
--- trunk/gnue-common/src/rpc/server.py 2004-03-18 23:07:27 UTC (rev 5352)
+++ trunk/gnue-common/src/rpc/server.py 2004-03-19 00:01:36 UTC (rev 5353)
@@ -0,0 +1,299 @@
+# GNU Enterprise RPC interface - Server adapter
+#
+# Copyright 2001-2004 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+from types import *
+
+import string
+
+from gnue.common.apps import GDebug
+from gnue.common.utils.FileUtils import dyn_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
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Bind/export our services
+# -----------------------------------------------------------------------------
+
+# Attributes:
+#
+# rpcdef The RPC definition loaded from an XML file. This can be
+# 1) a string that contains the location of the XML file
+# (can be a URL or pathname)
+# 2) a file-handle (or file-like handle; e.g. StringBuffer)
+# referencing an XML definition
+# 3) a GnuRpc object created from GComm.loadDefinition()
+#
+# 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 i.e. {'DonutPlace',getDonutPlaceObj}
+
+def bind (rpcdef, drivers, bindings):
+
+ if isinstance (rpcdef, StringType):
+
+ # Application supplied the location of their rpcdef.. load it
+ fin = openResource (rpcdef)
+ mapping = loadDefinition (fin, 1)
+ fin.close ()
+
+ elif hasattr (rpcdef, 'read'):
+
+ # Application provided us a file-like object
+ mapping = loadDefinition (rpcdef)
+
+ else:
+
+ # Otherwise, they must have specified a GnuRpc object
+ mapping = rpcdef
+
+
+ servers = {}
+
+ 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
+
+ adapter = driver.ServerAdapter (mapping, bindings, 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.)
+
+# -----------------------------------------------------------------------------
+# Load an XML-based interface definition
+# -----------------------------------------------------------------------------
+
+from gnue.common.rpc.parser.Parser import loadDefinition
+
+# =============================================================================
+# Exceptions
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# The basis of all rpc.client 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
+
+# -----------------------------------------------------------------------------
+# Parent for all caller errors
+# -----------------------------------------------------------------------------
+
+class ProgrammingError(Error):
+ pass
+
+# -----------------------------------------------------------------------------
+# An invalid parameter was passed to a RPC
+# -----------------------------------------------------------------------------
+
+class InvalidParameter(ProgrammingError):
+ pass
+
+# =============================================================================
+# Self test code
+# =============================================================================
+
+if __name__ == '__main__':
+
+ import sys
+ import time
+ import StringIO
+ import mx.DateTime
+
+ class subobject:
+ def __init__ (self):
+ print "Initializing subobject"
+
+ def test (self):
+ print "Testing subobject"
+
+ def __del__ (self):
+ print "Destroying subobject"
+
+ class servertest:
+
+ def stringtest (self):
+ return 'This is a string'
+
+ def ustringtest (self):
+ return u'This is a unicode string with ����'
+
+ def inttest (self):
+ return 21
+
+ def floattest (self):
+ return 123.45
+
+ def datetimetest (self):
+ return mx.DateTime.now ()
+
+ def booltest (self):
+ return True
+
+ def objtest (self):
+ return subobject ()
+
+ def shutdown (self):
+ sys.exit (0)
+
+ rpcdef = StringIO.StringIO ('<gnurpc>'
+ '<service name="test" binding="test">'
+ '<method name="stringtest"/>'
+ '<method name="ustringtest"/>'
+ '<method name="inttest"/>'
+ '<method name="floattest"/>'
+ '<method name="datetimetest"/>'
+ '<method name="booltest"/>'
+ '<method name="objtest"/>'
+ '<method name="shutdown"/>'
+ '</service>'
+# '<service name="subobject"
binding="subobject">'
+# '<method name="test"/>'
+# '</service>'
+ '</gnurpc>')
+
+ drivers = {'py_xmlrpc': {'port': 8765}}
+
+ bindings = {'test': servertest}
+
+ servers = bind (rpcdef, drivers, bindings)
+
+ print 'Starting server ...'
+
+ (servers.values () [0]).serve ()
Property changes on: trunk/gnue-common/src/rpc/server.py
___________________________________________________________________
Name: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5353 - in trunk/gnue-common/src: datasources/drivers/appserver/appserver rpc rpc/drivers rpc/drivers/_helpers rpc/drivers/proxy rpc/drivers/pyro rpc/drivers/soap rpc/drivers/soap/soappy rpc/drivers/sockets rpc/drivers/xmlrpc rpc/drivers/xmlrpc/pw_xmlrpc rpc/drivers/xmlrpc/py_xmlrpc,
reinhard <=