duelinmarkers / appengine-clj Goto Github PK
View Code? Open in Web Editor NEWClojure library to make life on Google AppEngine clean and easy
Clojure library to make life on Google AppEngine clean and easy
Hi, I was playing a little with GAE and this code and it seems that in order to be able to change an entity in the datastore, you must use the same Entity object that you get from the datastore. Using the same Key apparently is not sufficient. Therefore the design of your datastore functions is insufficient, because the Entity object is discarded.
I will probably fix it for myself by adding the object to the map, so it's possible to update the data using it.
Victor Rodriguez said...
Hello,
There is a bug in wrap-requiring-login: it doesn't pass a destination URL to createLoginURL().
Here is my fix (plus an extra functions).
Cheers,
Victor Rodriguez.
diff --git a/src/appengine_clj/users.clj b/src/appengine_clj/users.clj
index 61df7e5..53dc835 100644
--- a/src/appengine_clj/users.clj
+++ b/src/appengine_clj/users.clj
@@ -21,9 +21,14 @@
(application (assoc request :appengine-clj/user-info (user-info)))))
(defn wrap-requiring-login
- [application]
- (fn [request]
- (let [{:keys [user-service]} (:appengine-clj/user-info request)]
- (if (.isUserLoggedIn user-service)
- (application request)
- {:status 302 :headers {"Location" (.createLoginURL user-service)}}))))
+ ([application] (wrap-requiring-login application "/"))
+ ([application destination-url]
+ (fn [request]
+ (let [{:keys [user-service]} (:appengine-clj/user-info request)]
+ (if (.isUserLoggedIn user-service)
+ (application request)
+ {:status 302 :headers {"Location" (.createLoginURL user-service destination-url)}})))))
+
+(defn logout-url
+ ([] (logout-url "/"))
+ ([destination-url] (.createLogoutURL (:user-service (user-info)) destination-url)))
May 15, 2009 12:25 AM
I need to use the UserService support from GAE, and I can do it with appengine-clj just fine if I use the dev_appserver.sh. However, if I want to use Jetty (so that I may use SLIME) I get always stuck at this stacktrace:
2010-05-29 12:58:35.936::WARN: EXCEPTION
java.lang.NullPointerException
at com.google.appengine.api.users.UserServiceImpl.getCurrentUser(UserServiceImpl.java:102)
at appengine.users$user_info.invoke(users.clj:12)
at appengine.users$wrap_with_user_info$fn__1605.invoke(users.clj:22)
at ring.adapter.jetty$proxy_handler$fn__1585.invoke(jetty.clj:17)
at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler0 €handle(Unknown Source)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:864)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:533)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:207)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
I thought I required a wrapper much like your with-local-datastore, so I built one to load the LocalUserServiceTestConfig (all the required imports were added to the ns form)
(defmacro with-local-user [& body]
`(try (.setUp (test/local-service-test-helper (LocalUserServiceTestConfig.)))
~@Body
(finally (test/tear-down))))
And I'm firing up the server using this (test and users namespaces are from appengine-clj):
(defonce server
(with-local-user
(test/with-local-datastore
(run-jetty (users/wrap-with-user-info #'my-app) {:port 8080 :join? false}))))
I'm using clojure 1.2, compojure 1.4 + ring, and fukamachi's branch of you appengine-clj, but it doesn't change anything on the testing macros. Again, the application works great under the dev server and after being uploaded to google's servers too.
Could you point me towards my problem cause(s)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.