def authenticate_with_password(request, page_view_restriction_id, page_id):
 restriction = get_object_or_404(PageViewRestriction, id=page_view_restriction_id)
 page = get_object_or_404(Page, id=page_id).specific
 if (request.method == u'POST'):
  form = PasswordPageViewRestrictionForm(request.POST, instance=restriction)
  if form.is_valid():
   has_existing_session = (settings.SESSION_COOKIE_NAME in request.COOKIES)
   passed_restrictions = request.session.setdefault(u'passed_page_view_restrictions', [])
   if (restriction.id not in passed_restrictions):
    passed_restrictions.append(restriction.id)
    request.session[u'passed_page_view_restrictions'] = passed_restrictions
   if (not has_existing_session):
    request.session.set_expiry(0)
   return redirect(form.cleaned_data[u'return_url'])
 else:
  form = PasswordPageViewRestrictionForm(instance=restriction)
 action_url = reverse(u'wagtailcore_authenticate_with_password', args=[restriction.id, page.id])
 return page.serve_password_required_response(request, form, action_url)

def authenticate_with_password ( request , page_view_restriction_id , page_id ) : restriction = get_object_or_404 ( PageViewRestriction , id = page_view_restriction_id ) page = get_object_or_404 ( Page , id = page_id ) . specific if ( request . method == u'POST' ) : form = PasswordPageViewRestrictionForm ( request . POST , instance = restriction ) if form . is_valid ( ) : has_existing_session = ( settings . SESSION_COOKIE_NAME in request . COOKIES ) passed_restrictions = request . session . setdefault ( u'passed_page_view_restrictions' , [ ] ) if ( restriction . id not in passed_restrictions ) : passed_restrictions . append ( restriction . id ) request . session [ u'passed_page_view_restrictions' ] = passed_restrictions if ( not has_existing_session ) : request . session . set_expiry ( 0 ) return redirect ( form . cleaned_data [ u'return_url' ] ) else : form = PasswordPageViewRestrictionForm ( instance = restriction ) action_url = reverse ( u'wagtailcore_authenticate_with_password' , args = [ restriction . id , page . id ] ) return page . serve_password_required_response ( request , form , action_url )
handle a submission of passwordpageviewrestrictionform to grant view access over a subtree that is protected by a pageviewrestriction .