]> projects.mako.cc - python-simplemediawiki.debian/blobdiff - simplemediawiki.py
Fix a few issues
[python-simplemediawiki.debian] / simplemediawiki.py
index 940fb2b26486ff85e5193749e93aca61c3b65b26..c74fc663a9dd93f1f5e1af4d8262823fe0a04178 100644 (file)
@@ -49,6 +49,7 @@ class MediaWiki():
     _high_limits = None
     _namespaces = None
     _psuedo_namespaces = None
+    _mediawiki_version = None
 
     def __init__(self, api_url, cookie_file=None, user_agent=DEFAULT_UA):
         self._api_url = api_url
@@ -61,7 +62,9 @@ class MediaWiki():
                 self._cj.load()
         else:
             self._cj = cookielib.CookieJar()
-        self._opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self._cj))
+        self._opener = urllib2.build_opener(
+                urllib2.HTTPCookieProcessor(self._cj)
+        )
         self._opener.addheaders = [('User-agent', user_agent)]
 
     def _fetch_http(self, url, params):
@@ -138,12 +141,22 @@ class MediaWiki():
             data['lgtoken'] = token
         result = self.call(data)
         if result['login']['result'] == 'Success':
+            self._high_limits = None
             return True
         elif result['login']['result'] == 'NeedToken' and not token:
             return self.login(user, passwd, result['login']['token'])
         else:
             return False
 
+    def logout(self):
+        """
+        Conveinence function for logging out of the wiki.
+        """
+        data = {'action': 'logout'}
+        self.call(data)
+        self._high_limits = None
+        return True
+
     def limits(self, low, high):
         """
         Convenience function for determining appropriate limits in the API. If

Benjamin Mako Hill || Want to submit a patch?