Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install emulaterest

How to install emulaterest

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install emulaterest
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1
0.2Never BuiltWhy not?
0.1 Available View build log
Windows (64-bit)
0.1
0.2Never BuiltWhy not?
0.1 Available View build log
Mac OS X (10.5+)
0.1
0.2Never BuiltWhy not?
0.1 Available View build log
Linux (32-bit)
0.1
0.2Never BuiltWhy not?
0.1 Available View build log
Linux (64-bit)
0.2 Available View build log
0.1 Available View build log
 
Author
License
MIT
Imports
Lastest release
version 0.2 on May 21st, 2013

WSGI middleware that does Rails style PUT and DELETE request emulation.

The middleware intercepts the wrapped application's response and looks for forms with method="PUT" or method="DELETE". For each such form it replaces the value of method with "POST" and adds a hidden input field _method that contains the original request method. It also intercepts incoming requests and does the inverse transformation.

What this all means is that you can use PUT and DELETE forms in your HTML code, without having to worry about browser support for these request methods.

Install

You can install EmulateRest from PyPI:

easy_install emulaterest

or you can install the latest version from the github repository:

git clone git://github.com/abiczo/emulaterest.git
cd emulaterest
python setup.py install

Notes

  • For text/html documents the default behavior is to inject HTML style <input> elements. You can tell EmulateRest to inject XHTML style <input/> elements either by using the force_xhtml option or by serving your documents as application/xhtml+xml.
  • If you are using a gzipping middleware or any other middleware that modifies the content-encoding, make sure that EmulateRest is wrapped in that middleware and not the other way round.

Example

A complete working example using web.py:

import web

urls = ('/', 'index')

class index:
    def GET(self):
        web.ctx['headers'].append(('Content-Type', 'text/html'))
        return """<html><head><title>PUT test</title></head><body><div>
            <form method="PUT" action="/">
                <div>
                    <input type="text" name="inp" value="value">
                    <input type="submit" value="Submit">
                </div>
            </form>
            </div></body></html>
            """

    def PUT(self):
        return 'PUT ' + str(web.input())

if __name__ == '__main__':
    import emulaterest
    app = web.application(urls, globals())
    app.run(emulaterest.EmulateRestMiddleware)

Subscribe to package updates

Last updated May 21st, 2013

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.