简体   繁体   English

Google Apps引擎Django表格pyamf

[英]google apps engine django form pyamf

My flash-pyamf-gae works nice. 我的flash-pyamf-gae运作良好。 Now I would like to create a classic Django form by following the google tutorial : http://code.google.com/appengine/articles/djangoforms.html I did but when I post the data entered in my form i get the following message from pyamf : 现在,我想按照Google教程创建经典的Django表单: http : //code.google.com/appengine/articles/djangoforms.html我这样做了,但是当我发布在表单中输入的数据时,我收到以下消息来自pyamf:

Malformed stream (amfVersion=110) 流格式错误(amfVersion = 110)

400 Bad Request The request body was unable to be successfully decoded. 400错误的请求无法成功解码请求正文。

Traceback: 追溯:

Traceback (most recent call last): 追溯(最近一次通话):
File "C:\\Users\\Giil\\Documents\\dev\\gae\\moviesbuilder\\pyamf\\remoting\\gateway\\google.py", line 79, in post logger=self.logger, timezone_offset=timezone_offset) 文件“ C:\\ Users \\ Giil \\ Documents \\ dev \\ gae \\ moviesbuilder \\ pyamf \\ remoting \\ gateway \\ google.py”第79行,位于post logger = self.logger,timezone_offset = timezone_offset中)
File "C:\\Users\\Giil\\Documents\\dev\\gae\\moviesbuilder\\pyamf\\remoting_ init _.py", line 640, in decode msg.amfVersion) DecodeError: Malformed stream (amfVersion=110)Malformed stream (amfVersion=110) 文件“ C:\\ Users \\ Giil \\ Documents \\ dev \\ gae \\ moviesbuilder \\ pyamf \\ remoting_ init _.py”,行640,在解码msg.amfVersion中)DecodeError:格式错误的流(amfVersion = 110)格式错误的流(amfVersion = 110 )

Now that make sens to me because what I send from my form is not amf. 现在这对我很有意义,因为我从表格发送的不是amf。 How can I deal with this ? 我该如何处理?

Note : I have the feeling that the problems come from my app.yaml I have no special handler to tell the application to process this form differently...Malformed stream (amfVersion=110) 注意:我感觉问题出在我的app.yaml上,我没有特殊的处理程序来告诉应用程序以不同的方式处理此表单...格式错误的流(amfVersion = 110)

I solved the problem my own way : 我用自己的方式解决了这个问题:

My Form (the post is directed towards another function and not just "/" as in google example) : 我的表格(帖子指向其他功能,而不仅仅是Google示例中的“ /”):

class Projects(webapp.RequestHandler):
    def get(self):
        self.response.out.write('<html><body>'
                                '<form method="POST" '
                                'action="/ProjectsPage">'
                                '<table>')
        self.response.out.write(ProjectForm())
        self.response.out.write('</table>'
                                '<input type="submit">'
                                '</form></body></html>')

And then what I need to write to the dataStore and display the list : 然后我需要写到dataStore并显示列表:

class ProjectsPage(webapp.RequestHandler):
     #getting data and saving
     def post(self):
        data = ProjectForm(data=self.request.POST)
        if data.is_valid():
            # Save the data, and redirect to the view page
            entity = data.save(commit=False)
            entity.added_by = users.get_current_user()
            entity.put()
            self.redirect('/projects.html')
        else:
            # Reprint the form
            self.response.out.write('<html><body>'
                                    '<form method="POST" '
                                    'action="/">'
                                    '<table>')
            self.response.out.write(data)
            self.response.out.write('</table>'
                                    '<input type="submit">'
                                    '</form></body></html>')
    #display list of projects
    def get(self):
        query = db.GqlQuery("SELECT * FROM Project WHERE added_by=:1 ORDER BY name",users.get_current_user())
        template_values = {
            'projects': query,
        }
        path = os.path.join(os.path.dirname(__file__), 'templates/projects.html')
        self.response.out.write(template.render(path, template_values))   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM