gcv/appengine-magic

POST and GET parameters empty

supercentenarian opened this issue · 6 comments

gcv commented

Yes, it looks like parameters get stripped out in dev_appserver.sh mode. I consider dev_appserver.sh support an afterthought, and if it doesn't work because the App Engine team changed something in the main App Engine libraries, I will not work on fixing it in mainline appengine-magic. (If you feel like figuring it out and want to send me a patch, I'll accept it, however.) If it remains broken over the next few App Engine releases, I'll probably remove dev_appserver.sh support from future versions of appengine-magic.

You should use interactive REPL tools for development. They do everything dev_appserver.sh does, and more. Your example works fine with them. Your example also works in production App Engine, with one change. For some reason, production does not like routes named "/form" (they generate 404s). I don't know if this is a transient problem on Google's side. Renaming the route to something else (e.g., "/fm") worked.

I have this code and I'm not getting the parameters for POST. Can you see what's wrong with it? I uploaded it to production and it's not printing out the post parameters either.

-core.clj
(ns test.core
(:use compojure.core
[clojure.pprint :only [pprint]])
(:require [appengine-magic.core :as ae]))
(defroutes simple-example-app-handler
(POST "/parsepost" request
{:status 200
:headers {"Content-Type" "text/plain"}
:body
(str (pr-str request))
})
(GET "/test" req
{:status 200
:headers {"Content-Type" "text/html"}
:body
"print html form with action=parsepost here, github takes out the html"
}))
(ae/def-appengine-app test-app #'simple-example-app-handler)

-app_servlet.clj
(ns test.app_servlet
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use test.core)
(:use [appengine-magic.servlet :only [make-servlet-service-method]]))
(defn -service [this request response](%28make-servlet-service-method test-app%29 this request response))

-project.clj
(defproject test "1.0.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
[compojure "0.6.4"]
[hiccup "0.3.5"]]
:dev-dependencies [[appengine-magic "0.4.2"]
[swank-clojure "1.3.1"]])

gcv commented

I'm having a rough time reading this. Could you repost it in a way that keeps the code formatting intact? Prepending four spaces to each line might do the trick. Or, you can post a gist (https://gist.github.com/).

Sorry, I post the source files here: https://gist.github.com/1081299
I uploaded to production here: http://myweb-power.appspot.com/test

I do not see the post parameters. What am I doing wrong?
Please, help. Thanks.

gcv commented

The latest versions of Compojure do not automatically place params in the request. You can read about it in the "Breaking Changes" section of the Compojure README file. You just need to include the wrap-params (and, optionally, wrap-keyword-params) middleware in your application. Take a look at my fork of your gist: https://gist.github.com/1081971 — I only changed the core.clj file.

Perfect! Thank you very much, you are great. Thanks again.