Explorar el Código

Better handling when we are blocked from editing

.
tags/v0.2
Ben Kurtovic hace 12 años
padre
commit
d709ee00a7
Se han modificado 2 ficheros con 11 adiciones y 1 borrados
  1. +2
    -1
      earwigbot/exceptions.py
  2. +9
    -0
      earwigbot/wiki/page.py

+ 2
- 1
earwigbot/exceptions.py Ver fichero

@@ -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 Ver fichero

@@ -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)



Cargando…
Cancelar
Guardar