From fe1afa72b10a516c48281278ccec3c3d33a5f24a Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 27 Oct 2006 21:45:29 +0000 Subject: Add backward compatibility code for cache modules that override has_key instead of __contains__. svn path=/main/trunk/; revision=4855 --- pym/cache/template.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pym/cache') 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: -- cgit v1.2.3-1-g7c22