diff options
author | Will Woods <wwoods@redhat.com> | 2008-08-05 15:58:19 -0400 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2008-08-05 15:58:19 -0400 |
commit | 9434dd7a60859bc8b1f72fe28d8733bd0556c385 (patch) | |
tree | 836580feb0d80f6ed2c3497bc84fd174a3f43f94 | |
parent | 2de4aecfcdf639aed2d895d84a629651c45c1351 (diff) | |
download | python-bugzilla-9434dd7a60859bc8b1f72fe28d8733bd0556c385.tar.gz python-bugzilla-9434dd7a60859bc8b1f72fe28d8733bd0556c385.tar.xz python-bugzilla-9434dd7a60859bc8b1f72fe28d8733bd0556c385.zip |
Use Bugzilla32 where applicable
-rw-r--r-- | bugzilla/__init__.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/bugzilla/__init__.py b/bugzilla/__init__.py index 8561921..2e5ee75 100644 --- a/bugzilla/__init__.py +++ b/bugzilla/__init__.py @@ -9,7 +9,7 @@ # option) any later version. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. -from bugzilla3 import Bugzilla3 +from bugzilla3 import Bugzilla3, Bugzilla32 from rhbugzilla import RHBugzilla import xmlrpclib import logging @@ -17,23 +17,36 @@ log = logging.getLogger("bugzilla") def getBugzillaClassForURL(url): s = xmlrpclib.ServerProxy(url) - # RH Bugzilla method - prodinfo = {} + rhbz = False + bzversion = '' + c = None + + # Check for a RH-only method try: prodinfo = s.bugzilla.getProdInfo() - return RHBugzilla + rhbz = True except xmlrpclib.Fault: pass + # Try to get the bugzilla version string try: r = s.Bugzilla.version() - version = r['version'] - if version.startswith('3.'): - return Bugzilla3 + bzversion = r['version'] except xmlrpclib.Fault: pass - return None + # current preference order: RHBugzilla, Bugzilla3 + # RH BZ 3.2 will have rhbz == True and bzversion == 3.1.x or 3.2.x. + # To prefer Bugzilla32 over RHBugzilla do: if rhbz and (bzversion == '') + if rhbz: + c = RHBugzilla + elif bzversion.startswith('3.'): + if bzversion.startswith('3.0'): + c = Bugzilla3 + else: # 3.1 or higher + c = Bugzilla32 + + return c class Bugzilla(object): '''Magical Bugzilla class that figures out which Bugzilla implementation |