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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:36:07+00:00 2026-05-14T00:36:07+00:00

I am using this middleware to make my app restful, but it looks like

  • 0

I am using this middleware to make my app restful, but it looks like my form parameters are not coming through:

from google.appengine.ext import webapp

class RestHTTPMiddleware(object):
  def __init__(self, app):
    self.app = app

  def __call__(self, environ, start_response):
    method = webapp.Request(environ).get('_method')
    request = Request(environ)
    environ['wsgi.input'] = StringIO.StringIO(request.body)

    if method:
      environ['REQUEST_METHOD'] = method.upper()

    return self.app(environ, start_response)

when I submit a form and the debug it using:

def put(self):
    logging.debug(self.request.get('description'))

the logger is empty. The put(self) method is being called, I have tested it using the logger and my debug message is shown.

2nd revision:

from google.appengine.ext import webapp
from webob import Request
import logging
import StringIO

class RestHTTPMiddleware(object):
  def __init__(self, app):
    self.app = app

  def __call__(self, environ, start_response):
    request = Request(environ)
    environ['wsgi.input'] = StringIO.StringIO(request.body)

    method = webapp.Request(environ).get('_method')

    if method:
      environ['REQUEST_METHOD'] = method.upper()

    return self.app(environ, start_response)

Latest changes:

from google.appengine.ext import webapp
from webob import Request
import logging
import StringIO

class RestHTTPMiddleware(object):
  def __init__(self, app):
    self.app = app

  def __call__(self, environ, start_response):
    request = Request(environ)
    body = StringIO.StringIO(request.body)

    method = webapp.Request(environ).get('_method', None)

    if method:
      environ['REQUEST_METHOD'] = method.upper()
      environ['wsgi.input'] = body

    return self.app(environ, start_response)
  • 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-14T00:36:07+00:00Added an answer on May 14, 2026 at 12:36 am

    Instantiating webapp.Request and calling .get on it causes it to read the request body and parse form parameters in it. When your actual webapp starts later, it instantiates another request object, and once again tries to read the request body – but it’s already been read, so nothing is returned.

    You could modify your middleware to store a copy of the request body and put it back in the WSGI environment. There are other options:

    • If the _method arg will always be a query string parameter instead of a posted form parameter, you can use webapp.Request(environ).GET.get(‘method’), which won’t read the request body.
    • You could override WSGIApplication.call to change how it does dispatch.
    • You could subclass WSGIApplication and supply a custom REQUEST_CLASS, being a function that builds a real request object, then modifies the environment that was passed in to suit you (hack!).
    • You could define a custom webapp RequestHandler base class that implements initialize(), reaching in to the request object’s WSGI dict and changing the method (hack!).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know why this is happening, but after submitting a form via JS (using
Using this answer , I created a sample localized app. My question is, is
I'm trying to modify a header using Middleware in Pylons to make my application
I'm using Django 1.3, and I'd like to modify the session middleware to add
I Am using exception notifier like this in my rails 3.0.7- gem 'exception_notification_rails3', :require
I'm writing a middleware that does something like this Given I am logged in
When I run this command in MySQL: SELECT * FROM v WHERE v.firstname LIKE
I'm not sure if decorators are the best way to do this, but I've
I'm using node.js and the less compiler middleware: app.configure(function() { // ... app.use(express.compiler({ src:
Using this pipeline I can play two of the same videos using the videomixer,

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.