[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src GConditions.py GConfig.py GObje...
From: |
James Thompson |
Subject: |
gnue/common/src GConditions.py GConfig.py GObje... |
Date: |
Wed, 20 Nov 2002 22:47:47 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/11/20 22:47:46
Modified files:
common/src : GConditions.py GConfig.py GObjects.py
common/src/dbdrivers/_dbsig: DBdriver.py
common/src/dbdrivers/mysql: DBdriver.py
Log message:
merged in config fixes from 0.4.x branch
merged in papo patches from 0.4.x branch
a possible workaround for older mysql drivers
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GConditions.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GConfig.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GObjects.py.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/_dbsig/DBdriver.py.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/mysql/DBdriver.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
Patches:
Index: gnue/common/src/GConditions.py
diff -c gnue/common/src/GConditions.py:1.20 gnue/common/src/GConditions.py:1.21
*** gnue/common/src/GConditions.py:1.20 Tue Nov 12 18:00:18 2002
--- gnue/common/src/GConditions.py Wed Nov 20 22:47:46 2002
***************
*** 145,150 ****
--- 145,160 ----
def __init__(self, parent=None):
GConditionElement.__init__(self, parent, 'GCnotbetween')
+ class GCnull(GConditionElement):
+ def __init__(self, parent=None):
+ GConditionElement.__init__(self, parent, 'GCnull')
+
+ class GCnotnull(GConditionElement):
+ def __init__(self, parent=None):
+ GConditionElement.__init__(self, parent, 'GCnotnull')
+
+
+
# build an impossible condition GCondition={0=1}
GCimpossible=GCondition()
_h=GCeq(GCimpossible)
***************
*** 249,255 ****
'ParentTags': ('condition','and','or','not','negate') },
'notbetween': {
'BaseClass': GCnotbetween,
! 'ParentTags': ('condition','and','or','not','negate') }}
for alteration in updates.keys():
xmlElements[alteration].update(updates[alteration])
--- 259,272 ----
'ParentTags': ('condition','and','or','not','negate') },
'notbetween': {
'BaseClass': GCnotbetween,
! 'ParentTags': ('condition','and','or','not','negate') },
! 'null': {
! 'BaseClass': GCnull,
! 'ParentTags': ('condition','and','or','not') },
! 'notnull': {
! 'BaseClass': GCnotnull,
! 'ParentTags': ('condition','and','or','not') },
! }
for alteration in updates.keys():
xmlElements[alteration].update(updates[alteration])
Index: gnue/common/src/GConfig.py
diff -c gnue/common/src/GConfig.py:1.29 gnue/common/src/GConfig.py:1.30
*** gnue/common/src/GConfig.py:1.29 Wed Nov 13 12:06:20 2002
--- gnue/common/src/GConfig.py Wed Nov 20 22:47:46 2002
***************
*** 60,125 ****
__builtin__.__dict__[name] = alias.gConfig
def loadApplicationConfig(self, configFilename="gnue.conf",
homeConfigDir=".gnue", section="DEFAULT", defaults = None):
GDebug.printMesg(1,'Reading configuration info from %s section %s'
%(configFilename,section))
! # Create parser if it doesn't exist
! readFiles = 0
if not self._loadedConfigs.has_key(configFilename):
parser = ConfigParser()
self._loadedConfigs[configFilename]=parser
- readFiles = 1
! # Load any passed in defaults to the requested section
! defaultValues = self._buildDefaults(defaults)
! try:
! self._loadedConfigs[configFilename].add_section(section)
! except DuplicateSectionError:
! pass
! for key in defaultValues.keys():
! self._loadedConfigs[configFilename].set(section,key,defaultValues[key])
- # Load any [common] defaults
- defaultValues = self._buildDefaults(GCConfig.ConfigOptions)
- try:
- self._loadedConfigs[configFilename].add_section('common')
- except DuplicateSectionError:
- pass
- for key in defaultValues.keys():
- self._loadedConfigs[configFilename].set('common',key,defaultValues[key])
! # Skip reading the files if the parser for that section already existed
! if not readFiles:
! return
!
! # Build valid file list
! fileLocations = []
! etc_base = getInstalledBase('%s_etc' % section, 'common_etc')
!
! # system config file
! if etc_base:
! fileLocations.append(os.path.join(etc_base,configFilename))
!
! # user config file
try:
! fileLocations.append(os.path.join(os.environ['HOME'], homeConfigDir
,configFilename))
! except KeyError:
pass
- # system fixed config file
- if etc_base:
- fileLocations.append(os.path.join(etc_base,configFilename+'.fixed'))
-
- try:
- parser.read(fileLocations)
- except DuplicateSectionError:
- raise InvalidFormatError, _('The file has duplicate source
definitions.')
- except MissingSectionHeaderError:
- raise InvalidFormatError, _('The file has no source definitions.')
- except:
- print _('The file cannot be parsed. %s :: %s') % (sys.exc_type,
sys.exc_value)
- raise InvalidFormatError, _('The file cannot be parsed.')
def gConfig(self, varName, configFilename=None, section=None):
if not configFilename: configFilename = self._defaultConfigFilename
--- 60,148 ----
__builtin__.__dict__[name] = alias.gConfig
+ #
+ # loadApplicationConfig
+ #
+ # Loads the specified file only once.
+ # Subsequent calls setup the defaults for any missing values
+ #
def loadApplicationConfig(self, configFilename="gnue.conf",
homeConfigDir=".gnue", section="DEFAULT", defaults = None):
GDebug.printMesg(1,'Reading configuration info from %s section %s'
%(configFilename,section))
! #
! # Create parser and populate it if it doesn't exist
! #
if not self._loadedConfigs.has_key(configFilename):
parser = ConfigParser()
self._loadedConfigs[configFilename]=parser
!
! # Build valid file list
! fileLocations = []
! etc_base = getInstalledBase('%s_etc' % section, 'common_etc')
!
! # system config file
! if etc_base:
! fileLocations.append(os.path.join(etc_base,configFilename))
!
! # user config file
! try:
! fileLocations.append(os.path.join(os.environ['HOME'], homeConfigDir
,configFilename))
! except KeyError:
! pass
!
! # system fixed config file
! if etc_base:
! fileLocations.append(os.path.join(etc_base,configFilename+'.fixed'))
!
! #
! # Load the values from the files specified
! #
! try:
! parser.read(fileLocations)
! except DuplicateSectionError:
! raise InvalidFormatError, _('The file has duplicate source
definitions.')
! except MissingSectionHeaderError:
! raise InvalidFormatError, _('The file has no source definitions.')
! except:
! print _('The file cannot be parsed. %s :: %s') % (sys.exc_type,
sys.exc_value)
! raise InvalidFormatError, _('The file cannot be parsed.')
!
! #
! # Common only needs checked once
! #
! # Load any [common] defaults
! self._integrateDefaultDict(configFilename,'common',
! self._buildDefaults(GCConfig.ConfigOptions))
!
! #
! # Load anything set in the DEFAULT section
! #
! self._integrateDefaultDict(configFilename,section,
! self._loadedConfigs[configFilename].defaults())
!
! #
! # If any values are still blank after loading from file's
! # specific section and then the default section then load the
! # defaults specified by the application itself.
! #
!
self._integrateDefaultDict(configFilename,section,self._buildDefaults(defaults))
! def _integrateDefaultDict(self,filename, section,defaults):
try:
! self._loadedConfigs[filename].add_section(section)
! except DuplicateSectionError:
pass
+ for key in defaults.keys():
+ # Only set the value to the default if config file didn't contain
+ # custom setting.
+ try:
+ self._loadedConfigs[filename].get(section,key)
+ except NoOptionError:
+ self._loadedConfigs[filename].set(section,key,defaults[key])
def gConfig(self, varName, configFilename=None, section=None):
if not configFilename: configFilename = self._defaultConfigFilename
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.42 gnue/common/src/GObjects.py:1.43
*** gnue/common/src/GObjects.py:1.42 Tue Nov 19 20:01:36 2002
--- gnue/common/src/GObjects.py Wed Nov 20 22:47:46 2002
***************
*** 281,287 ****
while 1:
if parentObject == None:
! return None
elif parentObject._type == type:
return parentObject
--- 281,287 ----
while 1:
if parentObject == None:
! return None
elif parentObject._type == type:
return parentObject
Index: gnue/common/src/dbdrivers/_dbsig/DBdriver.py
diff -c gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.62
gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.63
*** gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.62 Mon Nov 11 15:51:16 2002
--- gnue/common/src/dbdrivers/_dbsig/DBdriver.py Wed Nov 20 22:47:46 2002
***************
*** 178,204 ****
class DBSIG_DataObject(GDataObjects.DataObject):
conditionElements = {
! 'add': (2, 999, '(%s)', '+' ),
! 'sub': (2, 999, '(%s)', '-' ),
! 'mul': (2, 999, '(%s)', '*' ),
! 'div': (2, 999, '(%s)', '/' ),
! 'and': (1, 999, '(%s)', ' AND ' ),
! 'or': (2, 999, '(%s)', ' OR ' ),
! 'not': (1, 1, '(NOT %s)', None ),
! 'negate': (1, 1, '-%s', None ),
! 'eq': (2, 2, '(%s = %s)', None ),
! 'ne': (2, 2, '(%s != %s)', None ),
! 'gt': (2, 2, '(%s > %s)', None ),
! 'ge': (2, 2, '(%s >= %s)', None ),
! 'lt': (2, 2, '(%s < %s)', None ),
! 'le': (2, 2, '(%s <= %s)', None ),
! 'like': (2, 2, '%s LIKE %s', None ),
! 'notlike': (2, 2, '%s NOT LIKE %s', None ),
! 'between': (3, 3, '%s BETWEEN %s AND %s', None ),
# These two are hacks... these are not really valid tags
# Used when the 2nd value of EQ or NE is NULL.
! '__iseq': (2, 2, '(%s IS %s)', None ),
! '__isne': (2, 2, '(%s IS NOT %s)', None )}
schema2nativeTypes={}
--- 178,207 ----
class DBSIG_DataObject(GDataObjects.DataObject):
conditionElements = {
! 'add': (2, 999, '(%s)', '+' ),
! 'sub': (2, 999, '(%s)', '-' ),
! 'mul': (2, 999, '(%s)', '*' ),
! 'div': (2, 999, '(%s)', '/' ),
! 'and': (1, 999, '(%s)', ' AND ' ),
! 'or': (2, 999, '(%s)', ' OR ' ),
! 'not': (1, 1, '(NOT %s)', None ),
! 'negate': (1, 1, '-%s', None ),
! 'null': (1, 1, '(%s IS NULL)', None ),
! 'notnull': (1, 1, '(%s IS NOT NULL)', None ),
! 'eq': (2, 2, '(%s = %s)', None ),
! 'ne': (2, 2, '(%s != %s)', None ),
! 'gt': (2, 2, '(%s > %s)', None ),
! 'ge': (2, 2, '(%s >= %s)', None ),
! 'lt': (2, 2, '(%s < %s)', None ),
! 'le': (2, 2, '(%s <= %s)', None ),
! 'like': (2, 2, '%s LIKE %s', None ),
! 'notlike': (2, 2, '%s NOT LIKE %s', None ),
! 'between': (3, 3, '%s BETWEEN %s AND %s', None ),
! 'notbetween': (3, 3, '(%s NOT BETWEEN %s AND %s)', None ),
# These two are hacks... these are not really valid tags
# Used when the 2nd value of EQ or NE is NULL.
! '__iseq': (2, 2, '(%s IS %s)', None ),
! '__isne': (2, 2, '(%s IS NOT %s)', None )}
schema2nativeTypes={}
Index: gnue/common/src/dbdrivers/mysql/DBdriver.py
diff -c gnue/common/src/dbdrivers/mysql/DBdriver.py:1.16
gnue/common/src/dbdrivers/mysql/DBdriver.py:1.17
*** gnue/common/src/dbdrivers/mysql/DBdriver.py:1.16 Thu Nov 7 12:04:38 2002
--- gnue/common/src/dbdrivers/mysql/DBdriver.py Wed Nov 20 22:47:46 2002
***************
*** 59,72 ****
DBSIG_ResultSet.__init__(self, dataObject, \
cursor, defaultValues, masterRecordSet)
self._recordSetClass = MySQL_RecordSet
def _loadNextRecord(self):
if self._cursor:
rs = None
try:
! #
! # rsets = self._cursor.fetchall()
! rsets = self._cursor.fetchmany()
except self._dataObject._DatabaseError, err:
raise GDataObjects.ConnectionError, err
--- 59,79 ----
DBSIG_ResultSet.__init__(self, dataObject, \
cursor, defaultValues, masterRecordSet)
self._recordSetClass = MySQL_RecordSet
+
+ # Compensate for bug in python mysql drivers older than 0.9.2a2
+ if MySQLdb.__version__ >= '0.9.2a2':
+ self.fetchBugFix = self._cursor.fetchmany
+ else:
+ self.fetchBugFix = self._cursor.fetchall
+
def _loadNextRecord(self):
if self._cursor:
rs = None
try:
! # See __init__ for details
! rsets = self.fetchBugFix()
!
except self._dataObject._DatabaseError, err:
raise GDataObjects.ConnectionError, err
***************
*** 93,102 ****
DBSIG_DataObject.__init__(self)
self._DatabaseError = MySQLdb.DatabaseError
self._resultSetClass = MySQL_ResultSet
-
-
def connect(self, connectData={}):
GDebug.printMesg(1,"Mysql database driver initializing")
try:
self._dataConnection = MySQLdb.connect(user=connectData['_username'],
passwd=connectData['_password'],
--- 100,108 ----
DBSIG_DataObject.__init__(self)
self._DatabaseError = MySQLdb.DatabaseError
self._resultSetClass = MySQL_ResultSet
def connect(self, connectData={}):
GDebug.printMesg(1,"Mysql database driver initializing")
+
try:
self._dataConnection = MySQLdb.connect(user=connectData['_username'],
passwd=connectData['_password'],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src GConditions.py GConfig.py GObje...,
James Thompson <=