Take the 2-minute tour ×

As with the command line in Pylons call the REST function from controller such as update? How to pass a request.POST to update function?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You need to use paster's post command. Below, I post to /login/attempt of a local app I've wrote.

$ paster post development.ini /login/attempt email_address=me password=invalid

## It returns this JSON
{"status": "fail", "value": "me is not a registered email address."}

Here is the docs for paster post -

Usage: C:\cygwin\home\jaime\virtualenv\sstesting\Scripts\paster-script.py post [options] CONFIG _FILE URL [OPTIONS/ARGUMENTS] Run a request for the described application

This command makes an artifical request to a web application that uses a paste.deploy configuration file for the server and application. Use 'paster request config.ini /url' to request /url. Use 'paster post config.ini /url < data' to do a POST with the given request body. If the URL is relative (doesn't begin with /) it is interpreted as relative to /.command/. The variable environ['paste.command_request'] will be set to True in the request, so your application can distinguish these calls from normal requests. Note that you can pass options besides the options listed here; any unknown options will be passed to the application in environ['QUERY_STRING'].

Options: -h, --help show this help message and exit -v, --verbose -q, --quiet -n NAME, --app-name=NAME Load the named application (default main) --config-var=NAME:VALUE Variable to make available in the config for %()s substitution (you can use this option multiple times) --header=NAME:VALUE Header to add to request (you can use this option multiple times) --display-headers Display headers before the response body

share|improve this answer
add comment

The simplest thing would be to make a HTTP POST request directly:

$ curl -d 'arg1=value&arg2=another' http://host/path/controller/responds/to/
share|improve this answer
add comment

Your Answer


