标签: appengine-magic

在Clojure中使用宏

我特意尝试使用Clojure中的appengine-magic为crud函数生成样板,以便与Google App Engine数据存储区一起使用.我很难弄清楚如何从我在下面复制的模型中生成值.

(def *model* {:users [{:name "Adam"
                       :email "adam@gmail.com"
                       :registered-on "07-05-2011"}
                      {:name "Greg"
                       :email "gregory@gmail.com"
                       :registered-on "11-05-2011"}]
              :post [{:title "A"
                      :authour "Adam"}
                     {:title "B"
                      :author "Greg"}]})
Run Code Online (Sandbox Code Playgroud)

我对appengine-magic相当新,但是它提供了一种不确定性,允许你定义可以放入数据存储区并保存的实体!它允许您将预定义的实体保存到数据存储区中.

采取以下形式:

(ds/defentity Post [title author])
(ds/save! (Post. title author))
Run Code Online (Sandbox Code Playgroud)

现在我要定义:

(defn list-entities [model]
  "Takes a representation of the model and lists the entities in preparation for generating defentities"
  (interleave (vec (map first (partition 1 (map (comp symbol capitalize #(str % ".") name) (keys model)))))
    (map vec (map keys (map first (vals model)))))) …
Run Code Online (Sandbox Code Playgroud)

macros clojure appengine-magic google-cloud-datastore

6
推荐指数
1
解决办法
702
查看次数

"帮助Arthur找到他的受限制的课程"或"我怎样才能使谷歌应用程序引擎快乐"

在这里,我正在使用java.rmi.server.UID哪个令人不安的GAE.之后:只有我对骨头的依赖我才陷入僵局.

(ns helloworld.core
  (:use ;[hiccup.core]
        [hiccup.page-helpers :only (html5 include-css)]
        [clojure.contrib.string :only (split)]
        [compojure.core :only (defroutes GET)]
        [hiccup.middleware :only (wrap-base-url)])
  (:require [appengine-magic.core :as ae]
            [compojure.route :as route
              :only (resources not-found) ]
            [compojure.handler :as handler :only (site)])
  (:gen-class :extends javax.servlet.http.HttpServlet))

 (defn index-page
  ([name]
     (html5
      [:head
       [:title (str "Hello " name)]
       (include-css "/css/style.css")]
      [:body
       [:h1 (str "Hello " name)]]))
  ([] (index-page "World")))

(def match-opperator
  { "add"      +
    "subtract" -
    "multiply" *
    "divide"   /})

(defroutes hello-routes
  (GET "/:f/*" [f & x]
       (index-page …
Run Code Online (Sandbox Code Playgroud)

java google-app-engine clojure compojure appengine-magic

6
推荐指数
1
解决办法
411
查看次数