Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python/google应用程序引擎中放置不起作用的参数_Python_Http_Google App Engine_Web Applications_Put - Fatal编程技术网

在python/google应用程序引擎中放置不起作用的参数

在python/google应用程序引擎中放置不起作用的参数,python,http,google-app-engine,web-applications,put,Python,Http,Google App Engine,Web Applications,Put,我正在使用python和google应用程序引擎上的webapp框架开发一个简单的RESTful Web服务 基本上,我是通过AJAX/jquery发送所有请求的——对于POST来说,它就像一个符咒,但当我使用PUT发送数据时,参数是空的/未处理 这是我的建议: $.ajax({ type: "PUT", url: "/boxes", data: { name: this.name, archived: this.archived },

我正在使用python和google应用程序引擎上的webapp框架开发一个简单的RESTful Web服务

基本上,我是通过AJAX/jquery发送所有请求的——对于POST来说,它就像一个符咒,但当我使用PUT发送数据时,参数是空的/未处理

这是我的建议:

    $.ajax({
        type: "PUT",
        url: "/boxes",
        data: { name: this.name, archived: this.archived  },
        success: function(msg){
        }
    });
萤火虫说我放了:

Parameter   application/x-www-form-urlencoded
archived    false
name    123112323asdasd
但是使用以下python代码:

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util, template
from google.appengine.ext import db
from google.appengine.api.datastore_types import *
from django.utils import simplejson as json

import cgi
import datetime

class BoxHandler(webapp.RequestHandler):

def post(self): #working
    print "test"
    self.response.out.write(self.request.get("name"))

def put(self):
    print "test" #not working
    self.response.out.write(self.request.get("name"))
我会回来的

test
Status: 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0
所以。。嗯,这里有我遗漏的东西吗

干杯,
Martin

代码中的
put
方法被正确调用,因为正如您所看到的,
test
被打印出来; 不起作用的是参数解析,这是
webob
类中的一个问题

您可以尝试解析request.body以提取查询字符串

def put(self):
    print "test"
    name = parse_body_to_extract_your_parameter(self.request.body)
    self.response.out.write(name)

你能把你的Python代码放到上下文中吗?什么是自我类型。请求?插入全班-希望有帮助-谢谢