File 0017-allow-various-bnc-instances-in-NovellBugzilla.patch of Package python-bugzilla

From 25f24e68d5005b500dd000f90ae5ebec8a2ba70d Mon Sep 17 00:00:00 2001
From: Michal Vyskocil <mvyskocil@suse.cz>
Date: Thu, 26 May 2011 11:00:33 +0200
Subject: [PATCH 17/17] allow various bnc instances in  NovellBugzilla

The older NovellBugzilla implementation was limited to
bugzilla.novell.com, so using of internal testing instace was not
possible. So code in NovellBugzilla.__init__ and getBugzillaClassForURL
search for 'novell.com' string only.

In adition NovellBugzilla.__init__ add a url= argument to kwargs if not
exists or if it does not contain novell.com, so this class can be simple
instantiated without arguments in some cases.
---
 bugzilla/__init__.py    |    2 +-
 bugzilla/nvlbugzilla.py |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/bugzilla/__init__.py b/bugzilla/__init__.py
index a3a88d2..fcfffd6 100644
--- a/bugzilla/__init__.py
+++ b/bugzilla/__init__.py
@@ -23,7 +23,7 @@ classlist = ['Bugzilla3', 'Bugzilla32', 'Bugzilla34', 'Bugzilla36',
 
 def getBugzillaClassForURL(url):
     log.debug("Choosing subclass for %s" % url)
-    if url.startswith('https://bugzilla.novell.com'):
+    if 'novell.com' in url:
         return NovellBugzilla
 
     s = xmlrpclib.ServerProxy(url)
diff --git a/bugzilla/nvlbugzilla.py b/bugzilla/nvlbugzilla.py
index 62b75b7..15879f1 100644
--- a/bugzilla/nvlbugzilla.py
+++ b/bugzilla/nvlbugzilla.py
@@ -55,9 +55,11 @@ class NovellBugzilla(Bugzilla34):
 
     def __init__(self, expires=300, **kwargs):
         self._expires = expires
+        # allow proper usage of NovellBugzilla with a wrong url argument
+        # (without it or with an another location)
+        if not 'novell.com' in kwargs.get('url', ''):
+            kwargs['url'] = self.__class__.bugzilla_url
         super(NovellBugzilla, self).__init__(**kwargs)
-        # url argument exists only for backward compatibility, but is always set to same url
-        self.url = self.__class__.bugzilla_url
 
     def __get_expiration(self):
         return self._expires
-- 
1.7.6

openSUSE Build Service is sponsored by