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 1109529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:14:58+00:00 2026-05-17T02:14:58+00:00

I’m using pylons, and my action of controller is: class UserController(BaseController): def create(self): name

  • 0

I’m using pylons, and my action of controller is:

 class UserController(BaseController):

      def create(self):
           name = request.POST['name']
           email = request.POST['email']
           password = request.POST['password']
           ...

But I found in turbogears, I can do like this:

 class UserController:

      def create(self, name, email, password):
           ...

How to do the same in pylons?


UPDATE

I’ve searched in google, and asked in some other forums, but still not get the answer. Nobody knows(or interested in) such a question?

  • 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-17T02:14:59+00:00Added an answer on May 17, 2026 at 2:14 am

    It sounds like you want to give arguments to the create() method of your controller that are derived directly from elements of the POST data. You can do this, but it’s rather fiddly.

    The shortest way to do it – a fragile way – would be to just define the action like so, using those environment variables as defaults for the action.

    class UserController(Base):
      def create(self, name=request.POST['name'], email=request.POST['email'], ...):
            ...
    

    The thing is that even though it may appear cumbersome, the first method you showed probably is a better way to do it, because it gives you more room to recover gracefully from those variables not being what you expect them to be.

    If you feel like getting really fiddly, you can push this logic into routing.py. The POST data is already available there, just not as directly, because logic like this belongs in your controller. You would use a conditional method in Routes, which gives you access to environ[wsgi.input], which has the POST data, then extract your desired data from there, and push it into the match_dict dictionary, which in turn would let you feed the POSTDATA directly to your controller action’s arguments. Here’s the Pylons Book section on conditional functions in routing.py, and here’s a similar question here on SO and another, which should help if you really want to work with wsgi.input directly.

    However, instead of either of those things, I would use your original method:

    class UserController(BaseController):
        def create(self):
           name = request.POST['name']
           email = request.POST['email']
           password = request.POST['password']
           ...
    

    It’s definitely possible to parse the POST data before it gets to your controller and to take actions on it before then. However, looking at POST data and deciding what to do with it is a controller’s role, not Routes’ role or a middleware role. If you decide to – for example – start fiddling with the POST data in routing.py, you’re losing some of the loosely-coupled advantages of Pylons and to a smaller extent the whole WSGI shebang.

    You will see Pylons controllers that look like this, though:

    class UserController(BaseController):
        def create(self, name, spam):
           ...
    

    However, in those cases, the values of “name” and “spam” come from the query string (and from Routes’ map), not from the POST data.

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

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.