Bladeren bron

Better handling when we are blocked from editing

.
tags/v0.2
Ben Kurtovic 12 jaren geleden
bovenliggende
commit
d709ee00a7
2 gewijzigde bestanden met toevoegingen van 11 en 1 verwijderingen
  1. +2
    -1
      earwigbot/exceptions.py
  2. +9
    -0
      earwigbot/wiki/page.py

+ 2
- 1
earwigbot/exceptions.py Bestand weergeven

@@ -169,7 +169,8 @@ class PermissionsError(EditError):

We tried to do something we don't have permission to, like trying to delete
a page as a non-admin, or trying to edit a page without login information
and AssertEdit enabled.
and AssertEdit enabled. This will also be raised if we have been blocked
from editing.

Raised by :py:meth:`Page.edit <earwigbot.wiki.page.Page.edit>` and
:py:meth:`Page.add_section <earwigbot.wiki.page.Page.add_section>`.


+ 9
- 0
earwigbot/wiki/page.py Bestand weergeven

@@ -400,6 +400,15 @@ class Page(CopyvioMixIn):
elif error.code in ["emptypage", "emptynewsection"]:
raise exceptions.NoContentError(error.info)

elif error.code == "blocked":
if tries > 0 or not all(self.site._login_info):
raise exceptions.PermissionsError(error.info)
else:
# Perhaps we are blocked from being logged-out? Try to log in:
self.site._login(self.site._login_info)
self._token = None # Need a new token; old one is invalid now
return self._edit(params=params, tries=1)

elif error.code == "contenttoobig":
raise exceptions.ContentTooBigError(error.info)



Laden…
Annuleren
Opslaan