http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10421
Revision: 10421 Author: valhallasw Date: 2012-06-26 19:05:50 +0000 (Tue, 26 Jun 2012) Log Message: ----------- Changed behaviour of site.logged_in back to original and updated docs & tests to reflect this.
site.logged_in will return False if the user is logged in as a different user than requested.
Modified Paths: -------------- branches/rewrite/pywikibot/site.py branches/rewrite/tests/dry_site_tests.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2012-06-24 18:26:16 UTC (rev 10420) +++ branches/rewrite/pywikibot/site.py 2012-06-26 19:05:50 UTC (rev 10421) @@ -679,9 +679,11 @@ return gen
def logged_in(self, sysop=False): - """Return True if logged in with specified privileges, otherwise False. + """Return True if logged in with the user specified in user-config.py + (or the sysop user specified if the sysop parameter is True).
- @param sysop: if True, require sysop privileges. + @param sysop: if True, test if user is logged in as the sysop user + instead of the normal user.
""" if not hasattr(self, "_userinfo"): @@ -694,7 +696,7 @@ return False
if self.userinfo['name'] != self._username[sysop]: - pywikibot.warning("Logged in as %s instead of %s" % (self.userinfo['name'], self._username[sysop])) + return False
return True
Modified: branches/rewrite/tests/dry_site_tests.py =================================================================== --- branches/rewrite/tests/dry_site_tests.py 2012-06-24 18:26:16 UTC (rev 10420) +++ branches/rewrite/tests/dry_site_tests.py 2012-06-26 19:05:50 UTC (rev 10421) @@ -21,4 +21,4 @@ x._userinfo['name'] = 'sysop_user' x._userinfo['groups'] = ['sysop'] assert x.logged_in(True) - assert x.logged_in(False) \ No newline at end of file + assert not x.logged_in(False)