Overriding the default view for Forbidden/HTTPForbidden.

2 views
Skip to first unread message

Torkel Lyng

unread,
Nov 26, 2011, 10:31:30 AM11/26/11
to ptahproject
Hello, I'm trying to override the default forbidden view. Instead of
the default view I want to display a login form, but I'm unable to
override it. What I've tried is adding a view for both
ptah.cms.Forbidden and pyramid.httpexceptions.HTTPForbidden, I tried
using something like this code:

from pyramid import security
from pyramid.httpexceptions import HTTPFound, HTTPForbidden

import ptah
from ptah import form, view

@view.pview(context=HTTPForbidden)
def login_required(request):
return str('Hello World')


I did the same approach for ptah.cms.Forbidden without any success.
How am I supposed to override it?

Alan Runyan

unread,
Nov 26, 2011, 12:55:53 PM11/26/11
to ptahp...@googlegroups.com, ptahproject
just use pyramid registration. pview not public API at moment

Alan Runyan
Enfold Systems
Sent from my iPhone

Nikolay Kim

unread,
Nov 26, 2011, 1:39:16 PM11/26/11
to ptahp...@googlegroups.com

this code works for me. have you seen default pyramid forbidden view?

define view only for HTTPForbidden. you dont need to define view for
ptah.cms.Forbidden
because it inherits from HTTPForbidden.

Reply all
Reply to author
Forward
0 new messages