             val (get-val-ds v)]
         ;; (log/trace "emap-new setting prop: " k prop v val)
         (.setProperty e prop val)))
-    (.put ds e)
+    (.put datastore e)
     ;; (PersistentEntityMap. e nil)))
     e))
 

;;               ;; (log/trace "setting val" val (type val))
;;               ;; (flush)
;;               (.setProperty e prop val)))))
;;       (.put ds e)
;;       ;; (log/trace "saved entity " e)
;;       (PersistentEntityMap. e nil))))

;; (defn- emap-update-empty
;;   [keychain]
;;   (let [k (apply entity-key keychain)
;;         e (try (.get ds k)
;;                (catch EntityNotFoundException e nil)
;;                (catch DatastoreFailureException e (throw e))
;;                (catch java.lang.IllegalArgumentException e (throw e)))]
;;     (if (ds/entity-map? e)
;;           (PersistentEntityMap. e nil)
;;           (let [e (Entity. k)]
;;             (.put ds e)
;;             (PersistentEntityMap. e nil)))))

;; TODO: support embedded maps, e.g. (ds/emap!! [:Foo/bar] {:a 1, :b {:c 3, :d 4}})


(clojure.core/println "loading migae.datastore.adapter.gae")

(def datastore  ;; store-map
  (let [dsm (DatastoreServiceFactory/getDatastoreService)
;;        psm (ds/->PersistentStoreMap dsm nil nil)
        ]
