summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-27 21:45:29 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-27 21:45:29 +0000
commitfe1afa72b10a516c48281278ccec3c3d33a5f24a (patch)
treee769cd884d92f9d047f15bace85cddfadb76369f
parent7b900376f3fcd5194ca6798712ac1706a4179f6e (diff)
downloadportage-fe1afa72b10a516c48281278ccec3c3d33a5f24a.tar.gz
portage-fe1afa72b10a516c48281278ccec3c3d33a5f24a.tar.bz2
portage-fe1afa72b10a516c48281278ccec3c3d33a5f24a.zip
Add backward compatibility code for cache modules that override has_key instead of __contains__.
svn path=/main/trunk/; revision=4855
-rw-r--r--pym/cache/template.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pym/cache/template.py b/pym/cache/template.py
index a628b1161..4ffd9b9ef 100644
--- a/pym/cache/template.py
+++ b/pym/cache/template.py
@@ -114,7 +114,14 @@ class database(object):
raise NotImplementedError
def __contains__(self, cpv):
- raise NotImplementedError
+ """This method should always be overridden. It is provided only for
+ backward compatibility with modules that override has_key instead. It
+ will automatically raise a NotImplementedError if has_key has not been
+ overridden."""
+ if self.has_key is database.has_key:
+ # prevent a possible recursive loop
+ raise NotImplementedError
+ return self.has_key(cpv)
def get(self, k, x=None):
try: