谷歌应用程序引擎 django 形式 pyamf

发布于 2024-10-01 11:53:53 字数 884 浏览 5 评论 0原文

我的 flash-pyamf-gae 工作得很好。 现在我想按照 google 教程创建一个经典的 Django 表单: http://code .google.com/appengine/articles/djangoforms.html 我这样做了,但是当我发布表单中输入的数据时,我从 pyamf 收到以下消息:

格式错误的流 (amfVersion=110)

400 错误请求 请求正文为 无法成功解码。

回溯:

回溯(最近一次调用最后一次):
文件 “C:\Users\Giil\Documents\dev\gae\moviesbuilder\pyamf\remoting\gateway\google.py”, 第 79 行,已发布 logger=self.logger, timezone_offset=timezone_offset)
文件 "C:\Users\Giil\Documents\dev\gae\moviesbuilder\pyamf\remoting_init_.py", 第 640 行,解码中 msg.amfVersion) DecodeError: 格式错误的流 (amfVersion=110)格式错误的流 (amfVersion=110)

现在这对我来说很有意义,因为我从表单发送的内容不是 amf。我该如何处理这个问题?

注意:我感觉问题来自我的 app.yaml 我没有特殊的处理程序来告诉应用程序以不同的方式处理此表单...格式错误的流(amfVersion=110)

My flash-pyamf-gae works nice.
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 :

Malformed stream (amfVersion=110)

400 Bad Request The request body was
unable to be successfully decoded.

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)
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)

Now that make sens to me because what I send from my form is not 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声无音无过去 2024-10-08 11:53:53

我用自己的方式解决了问题:

我的表单(帖子针对另一个函数,而不仅仅是像谷歌示例中的“/”):

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>')

然后我需要写入数据存储并显示列表:

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))   

I solved the problem my own way :

My Form (the post is directed towards another function and not just "/" as in google example) :

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 :

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))   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文