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

  • SEARCH
  • Home
  • 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 8235393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:47:40+00:00 2026-06-07T18:47:40+00:00

i need the request for this custom validation in deform to work: def d_validator(node,

  • 0

i need the “request” for this custom validation in deform to work:

def d_validator(node, value):
    if not value:
        raise Invalid(node, 'Enter a Password')
    if len(value) < 5:
        raise Invalid(node, 'Invalid Length')
    userid = authenticated_userid(userrequest)
    dbsession = DBSession()
    userInfo = dbsession.query(User).filter(_and(User.id==userid, User.password == value)).first()
    if not userInfo:
        raise Invalid(node, 'Invalid password')

so i tried this:

class Form(field.Field):
    def __init__(self, schema, **kw):
        self.saved_user = kw.pop('userrequest')
        log.info(self.saved_user)
        super(Form, self).__init__(schema, **kw)

and then:

Form(schema, buttons=('Actualizar',), 'userrequest'=request)

but i get SyntaxError: keyword can’t be an expression

i know this could be python related, bear with me, thanks in advance

  • 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-06-07T18:47:42+00:00Added an answer on June 7, 2026 at 6:47 pm

    Keywords are indeed not expressions, but 'userrequest'=request is. Remove the quotes:

    Form(schema, buttons=('Actualizar',), userrequest=request)
    

    Also, why are you basing your custom Form class on field.Field? I haven’t used deform yet myself, but from a quick glance at the documentation suggest strongly you should be inheriting from deform.Form instead.

    Last but not least, you could fall back to the pyramid thread-local request instead:

    def d_validator(node, value):
        if not value:
            raise Invalid(node, 'Enter a Password')
        if len(value) < 5:
            raise Invalid(node, 'Invalid Length')
        userid = authenticated_userid(get_current_request())
        dbsession = DBSession()
        userInfo = dbsession.query(User).filter(_and(User.id==userid, User.password == value)).first()
        if not userInfo:
            raise Invalid(node, 'Invalid password')
    

    Yes, this is often frowned upon, but could be easier in your case to deal with.

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

Sidebar

Related Questions

I need to grab a certain custom HTTP header value from every request and
I have code that does a web-service request. While doing this request I need
My program flow is like this: I need to sequential processing per user's request
I Need to make a webpage. asp.net this webpage recieve parameter by using Request.Querystring
I have linq request. I need get item.Title in select. how do this? var
I need some help with django request I want to add a custom form
I need to send a request to a user using my custom dialog (which
I'm developing a custom shipping method for Magento. For this shipping method I need
I need to set the HTTP_X_FORWARDED_FOR value in the Request.ServerVariables collection. I'm trying with
Do I even need this rule anymore? I don't see any requests incoming for

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.