[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src GConditions.py GDataObjects.py ...
From: |
Jason Cater |
Subject: |
gnue/common/src GConditions.py GDataObjects.py ... |
Date: |
Wed, 09 Jan 2002 22:33:49 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/01/09 22:33:49
Modified files:
common/src : GConditions.py GDataObjects.py GDataSource.py
common/src/dbdrivers/_dbsig: DBdriver.py
Log message:
fixed <datasource><conditions>... support
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GConditions.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GDataObjects.py.diff?cvsroot=OldCVS&tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GDataSource.py.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/dbdrivers/_dbsig/DBdriver.py.diff?cvsroot=OldCVS&tr1=1.30&tr2=1.31&r1=text&r2=text
Patches:
Index: gnue/common/src/GConditions.py
diff -c gnue/common/src/GConditions.py:1.6 gnue/common/src/GConditions.py:1.7
*** gnue/common/src/GConditions.py:1.6 Wed Jan 9 16:48:38 2002
--- gnue/common/src/GConditions.py Wed Jan 9 22:33:49 2002
***************
*** 47,56 ****
cond = GCondition()
lastParent = cond
! if len(dict.keys()):
lastParent = GCand(lastParent)
! for key in dict.keys():
eq = (comparison or GCeq)(lastParent)
GCField(eq, key)
GCConst(eq, dict[key])
--- 47,56 ----
cond = GCondition()
lastParent = cond
! if len(dict.keys()):
lastParent = GCand(lastParent)
! for key in dict.keys():
eq = (comparison or GCeq)(lastParent)
GCField(eq, key)
GCConst(eq, dict[key])
***************
*** 62,68 ****
# NOTE: This modifies cond1 (and also returns it)
#
def combineConditions (cond1, cond2):
! if not len(cond1._children):
cond1._children = cond2._children
return cond1
elif len(cond2._children):
--- 62,72 ----
# NOTE: This modifies cond1 (and also returns it)
#
def combineConditions (cond1, cond2):
! if cond1 == None or cond1 == {}:
! return cond2
! elif cond2 == None or cond1 == {}:
! return cond1
! elif not len(cond1._children):
cond1._children = cond2._children
return cond1
elif len(cond2._children):
***************
*** 78,94 ****
return cond1
- class GConditions(GObj):
- def __init__(self, parent=None, type="GCConditions"):
- GObj.__init__(self, parent, type=type)
-
class GCondition(GObj):
def __init__(self, parent=None, type="GCCondition"):
GObj.__init__(self, parent, type=type)
! class GConditionElement (GObj) :
def __init__(self, parent=None, type="GConditionElement"):
! GObj.__init__(self, parent, type=type)
class GCField (GConditionElement):
def __init__(self, parent, name=None, datatype="char"):
--- 82,98 ----
return cond1
class GCondition(GObj):
def __init__(self, parent=None, type="GCCondition"):
GObj.__init__(self, parent, type=type)
! class GConditions(GCondition):
! def __init__(self, parent=None, type="GCConditions"):
! GCondition.__init__(self, parent, type=type)
!
! class GConditionElement (GCondition) :
def __init__(self, parent=None, type="GConditionElement"):
! GCondition.__init__(self, parent, type=type)
class GCField (GConditionElement):
def __init__(self, parent, name=None, datatype="char"):
***************
*** 124,134 ****
GConditionElement.__init__(self, parent, 'GCnot')
class GCnegate(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCnegate')
class GCeq(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCeq')
class GCne(GConditionElement):
--- 128,138 ----
GConditionElement.__init__(self, parent, 'GCnot')
class GCnegate(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCnegate')
class GCeq(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCeq')
class GCne(GConditionElement):
***************
*** 136,142 ****
GConditionElement.__init__(self, parent, 'GCne')
class GCgt(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCgt')
class GCge(GConditionElement):
--- 140,146 ----
GConditionElement.__init__(self, parent, 'GCne')
class GCgt(GConditionElement):
! def __init__(self, parent):
GConditionElement.__init__(self, parent, 'GCgt')
class GCge(GConditionElement):
***************
*** 181,187 ****
'cfield': {
'BaseClass': GCField,
'Attributes': {
! 'field': {
'Required': 1,
'Typecast': GTypecast.name } },
'ParentTags': ('eq','ne','lt','le','gt','ge',
--- 185,191 ----
'cfield': {
'BaseClass': GCField,
'Attributes': {
! 'name': {
'Required': 1,
'Typecast': GTypecast.name } },
'ParentTags': ('eq','ne','lt','le','gt','ge',
***************
*** 197,202 ****
--- 201,210 ----
'like','notlike','between','notbetween') },
'cconst': {
'BaseClass': GCConst,
+ 'Attributes': {
+ 'value': {
+ 'Required': 1,
+ 'Typecast': GTypecast.text } },
'ParentTags': ('eq','ne','lt','le','gt','ge',
'like','notlike','between','notbetween') },
'and': {
Index: gnue/common/src/GDataObjects.py
diff -c gnue/common/src/GDataObjects.py:1.34
gnue/common/src/GDataObjects.py:1.35
*** gnue/common/src/GDataObjects.py:1.34 Wed Jan 9 08:56:55 2002
--- gnue/common/src/GDataObjects.py Wed Jan 9 22:33:49 2002
***************
*** 90,95 ****
--- 90,96 ----
self._masterfields = []
self._detailfields = []
+ self._staticCondition = None
self._masterObject = None
self._detailObjects = []
***************
*** 111,117 ****
# Do not over-ride by vendor code
def createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
! return self._createResultSet(conditions, readOnly=readOnly,
masterRecordSet=masterRecordSet)
# Designed to be replaced by vendor-specific code
def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
--- 112,120 ----
# Do not over-ride by vendor code
def createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
! return self._createResultSet(
! GConditions.combineConditions(conditions, self._staticCondition),
! readOnly=readOnly, masterRecordSet=masterRecordSet)
# Designed to be replaced by vendor-specific code
def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
Index: gnue/common/src/GDataSource.py
diff -c gnue/common/src/GDataSource.py:1.21 gnue/common/src/GDataSource.py:1.22
*** gnue/common/src/GDataSource.py:1.21 Fri Jan 4 17:56:59 2002
--- gnue/common/src/GDataSource.py Wed Jan 9 22:33:49 2002
***************
*** 87,92 ****
--- 87,97 ----
self._dataObject._fieldReferences = self._fieldReferences
self._dataObject._unboundFieldReferences = self._unboundFieldReferences
self._dataObject._defaultValues = self._defaultValues
+ for child in self._children:
+ print child
+ if isinstance(child, GConditions.GCondition):
+ self._dataObject._staticCondition = child
+ break
# Copy all attributes from XML to the dataObject
Index: gnue/common/src/dbdrivers/_dbsig/DBdriver.py
diff -c gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.30
gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.31
*** gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.30 Tue Jan 8 17:07:58 2002
--- gnue/common/src/dbdrivers/_dbsig/DBdriver.py Wed Jan 9 22:33:49 2002
***************
*** 248,254 ****
'notlike': (2, 2, '%s NOT LIKE %s', None ),
'between': (3, 3, '%s BETWEEN %s AND %s', None ) }
! def __init__(self, strictQueryCount=1):
GDataObjects.DataObject.__init__(self)
GDebug.printMesg (1,"DB-SIG database driver backend initializing")
--- 248,254 ----
'notlike': (2, 2, '%s NOT LIKE %s', None ),
'between': (3, 3, '%s BETWEEN %s AND %s', None ) }
! def __init__(self, strictQueryCount=1):
GDataObjects.DataObject.__init__(self)
GDebug.printMesg (1,"DB-SIG database driver backend initializing")
***************
*** 259,270 ****
# This should be over-ridden only if driver needs more than user/pass
! def getLoginFields(self):
return [['_username', 'User Name',0],['_password', 'Password',1]]
! def _createResultSet(self, conditions={}, readOnly=0,
masterRecordSet=None):
! try:
cursor = self._dataConnection.cursor()
# pull a record count for the upcomming query
--- 259,270 ----
# This should be over-ridden only if driver needs more than user/pass
! def getLoginFields(self):
return [['_username', 'User Name',0],['_password', 'Password',1]]
! def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
! try:
cursor = self._dataConnection.cursor()
# pull a record count for the upcomming query
***************
*** 289,307 ****
cursor.execute(self._buildQueryCount(conditions))
rs = cursor.fetchone()
! return rs[0]
! def commit(self):
GDebug.printMesg (5,"DB-SIG database driver: commit()")
! try:
self._dataConnection.commit()
except self._DatabaseError, value:
raise GDataObjects.ConnectionError, value
!
self._beginTransaction()
! def rollback(self):
GDebug.printMesg (5,"DB-SIG database driver: rollback()")
try:
--- 289,307 ----
cursor.execute(self._buildQueryCount(conditions))
rs = cursor.fetchone()
! return rs[0]
! def commit(self):
GDebug.printMesg (5,"DB-SIG database driver: commit()")
! try:
self._dataConnection.commit()
except self._DatabaseError, value:
raise GDataObjects.ConnectionError, value
!
self._beginTransaction()
! def rollback(self):
GDebug.printMesg (5,"DB-SIG database driver: rollback()")
try:
***************
*** 314,335 ****
# Used to convert a condition tree to an sql where clause
! def _conditionToSQL (self, condition):
! if condition == {} or condition == None:
return ""
elif type(condition) == types.DictType:
cond = GConditions.buildConditionFromDict(condition)
else:
cond = condition
!
! if not len(cond._children):
return ""
! elif len(cond._children) > 1:
chillun = cond._children[:]
cond._children = []
_and = GConditions.GCand(cond)
_and._children = chillun
!
where = " WHERE (%s)" % (self.__conditionToSQL (cond._children[0]))
GDebug.printMesg(5, where)
return where
--- 314,335 ----
# Used to convert a condition tree to an sql where clause
! def _conditionToSQL (self, condition):
! if condition == {} or condition == None:
return ""
elif type(condition) == types.DictType:
cond = GConditions.buildConditionFromDict(condition)
else:
cond = condition
!
! if not len(cond._children):
return ""
! elif len(cond._children) > 1:
chillun = cond._children[:]
cond._children = []
_and = GConditions.GCand(cond)
_and._children = chillun
!
where = " WHERE (%s)" % (self.__conditionToSQL (cond._children[0]))
GDebug.printMesg(5, where)
return where
***************
*** 339,357 ****
#
# This code recursively travels down a condition tree replacing the objects
# with a strings representation
! def __conditionToSQL (self, element):
! if type(element) != types.InstanceType:
return "%s" % element
else:
# Note that we strip the GC from the object types and lowercase the rest
otype = string.lower(element.getObjectType()[2:])
#print "Otype: ",otype
! if otype == 'field':
return "%s" % element.name
! elif otype == 'const':
! if element.value == None:
! return "NULL"
! elif element.type == 'number':
return "%s" % element.value
else:
return "'%s'" % element.value
--- 339,357 ----
#
# This code recursively travels down a condition tree replacing the objects
# with a strings representation
! def __conditionToSQL (self, element):
! if type(element) != types.InstanceType:
return "%s" % element
else:
# Note that we strip the GC from the object types and lowercase the rest
otype = string.lower(element.getObjectType()[2:])
#print "Otype: ",otype
! if otype == 'field':
return "%s" % element.name
! elif otype == 'const':
! if element.value == None:
! return "NULL"
! elif element.type == 'number':
return "%s" % element.value
else:
return "'%s'" % element.value
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src GConditions.py GDataObjects.py ...,
Jason Cater <=