Giter Site home page Giter Site logo

appengine-clj's Introduction

appengine-clj

Library aimed at making life on Google AppEngine clean and easy for a Clojure app.

appengine-clj.users

Convenience API for the com.google.appengine.api.users package.

The user-info function can be called from anywhere to get the current user and a UserService.
For a more functional approach, a Ring middlware function is provided
to assoc the user info into every request under the key :appengine-clj/user-info.

appengine-clj.datastore

A convenience API for the com.google.appengine.api.datastore package providing access to Google’s schema-free datastore.

It allows you to work with immutable data structures instead of mutable Entity instances.

(require '[appengine-clj.datastore :as ds])
(ds/create {:kind "Person" :name "Jimmmy" :age 25})
=> {:kind "Person" :key #<Key Person(1138)> :name "Jimmmy" :age 25}

appengine-clj.test-utils

Provides setup and teardown of an in-memory Datastore for use in tests or from a REPL.
If you’re using clojure.contrib.test-is, you can use the dstest macro to get a fresh Datastore for each test.


Copyright © 2009 John D. Hume.

Released under an MIT license.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

appengine-clj's People

Contributors

duelinmarkers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

appengine-clj's Issues

datastore and updating values

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.

wrap-requiring-login doesn't pass a destination URL to createLoginURL

From http://elhumidor.blogspot.com/2009/04/clojure-on-google-appengine.html?showComment=1242361500000#c5712852478171054851

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

UserService and interactive development

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.