Groups
Conversations
All groups and messages
Send feedback to Google
Help
Training
Sign in
Groups
TurboGears
Conversations
About
How does one return a specific HTTP status code?
27 views
Skip to first unread message
Vipul Ved Prakash
unread,
Feb 5, 2020, 2:22:08 AM
2/5/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TurboGears
I'd like to return 401 from a controller. How does one do this?
best,
vipul
Vincenzo Castiglia
unread,
Feb 11, 2020, 5:47:17 PM
2/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TurboGears
see
https://turbogears.readthedocs.io/en/latest/reference/classes.html#tg.controllers.util.abort
I suggest you to use detail with gettext:
```
from tg import expose, abort
from tg.i18n import ugettext as _
@expose('templates...blah.blah')
def test(self):
return abort(401, detail=_('pretty message'))
```
take a look also at your controllers/error.py error controller
Reply all
Reply to author
Forward
0 new messages