views:

329

answers:

1

I have a form and I need to send the content to the server.

I use google authentication because only authorized people can send to the server.

The form is somthing like this:

<form action="/blog/submit" method="post">
...
</form>

The authentication is needed only during the submit, not entering the form page. So in the submit controller I used something like this:

class SubmitPage(webapp.RequestHandler):
    def post(self):
        if users.get_current_user() is None:
            self.redirect(users.create_login_url(self.request.uri))
            ...

The problem is that the return url in redirect is executed only ad an HTTP GET, not HTTP POST as I wanted.

I'd like to authenticate and then redirect to the submit page (POST), but it tries to execute a GET on the same url.

Is it possible to implement what I want?

+3  A: 

No, it's not possible to have POST data follow an HTTP redirect.

You should almost certainly be checking for a login before you display the form that's posting this data in the first place, but once the user gets to the form your best bet is probably to save the content to the datastore linked to a session ID you generate, and either set it as a cookie or add it to the redirect URI so you can retrieve it again when the user returns from the login page.

Wooble