Add backward compatibility code for cache modules that override has_key instead of...
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Oct 2006 21:45:29 +0000 (21:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Oct 2006 21:45:29 +0000 (21:45 -0000)
svn path=/main/trunk/; revision=4855

pym/cache/template.py

index a628b1161a0ad8304e5e204394609dc4b7cd62cb..4ffd9b9efd2a1177271e5a3981a963066976f901 100644 (file)
@@ -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: