/[gnue]/gnue-common/src/datasources/drivers/DBSIG2/DataObject.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/DBSIG2/DataObject.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.3 by siesel, Sun Oct 12 19:47:15 2003 UTC revision 1.1.2.4 by jcater, Wed Nov 19 02:07:07 2003 UTC
# Line 33  Line 33 
33    
34  __all__ = ['DataObject','DataObject_SQL','DataObject_Object']  __all__ = ['DataObject','DataObject_SQL','DataObject_Object']
35    
36  from gnue.common.datasources import GDataObjects, GConditions  from gnue.common.datasources import GConditions, Exceptions
37    from gnue.common.datasources.drivers.Base import DataObject as BaseDataObject
38  from gnue.common.apps import GDebug  from gnue.common.apps import GDebug
39  import string  import string
40  import types  import types
# Line 44  from ResultSet import ResultSet Line 45  from ResultSet import ResultSet
45  #  #
46  #  #
47  #  #
48  class DataObject(GDataObjects.DataObject):  class DataObject(BaseDataObject):
49    
50    _escapeSingleQuote = "'"    _escapeSingleQuote = "'"
51    _resultSetClass = ResultSet    _resultSetClass = ResultSet
# Line 94  class DataObject(GDataObjects.DataObject Line 95  class DataObject(GDataObjects.DataObject
95    
96    
97    def __init__(self, *args, **params):    def __init__(self, *args, **params):
98      GDataObjects.DataObject.__init__(self, *args, **params)      BaseDataObject.__init__(self, *args, **params)
99    
100      GDebug.printMesg (1,"DB-SIG database driver backend initializing")      GDebug.printMesg (1,"DB-SIG database driver backend initializing")
101    
# Line 114  class DataObject(GDataObjects.DataObject Line 115  class DataObject(GDataObjects.DataObject
115      try:      try:
116        return value.strftime(self._dateTimeFormat)        return value.strftime(self._dateTimeFormat)
117      except AttributeError:      except AttributeError:
118          
119        if value == None:        if value == None:
120          return "NULL"          return "NULL"
121    
# Line 159  class DataObject(GDataObjects.DataObject Line 160  class DataObject(GDataObjects.DataObject
160          return "'%s'" % string.replace(str(value),          return "'%s'" % string.replace(str(value),
161                                         "'",                                         "'",
162                                         "%s'" % self._escapeSingleQuote)                                         "%s'" % self._escapeSingleQuote)
163            
164    
165    # Used by drivers with a unique id (like rowid) (see Oracle for example)    # Used by drivers with a unique id (like rowid) (see Oracle for example)
166    def _checkForPrimaryId(self):    def _checkForPrimaryId(self):
# Line 182  class DataObject(GDataObjects.DataObject Line 183  class DataObject(GDataObjects.DataObject
183          recordCount = cursor.rowcount          recordCount = cursor.rowcount
184          #disable the count query and see if anyone screams          #disable the count query and see if anyone screams
185          #recordCount = self._getQueryCount(conditions,sql)          #recordCount = self._getQueryCount(conditions,sql)
186            
187      except self._DatabaseError, err:      except self._DatabaseError, err:
188        raise GDataObjects.ConnectionError, err        raise Exceptions.ConnectionError, err
189    
190      rs = self._resultSetClass(self, cursor=cursor, masterRecordSet=masterRecordSet)      rs = self._resultSetClass(self, cursor=cursor, masterRecordSet=masterRecordSet)
191      if self._strictQueryCount:      if self._strictQueryCount:
# Line 258  class DataObject(GDataObjects.DataObject Line 259  class DataObject(GDataObjects.DataObject
259          if len(result) < self.conditionElements[otype][0]:          if len(result) < self.conditionElements[otype][0]:
260            tmsg = _('Condition element "%s" expects at least %s arguments; found %s') % \            tmsg = _('Condition element "%s" expects at least %s arguments; found %s') % \
261                  (otype, self.conditionElements[otype][0], len(result))                  (otype, self.conditionElements[otype][0], len(result))
262            raise GConditions.ConditionError, tmsg            raise Exceptions.ConditionError, tmsg
263          if len(result) > self.conditionElements[otype][1]:          if len(result) > self.conditionElements[otype][1]:
264            tmsg = _('Condition element "%s" expects at most %s arguments; found %s') % \            tmsg = _('Condition element "%s" expects at most %s arguments; found %s') % \
265                  (otype, self.conditionElements[otype][0], len(result))                  (otype, self.conditionElements[otype][0], len(result))
266            raise GConditions.ConditionError, tmsg            raise Exceptions.ConditionError, tmsg
267    
268          if self.conditionElements[otype][3] == None:          if self.conditionElements[otype][3] == None:
269            return self.conditionElements[otype][2] % tuple(result)            return self.conditionElements[otype][2] % tuple(result)
# Line 271  class DataObject(GDataObjects.DataObject Line 272  class DataObject(GDataObjects.DataObject
272              (string.join(result, self.conditionElements[otype][3]))              (string.join(result, self.conditionElements[otype][3]))
273        else:        else:
274          tmsg = _('Condition clause "%s" is not supported by this db driver.') % otype          tmsg = _('Condition clause "%s" is not supported by this db driver.') % otype
275          raise GConditions.ConditionNotSupported, tmsg          raise Exceptions.ConditionNotSupported, tmsg
276    
277    
278    

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26