[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-common/src GConfigParser.py GConnecti...
From: |
Jason Cater |
Subject: |
gnue/gnue-common/src GConfigParser.py GConnecti... |
Date: |
Mon, 13 Aug 2001 16:15:40 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/08/13 16:15:40
Modified files:
gnue-common/src: GConfigParser.py GConnections.py
Log message:
Fixed support for <database> tags, although I do not recommend them
(but I suppose there are cases where it is needed)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GConfigParser.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GConnections.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gnue/gnue-common/src/GConfigParser.py
diff -u gnue/gnue-common/src/GConfigParser.py:1.1
gnue/gnue-common/src/GConfigParser.py:1.2
--- gnue/gnue-common/src/GConfigParser.py:1.1 Mon Jun 4 20:23:39 2001
+++ gnue/gnue-common/src/GConfigParser.py Mon Aug 13 16:15:40 2001
@@ -5,14 +5,50 @@
#
from ConfigParser import *
import GDebug
+import string
class GConfigParser(ConfigParser):
def __init__(self):
ConfigParser.__init__(self)
+
+
+ # ARGH! Python 1.5.2 ConfigParser was fairly useless.
+ # 1.6+ supports quite a few more options that 1.5.2 .
+ # So, we'll have to patch to make 1.5.2 useful.
+ #
+ # WARNING: this is using internal, undocumented properties
+ # of 1.5.2's ConfigParser to do its magic.
+ #
+
+ # TODO: If the minimum Python version is ever increased to the
+ # TODO: 2.x series, this entire class can simply sublcass
+ # TODO: ConfigParser and not have ANY methods!
+
+
if (not ConfigParser.__dict__.has_key('readfp') and
ConfigParser.__dict__.has_key('_ConfigParser__read')):
GDebug.printMesg(1,'Subclassing ConfigParser to support URL''s')
self.readfp = self._readfp
+
+ if (not ConfigParser.__dict__.has_key('set')):
+ GDebug.printMesg(1,'Subclassing ConfigParser to support set()')
+ self.set = self._set
+
+ if (not ConfigParser.__dict__.has_key('remove_section')):
+ GDebug.printMesg(1,'Subclassing ConfigParser to support
remove_section()')
+ self.remove_section = self._remove_section
+
+ def _readfp(self, fp):
+ self._ConfigParser__read(fp)
+
+ def _set(self, section, option, value):
+ self._ConfigParser__sections[string.lower(section)]\
+ [string.lower(option)] = value
+
+ def _remove_section(self, section):
+ if self._ConfigParser__sections.has_key (string.lower(section)):
+ del self._ConfigParser__sections[string.lower(section)]
+ return 1
+ else:
+ return 0
- def _readfp (self, fp):
- self._ConfigParser__read(fp)
Index: gnue/gnue-common/src/GConnections.py
diff -u gnue/gnue-common/src/GConnections.py:1.10
gnue/gnue-common/src/GConnections.py:1.11
--- gnue/gnue-common/src/GConnections.py:1.10 Sun Aug 12 12:55:26 2001
+++ gnue/gnue-common/src/GConnections.py Mon Aug 13 16:15:40 2001
@@ -126,7 +126,18 @@
return rv
+ #
+ # Add a connection entry (session specific; i.e., doesn't add
+ # to the connections.conf file, but to the current instance's
+ # list of available connections.
+ #
+ def addConnectionSpecification (self, name, parameters):
+ self._parser.remove_section(string.lower(name))
+ self._parser.add_section(string.lower(name))
+ for key in parameters.keys():
+ self._parser.set(string.lower(name), key, parameters[key])
+
#
# Return a database provider object
#
@@ -191,18 +202,6 @@
# Guess they changed their minds. Treat as a login error.
raise GDataObjects.LoginError, "User canceled the login request"
-
-
-
-#
-# This is an ugly hack to make the Python 1.5.2 ConfigParser
-# support reading its data from a file handle. Later versions
-# have a readfp method. :(
-#
-#class _ConfigParser(ConfigParser):
-# def readfp (self, fp):
-# self.__read(fp)
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnue-common/src GConfigParser.py GConnecti...,
Jason Cater <=