summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-05-22 14:59:46 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-05-22 15:02:12 -0500
commit289b649107aff7c36648bbd50df7c2ca54681982 (patch)
tree6aecf6cef178ac0bcafc1062e9315f2a6b83c6cf /src
parentbed31991ee88bb99b3a0489004cbd5e6d1ab7bdd (diff)
downloadbcfg2-289b649107aff7c36648bbd50df7c2ca54681982.tar.gz
bcfg2-289b649107aff7c36648bbd50df7c2ca54681982.tar.bz2
bcfg2-289b649107aff7c36648bbd50df7c2ca54681982.zip
Pkgmgr: Fix broken altsrc
Use __contains__ instead of has_key in Pkgmgr. Gone in Py3k. Fallback on __getitem__ in PrioDir. Handles cased with an override for __getitem__ is used.
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Pkgmgr.py10
2 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index b668b7442..4e9199466 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -880,6 +880,9 @@ class PrioDir(Plugin, Generator, XMLDirectoryBacked):
if self._matches(entry, metadata, [rname]):
data = matching[index].cache[1][entry.tag][rname]
break
+ else:
+ # Fall back on __getitem__. Required if override used
+ data = matching[index].cache[1][entry.tag][entry.get('name')]
if '__text__' in data:
entry.text = data['__text__']
if '__children__' in data:
diff --git a/src/lib/Bcfg2/Server/Plugins/Pkgmgr.py b/src/lib/Bcfg2/Server/Plugins/Pkgmgr.py
index e9254cdcc..8d6d85ef2 100644
--- a/src/lib/Bcfg2/Server/Plugins/Pkgmgr.py
+++ b/src/lib/Bcfg2/Server/Plugins/Pkgmgr.py
@@ -24,12 +24,14 @@ class FuzzyDict(dict):
print("got non-string key %s" % str(key))
return dict.__getitem__(self, key)
- def has_key(self, key):
+ def __contains__(self, key):
if isinstance(key, str):
mdata = self.fuzzy.match(key)
- if self.fuzzy.match(key):
- return dict.has_key(self, mdata.groupdict()['name'])
- return dict.has_key(self, key)
+ if mdata:
+ return dict.__contains__(self, mdata.groupdict()['name'])
+ else:
+ print("got non-string key %s" % str(key))
+ return dict.__contains__(self, key)
def get(self, key, default=None):
try: