This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Introduction

repoze.bfg.restrequest implements 4 additional Request types for use with RESTful applications.

Imagine you want to create separate views for one resource (identified by an URL) and different HTTP methods. In a default repoze.bfg project you can e.g. write:

from repoze.bfg.restrequest import IGETRequest, IPOSTRequest
from webob import Response

def my_view_get(context, request):
    return Response("GET\n")

def my_view_post(context, request):
    return Response("POST "+request.body+"\n")

This defines one method my_view_get in case a GET request is performed on this resource and my_view_post in case a POST request is performed. You can do similar things with PUT or DELETE.

In order to enable these views you need to wire them in configure.zcml like this:

<!-- include to activate the event handler for marking REST requests -->
<include package="repoze.bfg.restrequest" />

<bfg:view for=".models.IMyModel"
      request_type="repoze.bfg.restrequest.interfaces.IGETRequest"
      view=".views.my_view_get"
      />

<bfg:view for=".models.IMyModel"
      request_type="repoze.bfg.restrequest.interfaces.IPOSTRequest"
      view=".views.my_view_post"
      />

You can do the same using repoze.bfg.convention in which case your views would look like this:

from repoze.bfg.restrequest import IGETRequest, IPOSTRequest
from webob import Response

@bfg_view(request_type=IGETRequest, for_=models.IMyModel)
def my_view_get(context, request):
    return Response("GET\n")

@bfg_view(request_type=IPOSTRequest, for_=models.IMyModel)
def my_view_post(context, request):
    return Response("POST "+request.body+"\n")

Make sure you nevertheless include repoze.bfg.restrequest in your configure.zcml.

Testing your application

A simple test for the above would be to start your application and use curl to see what the result is for different methods:

$ curl http://127.0.0.1:6543/
GET

$ curl http://127.0.0.1:6543/ -d "posttest"
POST posttest

Changelog

1.0 - initial release (19 Oct 2008)

  • Initial release

1.0.1 - package bugfixing

  • moved HISTORY.txt to main directory so that setup.py finds and packages it.
Release History

Release History

1.0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
repoze.bfg.restrequest-1.0.1.tar.gz (3.3 kB) Copy SHA256 Checksum SHA256 Source Oct 21, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting