commit-gnue
[Top][All Lists]
Advanced

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

gnue-common/src/datasources/drivers/appserver/a...


From: Jan Ischebeck
Subject: gnue-common/src/datasources/drivers/appserver/a...
Date: Fri, 10 Oct 2003 07:36:14 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-common
Branch:         
Changes by:     Jan Ischebeck <address@hidden>  03/10/10 07:36:13

Modified files:
        src/datasources/drivers/appserver/appserver: Driver.py 

Log message:
        Appserver dbdriver updates:
        - convert Unicode values to utf-8 too (fix unicodeMode)
        - make unicodeMode datasource depend

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/datasources/drivers/appserver/appserver/Driver.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text

Patches:
Index: gnue-common/src/datasources/drivers/appserver/appserver/Driver.py
diff -c gnue-common/src/datasources/drivers/appserver/appserver/Driver.py:1.20 
gnue-common/src/datasources/drivers/appserver/appserver/Driver.py:1.21
*** gnue-common/src/datasources/drivers/appserver/appserver/Driver.py:1.20      
Thu Oct  9 17:27:49 2003
--- gnue-common/src/datasources/drivers/appserver/appserver/Driver.py   Fri Oct 
10 07:36:12 2003
***************
*** 44,50 ****
  import sys
  
  class Appserver_Connector:
!   def __init__(self, connectData, unicodeMode=0):
      
      user = connectData['_username']
      passwd = connectData['_password']
--- 44,50 ----
  import sys
  
  class Appserver_Connector:
!   def __init__(self, connectData):
      
      user = connectData['_username']
      passwd = connectData['_password']
***************
*** 62,69 ****
        GDebug.printMesg(1,"Appserver's dbdriver doesn't 'encoding' parameter, 
as the transport"+\
                         " encoding has to be 'utf-8'.")
  
-     self._unicodeMode=unicodeMode
-    
      #GDebug.printMesg(3,"Get the status of the session manager")
      #GDebug.printMesg(3,"Status: "+sessionManager.Status())
      
--- 62,67 ----
***************
*** 84,92 ****
    def cursor(self):
      return self._updateCursor
  
!   def request(self,table,filter,sort,fieldlist):
      listid = self._sm.request(self._sess_id,table,filter,sort,fieldlist)
!     return Appserver_ListCursor(self,listid,fieldlist)
  
    def call(self,classname,obj_id_list,methodname,parameters):
      self._sm.call(self._sess_id,classname,obj_id_list,methodname,parameters)
--- 82,90 ----
    def cursor(self):
      return self._updateCursor
  
!   def request(self,table,filter,sort,fieldlist,unicodeMode=0):
      listid = self._sm.request(self._sess_id,table,filter,sort,fieldlist)
!     return Appserver_ListCursor(self,listid,fieldlist,unicodeMode)
  
    def call(self,classname,obj_id_list,methodname,parameters):
      self._sm.call(self._sess_id,classname,obj_id_list,methodname,parameters)
***************
*** 103,113 ****
      self._sm.close(self._sess_id,commit)
  
  class Appserver_ListCursor:
!   def __init__(self,dataCon,listid,fieldlist):
      self._dataCon=dataCon
      self._listid=listid
      self._fieldlist=fieldlist
      self._stackpos=0
  
    def fetch(self,count=5):
      if self._stackpos == -1:
--- 101,112 ----
      self._sm.close(self._sess_id,commit)
  
  class Appserver_ListCursor:
!   def __init__(self,dataCon,listid,fieldlist,unicodeMode=0):
      self._dataCon=dataCon
      self._listid=listid
      self._fieldlist=fieldlist
      self._stackpos=0
+     self._unicodeMode=unicodeMode
  
    def fetch(self,count=5):
      if self._stackpos == -1:
***************
*** 137,143 ****
  
          # recode unicode strings to standart encoding
          if (type(value) == types.UnicodeType) and \
!                (not self._dataCon._unicodeMode):
            value = value.encode(gConfig('textEncoding'))
              
          dict[fieldName] = value
--- 136,142 ----
  
          # recode unicode strings to standart encoding
          if (type(value) == types.UnicodeType) and \
!                (not self._unicodeMode):
            value = value.encode(gConfig('textEncoding'))
              
          dict[fieldName] = value
***************
*** 158,168 ****
      # TODO: Implement List Close command
  
  class Appserver_UpdateCursor:
!   def __init__(self,dataCon):
      self._dataCon=dataCon
      self._deleteList={}
      self._updateList={}
      self._updateKeyList={}
  
    def delete(self,classname,id):
      if not self._deleteList.has_key(classname):
--- 157,168 ----
      # TODO: Implement List Close command
  
  class Appserver_UpdateCursor:
!   def __init__(self,dataCon,unicodeMode=0):
      self._dataCon=dataCon
      self._deleteList={}
      self._updateList={}
      self._updateKeyList={}
+     self._unicodeMode=unicodeMode
  
    def delete(self,classname,id):
      if not self._deleteList.has_key(classname):
***************
*** 174,187 ****
      if not self._updateList.has_key(classname):
         self._updateList[classname]=[]
         self._updateKeyList[classname]=[]
!        
      for key in fieldDict.keys():
        value=fieldDict[key]
        if type(value) == types.StringType:
!         if not self._dataCon._unicodeMode:
!           fieldDict[key] = 
unicode(value,gConfig('textEncoding')).encode('utf-8')
!         else:
!           fieldDict[key] = value.encode('utf-8')
         
      self._updateList[classname].append(fieldDict)
      self._updateKeyList[classname].append(id)
--- 174,195 ----
      if not self._updateList.has_key(classname):
         self._updateList[classname]=[]
         self._updateKeyList[classname]=[]
! 
!     # convert data to transfer encoding (utf-8)
      for key in fieldDict.keys():
        value=fieldDict[key]
+ 
+       # convert Strings from local encoding to 'utf-8'
        if type(value) == types.StringType:
!         fieldDict[key] = 
unicode(value,gConfig('textEncoding')).encode('utf-8')
! 
!         # raise Warning if running in unicode mode
!         if self._unicodeMode:
!           GDebug.printMesg(0,'WARNING: non-unicode passed to the dbdriver 
(%s)' % value)
!           
!       # recode unicode strings to 'utf-8'
!       elif type(value) == types.UnicodeType:
!         fieldDict[key] = value.encode('utf-8')
         
      self._updateList[classname].append(fieldDict)
      self._updateKeyList[classname].append(id)
***************
*** 363,369 ****
        raise GDataObjects.ConnectionError, err
  
      try:
!       listcursor = 
self._dataConnection.request(self.table,filter,sort,fieldlist)
      except Exception, msg:
        tmsg = _("Error during creation of object list \n\n --- %s ---)") % msg
        raise GDataObjects.ConnectionError, tmsg
--- 371,378 ----
        raise GDataObjects.ConnectionError, err
  
      try:
!       listcursor = 
self._dataConnection.request(self.table,filter,sort,fieldlist,\
!                                                 self._unicodeMode)
      except Exception, msg:
        tmsg = _("Error during creation of object list \n\n --- %s ---)") % msg
        raise GDataObjects.ConnectionError, tmsg




reply via email to

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