0

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)

MPelletier
  • 16,256
  • 15
  • 86
  • 137
gpasse
  • 4,380
  • 7
  • 44
  • 75

1 Answers1

0

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))   
gpasse
  • 4,380
  • 7
  • 44
  • 75