This error occurs when following the TG2 wiki20.
I could not see an easy answer on here that was related to TG2, and this issue could be quite confusing, as it occurs during the official tutorial.
The problem is when using the tg.redirect method, as described in the tutorial:
@expose('wiki20.templates.page')
def _default(self, pagename="FrontPage"):
from sqlalchemy.exc import InvalidRequestError
try:
page = DBSession.query(Page).filter_by(pagename=pagename).one()
except InvalidRequestError:
raise redirect("notfound", pagename=pagename)
content = publish_parts(page.data, writer_name="html")["html_body"]
root = url('/')
content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
return dict(content=content, wikipage=page)
Trying to use the method above, copied exactly from the tutorial returns the error. The issue is clearly with the keyword arguments accepted by the redirect method.
I was able to solve this problem by checking the docs for the redirect method itself:
You can that it accepts a
paramsparameter (and NOT **kwargs -> perhaps in an earlier version, **kwargs was accepted). Unfortunately, theparamsargument is not type-hinted, but I guessed it should be adict, and was correct.The working method, as far as I can tell, should look like this:
EDIT:
There is a "latest" version of the tutorial, which DOES include the change above, exactly as it is here (but it wasn't the default version for me when I first accessed the tutorial for some reason).
I will leave this here in case it helps any other googlers who didn't check their version numbers!