# HG changeset patch # User Atul Varma # Date 1271205756 25200 # Node ID d5f43c3aeb29e648d61bbb05146f788ca00da046 # Parent d8db9b733a1257000b71904f38ebd6187c0be192 made passing bzapi into constructors of User, Bug, Attachment objects mandatory diff -r d8db9b733a12 -r d5f43c3aeb29 bugzilla.py --- a/bugzilla.py Tue Apr 13 17:37:33 2010 -0700 +++ b/bugzilla.py Tue Apr 13 17:42:36 2010 -0700 @@ -249,7 +249,7 @@ class User(BugzillaObject): """ - >>> u = User(TEST_USER) + >>> u = User(TEST_USER, bzapi=None) >>> u.name u'avarma@mozilla.com' >>> u.real_name @@ -272,7 +272,7 @@ 'name': unicode } - def __init__(self, jsonobj, bzapi=None): + def __init__(self, jsonobj, bzapi): BugzillaObject.__init__(self, jsonobj, bzapi) self.__email = jsonobj.get('email') self.__real_name = jsonobj.get('real_name') @@ -326,7 +326,7 @@ 'is_obsolete': bool } - def __init__(self, jsonobj, bzapi=None, bug=None): + def __init__(self, jsonobj, bzapi, bug=None): BugzillaObject.__init__(self, jsonobj, bzapi) if 'data' in jsonobj: self.__data = self.__decode_data(jsonobj) @@ -338,20 +338,12 @@ @property def bug(self): if self.__bug is None: - if not self.bzapi: - raise AttributeError('cannot fetch bug %d for ' - 'attachment %d; no bzapi' % - (self.bug_id, self.id)) self.__bug = Bug.fetch(self.bzapi, self.bug_id) return self.__bug @property def data(self): if self.__data is None: - if not self.bzapi: - raise AttributeError('cannot fetch data for ' - 'attachment %d; no bzapi' % - self.id) jsonobj = self.__get_full_attachment(self.bzapi, self.id) self.__data = self.__decode_data(jsonobj) return self.__data @@ -388,7 +380,7 @@ class Bug(BugzillaObject): """ - >>> Bug(TEST_BUG) + >>> Bug(TEST_BUG, bzapi=None) """ @@ -397,7 +389,7 @@ 'summary': unicode } - def __init__(self, jsonobj, bzapi=None): + def __init__(self, jsonobj, bzapi): BugzillaObject.__init__(self, jsonobj, bzapi) self.attachments = [Attachment(attach, bzapi, self) for attach in jsonobj['attachments']]