Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 981211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:30:22+00:00 2026-05-16T04:30:22+00:00

The validate and authenticate_form decorators don’t seem to play nice together. This is my

  • 0

The validate and authenticate_form decorators don’t seem to play nice together. This is my template:

<html>
<title>Test</title>
<body>
${h.secure_form('/meow/do_post')}
<input type="text" name="dummy">
<form:error name="dummy"><br>
<input type="submit" name="doit" value="Do It">
${h.end_form()}
</body>
</html>

And this is the controller:

import logging

from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect

from ocust.lib.base import BaseController, render
import formencode
import formencode.validators
from formencode import htmlfill
from pylons.decorators import validate
from pylons.decorators.secure import authenticate_form

class MeowForm(formencode.Schema):
    allow_extra_fields = True
    dummy = formencode.validators.NotEmpty()

class MeowController(BaseController):

    def index(self): 
        return render('/index.mako')

    @authenticate_form
    @validate(schema=MeowForm(), form='index')
    def do_post(self):
        return 'posted OK'

If validation fails, the form is re-rendered using htmlfill.render by the @validate decorator, but this strips out the authentication token, so a 403 CSRF detected error is shown the next time the form is submitted.

The authentication token seems to be stripped because @authenticate_form deletes the authentication token from request.POST.

If this is used instead:

@validate(schema=MeowForm(), form='index', force_defaults=False)

it works fine. Is there anything bad that can happen if force_defaults is set to False? The docs for htmlfill seem to recommend it be set to True when the defaults “are the result of a form submission”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:30:22+00:00Added an answer on May 16, 2026 at 4:30 am
    @validate(schema=MeowForm(), form='index')
    @authenticate_form
    def do_post(self):
    

    You need to change order of decorators, authenticate decorator must be last

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to validate logged in / authenticated users in my
I need to validate this simple pick list: <select name=<%= key %>> <option value=ETC
I just can't seem to figure this one out... As far as I know,
Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function
I validate in two ways - using spring validator for custom validation and javax.validation
I need to validate a date/time field on a webpage but want it to
Is it possible to validate an xml file against its associated schema using Visual
I need to validate an XML string (and not a file) against a DTD
I am trying to validate user id's matching the example: smith.jack or smith.jack.s In
How can I validate that my ASPNET AJAX installation is correct. I have Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.