From: jordan Date: Sat, 21 May 2011 19:39:57 +0000 (+0000) Subject: adding a try-except block that listens for AttributeError for the find_by_name and... X-Git-Tag: live~268 X-Git-Url: https://git.openstreetmap.org/osqa.git/commitdiff_plain/42651c00f2a66cefa8d3a679b97edc1c0aca8418 adding a try-except block that listens for AttributeError for the find_by_name and remove_by_name methods git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1045 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/modules/ui.py b/forum/modules/ui.py index 2694110..114885b 100644 --- a/forum/modules/ui.py +++ b/forum/modules/ui.py @@ -11,13 +11,19 @@ class Registry(list): def find_by_name(self, name): for i in self: - if i.name and (i.name == name): - return i + try: + if i.name and (i.name == name): + return i + except AttributeError: + pass def remove_by_name(self, name): for i, r in enumerate(self): - if r.name and (r.name == name): - return self.pop(i) + try: + if r.name and (r.name == name): + return self.pop(i) + except AttributeError: + pass HEAD_CONTENT = 'HEAD_CONTENT'