summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2007-09-19 15:07:51 -0400
committerWill Woods <wwoods@redhat.com>2007-09-19 15:07:51 -0400
commitd69b8d6ad2959651099789873d6cf9b7ec580fcf (patch)
treeb519d6164a462ad5e2f23f254df895946b7a75b9
parentf871d03b187406dbe352c7b1fed1bafeb818a18e (diff)
downloadpython-bugzilla-d69b8d6ad2959651099789873d6cf9b7ec580fcf.tar.gz
python-bugzilla-d69b8d6ad2959651099789873d6cf9b7ec580fcf.tar.xz
python-bugzilla-d69b8d6ad2959651099789873d6cf9b7ec580fcf.zip
Handle missing getBugFields more gracefully
-rw-r--r--bugzilla.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/bugzilla.py b/bugzilla.py
index a4f11ea..6755620 100644
--- a/bugzilla.py
+++ b/bugzilla.py
@@ -149,7 +149,16 @@ class Bugzilla(object):
for this bugzilla instance. This can be used to set the list of attrs
on the Bug object.'''
if force_refresh or not self._bugfields:
- self._bugfields = self._getbugfields()
+ try:
+ self._bugfields = self._getbugfields()
+ except xmlrpclib.Fault, f:
+ if f.faultCode == 'Client':
+ # okay, this instance doesn't have getbugfields. fine.
+ self._bugfields = []
+ else:
+ # something bad actually happened on the server. blow up.
+ raise f
+
return self._bugfields
bugfields = property(fget=lambda self: self.getbugfields(),
fdel=lambda self: setattr(self,_bugfields,None))
@@ -680,7 +689,10 @@ class Bug(object):
id(self))
def __getattr__(self,name):
- if 'bug_id' in self.__dict__ and name in self.bugzilla.bugfields:
+ if 'bug_id' in self.__dict__:
+ if self.bugzilla.bugfields and name not in self.bugzilla.bugfields:
+ # We have a list of fields, and you ain't on it. Bail out.
+ raise AttributeError
#print "Bug %i missing %s - loading" % (self.bug_id,name)
self.refresh()
if name in self.__dict__: