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 |
45 |
# |
# |
46 |
# |
# |
47 |
# |
# |
48 |
class DataObject(GDataObjects.DataObject): |
class DataObject(BaseDataObject): |
49 |
|
|
50 |
_escapeSingleQuote = "'" |
_escapeSingleQuote = "'" |
51 |
_resultSetClass = ResultSet |
_resultSetClass = ResultSet |
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 |
|
|
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 |
|
|
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): |
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: |
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) |
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 |
|
|