Created
June 2, 2010 07:37
-
-
Save smartrevolution/422066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;taken from clj-gae-datastore/src/example/clojure/com/freiheit/gae/datastore/example.clj | |
; short-cut to set-up the GAE environment for interactive programming with Clojure and GAE | |
(ns com.freiheit.gae.datastore.example | |
(:use | |
[clojure.contrib def]) | |
(:import | |
[com.google.apphosting.api ApiProxy ApiProxy$Environment] | |
[java.io File] | |
[java.util HashMap] | |
[com.google.appengine.tools.development ApiProxyLocalFactory ApiProxyLocalImpl LocalServiceContext LocalServerEnvironment] | |
[com.google.appengine.api.labs.taskqueue.dev LocalTaskQueue])) | |
(defn init-app-engine | |
"Initialize the app engine services. Call it once from the REPL" | |
([] | |
(init-app-engine "/tmp")) | |
([dir] | |
(let [default-port 9090 | |
env-proxy (proxy [ApiProxy$Environment] [] | |
(isLoggedIn [] false) | |
(getRequestNamespace [] "") | |
(getDefaultNamespace [] "") | |
(getAttributes [] (let [attributes (HashMap.) | |
local-server-url (str "http://localhost:" default-port)] | |
(.put attributes "com.google.appengine.server_url_key" local-server-url) | |
attributes)) | |
(getAppId [] "local")) | |
local-env (proxy [LocalServerEnvironment] [] | |
(getAppDir [] (File. dir)) | |
(getAddress [] "localhost") | |
(getPort [] default-port) | |
(waitForServerToStart [] nil)) | |
api-proxy (.create (ApiProxyLocalFactory.) local-env)] | |
(do | |
(com.google.apphosting.api.ApiProxy/setEnvironmentForCurrentThread env-proxy) | |
(com.google.apphosting.api.ApiProxy/setDelegate api-proxy))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment