commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src commdrivers/pw_xmlrpc/ClientAda...


From: Jan Ischebeck
Subject: gnue/common/src commdrivers/pw_xmlrpc/ClientAda...
Date: Sun, 09 Jun 2002 09:55:07 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  02/06/09 09:55:07

Modified files:
        common/src/commdrivers/pw_xmlrpc: ClientAdapter.py 
        common/src/commdrivers/xmlrpc: ClientAdapter.py 
        common/src     : GComm.py 

Log message:
        add special function for creating boolean/base64/datetime parameters on
        client side

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GComm.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: gnue/common/src/GComm.py
diff -c gnue/common/src/GComm.py:1.18 gnue/common/src/GComm.py:1.19
*** gnue/common/src/GComm.py:1.18       Mon May 27 14:06:45 2002
--- gnue/common/src/GComm.py    Sun Jun  9 09:55:07 2002
***************
*** 223,225 ****
--- 223,277 ----
    pass
  
  
+ 
+ #
+ # Some conversion functions to allow a client to describe the type of
+ # the argument that should be passed instead of autodetection
+ #
+ # 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:
+   def __init__(self,value):
+     self._type='string'
+     self._value=value
+ 
+ class none:
+   def __init__(self,value):
+     self._type='none'
+     self._value=value
Index: gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py
diff -c gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.5 
gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.6
*** gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.5  Thu Jun  6 
19:56:23 2002
--- gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py      Sun Jun  9 
09:55:06 2002
***************
*** 152,157 ****
--- 152,176 ----
    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);
          
      result=to_call.__call__(*args, **params)
Index: gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.10 
gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.11
*** gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.10    Thu Jun  6 
19:56:23 2002
--- gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py Sun Jun  9 09:55:07 2002
***************
*** 182,187 ****
--- 182,188 ----
  
  
    def request(self, service, params={}):
+     # TODO: add support for more than one baseproxy
      self._baseproxy = _ProxyObject(self, service)
      return self._baseproxy
  
***************
*** 233,238 ****
--- 234,260 ----
  
    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'):
***************
*** 247,253 ****
            msg= _("Unable to connect to XML-RPC server ") + \
                 _("at '%s' \n(connection refused)\n") % self._url + \
                 _("please check if the server is running")        
-           #raise GComm.CommunicationsError, msg
          else:
            msg="Error: %s" % (sys.exc_value,)
            
--- 269,274 ----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]