[clouchdb-cvs] CVS clouchdb/src

peddy peddy at common-lisp.net
Fri Dec 28 16:25:51 UTC 2007


Update of /project/clouchdb/cvsroot/clouchdb/src
In directory clnet:/tmp/cvs-serv25209

Modified Files:
	tests.lisp package.lisp examples.lisp encoder.lisp 
	clouchdb.lisp clouchdb.asd 
Log Message:
Switched to simpler keyword encoding scheme


--- /project/clouchdb/cvsroot/clouchdb/src/tests.lisp	2007/12/21 19:58:31	1.7
+++ /project/clouchdb/cvsroot/clouchdb/src/tests.lisp	2007/12/28 16:25:51	1.8
@@ -68,7 +68,7 @@
   (let ((docs))
     (dolist (e data)
       (let ((doc (get-document (document-property id-field e))))
-	(if (not (document-property :_id doc))
+	(if (not (document-property :|_id| doc))
 	    (error (format t "Document ID=~S not found" 
 			   (document-property id-field e))))
 	(push e docs)))
@@ -114,7 +114,7 @@
   (:documentation "Test document-property")
   general-tests-document-property
   (ensure
-   (let ((doc '((:NAME . "name1") (:*NAME . "name2") (:*NA-ME . "NaMe"))))
+   (let ((doc '((:NAME . "name1") (:|Name| . "name2") (:|NaMe| . "NaMe"))))
      (reduce #'(lambda (a b) (and a b))
              (mapcar #'(lambda (e)
                          (equal (cdr (assoc (car e) doc))
@@ -171,24 +171,24 @@
 (addtest (clouchdb-db-admin-tests)
   (:documentation "Look for the welcome message and version info from server")
   generic-server-info-query
-  (ensure-same "Welcome" (document-property :couchdb (get-db-info)))
-  (ensure (document-property :version (get-db-info))))
+  (ensure-same "Welcome" (document-property :|couchdb| (get-db-info)))
+  (ensure (document-property :|version| (get-db-info))))
 
 (addtest (clouchdb-db-admin-tests)
   (:documentation "Ensure get-db-info reports non-existant databases")
   db-non-existance-test
   (ensure (setf *db-name* (create-temp-db-name)))
-  (ensure-same "not_found" (document-property :error (get-db-info)))
-  (ensure-same "missing" (document-property :reason  (get-db-info))))
+  (ensure-same "not_found" (document-property :|error| (get-db-info)))
+  (ensure-same "missing" (document-property :|reason|  (get-db-info))))
 
 (addtest (clouchdb-db-admin-tests)
   (:documentation "Create a database and ensure it's there, ensure it's deleted too")
   db-creation-test
   (ensure (setf *db-name* (create-temp-db)))
-  (ensure-same (document-property :db_name (get-db-info)) *db-name*)
-  (ensure-same 0 (document-property :doc_count (get-db-info)))
-  (ensure-same 0 (document-property :update_seq (get-db-info)))
-  (ensure (document-property :ok (delete-db))))
+  (ensure-same (document-property :|db_name| (get-db-info)) *db-name*)
+  (ensure-same 0 (document-property :|doc_count| (get-db-info)))
+  (ensure-same 0 (document-property :|update_seq| (get-db-info)))
+  (ensure (document-property :|ok| (delete-db))))
 
 (addtest (clouchdb-db-admin-tests)
   (:documentation "Make sure deleting a nonexistant db generates an error")
@@ -200,7 +200,7 @@
   db-ignore-delete-non-existant-db
   (ensure
    (document-property 
-    :error 
+    :|error| 
     (delete-db :if-missing :ignore :db-name (create-temp-db-name)))))
 
 (addtest (clouchdb-db-admin-tests)
@@ -214,20 +214,20 @@
   (:documentation "Ignore the duplicate db create error")
   db-ignore-create-existant-db
   (ensure (setf *db-name* (create-temp-db)))
-  (ensure (document-property :ok (create-db :if-exists :ignore)))
+  (ensure (document-property :|ok| (create-db :if-exists :ignore)))
   (ensure (delete-db)))
 
 (addtest (clouchdb-db-admin-tests)
   (:documentation "recreate option for create-db on existing db")
   db-recreate-db
   (ensure (setf *db-name* (create-temp-db)))
-  (ensure (document-property :ok (create-db :if-exists :recreate)))
+  (ensure (document-property :|ok| (create-db :if-exists :recreate)))
   (ensure (delete-db)))
 
 (addtest (clouchdb-db-admin-tests)
   (:documentation "recreate option for create-db on non-existant db")
   db-recreate-nonexistant-db
-  (ensure (document-property :ok (create-db :if-exists :recreate)))
+  (ensure (document-property :|ok| (create-db :if-exists :recreate)))
   (ensure (delete-db)))
 
 ;;
@@ -248,29 +248,29 @@
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Ensures the temporary db for these tests is succesfully created.")
   empty-test
-  (ensure-same (document-property :db_name (get-db-info)) *db-name*))
+  (ensure-same (document-property :|db_name| (get-db-info)) *db-name*))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Create a document with create-document")
   create-document-auto-id
-  (ensure (document-property :ok (create-document '((:a "test"))))))
+  (ensure (document-property :|ok| (create-document '((:a "test"))))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Create document with create-document, specify document ID")
   create-document-specified-id
-  (ensure (document-property :ok (create-document '((:a "test")) :id "specified"))))
+  (ensure (document-property :|ok| (create-document '((:a "test")) :id "specified"))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Create a document with a duplicate ID")
   create-document-specified-id-conflict
-  (ensure (document-property :ok (create-document '((:a "test")) :id "specified")))
+  (ensure (document-property :|ok| (create-document '((:a "test")) :id "specified")))
   (ensure-condition 'id-or-revision-conflict
     (create-document '((:a "test")) :id "specified")))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Create a document with put-document")
   put-document-create
-  (ensure (document-property :ok (put-document '((:a "test")) :id "specified"))))
+  (ensure (document-property :|ok| (put-document '((:a "test")) :id "specified"))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Create a document with put-document with no ID (error)")
@@ -295,13 +295,13 @@
 			(put-document doc)))
 		    ;;
 		    (let ((docinf (get-document "revizedalot" :revision-info t)))
-		      (length (document-property :_revs_info docinf))))))
+		      (length (document-property :|_revs_info| docinf))))))
 	    
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Delete a document by ID")
   delete-document-by-id
-  (ensure (document-property :ok (create-document '((:a "test")) :id "specified")))
-  (ensure (document-property :ok (delete-document :id "specified"))))
+  (ensure (document-property :|ok| (create-document '((:a "test")) :id "specified")))
+  (ensure (document-property :|ok| (delete-document :id "specified"))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Delete a document by ID and revision")
@@ -309,15 +309,15 @@
   (ensure (progn
 	    (create-document '((:a . "document")) :id "specified")
 	    (let ((doc (get-document "specified")))
-	      (document-property :ok (delete-document :id (document-property :_id doc)
-						      :revision (document-property :_rev doc)))))))
+	      (document-property :|ok| (delete-document :id (document-property :|_id| doc)
+						      :revision (document-property :|_rev| doc)))))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Delete a document by document")
   delete-document-by-document
   (ensure (progn
 	    (create-document '((:a . "document")) :id "polly")
-	    (document-property :ok 
+	    (document-property :|ok| 
 			       (delete-document :document (get-document "polly"))))))
 
 (addtest (clouchdb-doc-api-tests)
@@ -335,8 +335,8 @@
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Test get-document for existing document.")
   get-document-test
-  (ensure (document-property :ok (create-document '((:a . "test")) :id "test")))
-  (ensure-same (document-property :_id (get-document "test")) "test"))
+  (ensure (document-property :|ok| (create-document '((:a . "test")) :id "test")))
+  (ensure-same (document-property :|_id| (get-document "test")) "test"))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Update a document property")
@@ -353,7 +353,7 @@
   add-document-property-test1
   (ensure (create-test-documents *people* :id-field :name))
   (ensure 
-   (document-property :ok (put-document (cons '(:handsome . "false")
+   (document-property :|ok| (put-document (cons '(:handsome . "false")
 					      (get-document "peter"))))))
 
 (addtest (clouchdb-doc-api-tests)
@@ -361,25 +361,25 @@
   bulk-update-1
   (ensure (create-test-documents *people* :id-field :name))
   (ensure (let ((docs))
-            (dolist (di (document-property :rows (get-all-documents)))
+            (dolist (di (document-property :|rows| (get-all-documents)))
               (push (cons '(:new-field . "New Value") 
-                          (get-document (document-property :id di)))
+                          (get-document (document-property :|id| di)))
                     docs))
             (bulk-document-update docs)
 	    (block test
-	      (loop for di in (document-property :rows (get-all-documents)) do
+	      (loop for di in (document-property :|rows| (get-all-documents)) do
 		   (if (not (equal "New Value" 
 				   (document-property :new-field
 						      (get-document 
-						       (document-property :id di)))))
+						       (document-property :|id| di)))))
 		       (return-from test nil)))
 	      t))))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Test document ID encoding")
   encode-document-id
-  (ensure (document-property :ok (create-document '((:a "test")) :id "http://google.com")))
-  (ensure-same (document-property :_id (get-document "http://google.com")) "http://google.com"))
+  (ensure (document-property :|ok| (create-document '((:a "test")) :id "http://google.com")))
+  (ensure-same (document-property :|_id| (get-document "http://google.com")) "http://google.com"))
 
 (addtest (clouchdb-doc-api-tests)
   (:documentation "Test encoding and decoding of utf-8 document IDs")
@@ -388,8 +388,8 @@
    (let ((ids '("Ångström Café" "σπασμένα" "我能吞下玻璃而不伤身体")))
      (reduce #'(lambda (a b) (and a b))
              (mapcar #'(lambda (id)
-                         (and (document-property :ok (create-document nil :id id))
-                              (equal id (document-property :_id (get-document id)))))
+                         (and (document-property :|ok| (create-document nil :id id))
+                              (equal id (document-property :|_id| (get-document id)))))
                      ids)))))
 
 (addtest (clouchdb-doc-api-tests)
@@ -424,7 +424,7 @@
                          (:korean . "나는 유리를 먹을 수 있어요. 그래도 아프지 않아요")
                          (:euro-symbol . "€")
                          (:georgian . "მინას ვჭამ და არა მტკივა."))))
-     (and (document-property :ok (create-document glass-eaters :id "glass-eaters"))
+     (and (document-property :|ok| (create-document glass-eaters :id "glass-eaters"))
           (let ((doc (get-document "glass-eaters")))
             (reduce #'(lambda (a b) (and a b))
                     (mapcar #'(lambda (e) 
@@ -443,17 +443,18 @@
   ad-hoc-view-result
   (ensure-same (length (contains-property *people* :name :pval "marc"))
 	       (document-property
-		:total_rows
+		:|total_rows|
 		(ad-hoc-view 
 		 (ps (lambda (doc) 
-		       (if (= doc.name "marc")
-			   (map null doc.name))))))))
+                       (with-slots (*NAME*) doc
+                         (if (= *NAME* "marc")
+			   (map null *NAME*)))))))))
 
 (addtest (clouchdb-view-tests)
   (:documentation "Create an ad-hock view that should return no results")
   ad-hoc-view-no-result
   (ensure-same 0 (document-property
-		  :total_rows
+		  :|total_rows|
 		  (ad-hoc-view 
 		   (ps (lambda (doc) 
 			 (if (= doc.name "marie")
@@ -463,12 +464,12 @@
   (:documentation "Ensure a view can be created")
   create-view-test1
   (ensure 
-   (document-property :ok 
+   (document-property :|ok|
 		      (create-view "friend"
 				   (cons "marie-view"
 					 (ps (lambda (doc)
-					       (with-slots (friends) doc
-						 (dolist (friend friends)
+					       (with-slots (*friends*) doc
+						 (dolist (friend *friends*)
 						   (if (= friend "marie")
 						       (map null doc)))))))))))
 
@@ -477,7 +478,7 @@
   create-view-test2
   (ensure 
    (document-property
-    :ok 
+    :|ok|
     (create-view "friend"
 		 (cons "marie-view"
 		       (ps (lambda (doc)
@@ -485,29 +486,29 @@
 			       (dolist (friend friends)
 				 (if (= friend "marie")
 				     (map null doc))))))))))
-  (ensure (document-property :ok (delete-view "friend"))))
+  (ensure (document-property :|ok| (delete-view "friend"))))
 			     
 (addtest (clouchdb-view-tests)
   (:documentation "Creating a view that already exists should report an error")
   create-view-test3
   (ensure 
    (document-property
-    :ok 
+    :|ok|
     (create-view "friend"
 		 (cons "marie-view"
 		       (ps (lambda (doc)
-			     (with-slots (friends) doc
-			       (dolist (friend friends)
+			     (with-slots (*friends*) doc
+			       (dolist (friend *friends*)
 				 (if (= friend "marie")
 				     (map null doc))))))))))
   (ensure-same "conflict"
 	       (document-property
-		:error
+		:|error|
 		(create-view "friend"
 			     (cons "marie-view"
 				   (ps (lambda (doc)
-					 (with-slots (friends) doc
-					   (dolist (friend friends)
+					 (with-slots (*friends*) doc
+					   (dolist (friend *friends*)
 					     (if (= friend "marie")
 						 (map null doc)))))))))))
 
@@ -515,30 +516,30 @@
   (:documentation "Create a view and see if it can be queried")
   create-view-query-test1
   (ensure 
-   (document-property :ok 
+   (document-property :|ok|
 		      (create-view "friend"
 				   (cons "marie-view"
 					 (ps (lambda (doc)
-					       (with-slots (friends) doc
-						 (dolist (friend friends)
+					       (with-slots (*friends*) doc
+						 (dolist (friend *friends*)
 						   (if (= friend "marie")
 						       (map null doc))))))))))
-  (ensure-same (document-property :total_rows (invoke-view "friend" "marie-view"))
+  (ensure-same (document-property :|total_rows| (invoke-view "friend" "marie-view"))
  	       (length (contains-property *people* :friends :pval "marie"))))
 
 (addtest (clouchdb-view-tests)
   (:documentation "Create a view and see if it can be queried with a key")
   create-view-keyquery-test1
   (ensure 
-   (document-property :ok 
+   (document-property :|ok|
 		      (create-view "friend"
 				   (cons "fname"
 					 (ps (lambda (doc)
-					       (with-slots (friends) doc
-						 (dolist (friend friends)
+					       (with-slots (*friends*) doc
+						 (dolist (friend *friends*)
 						   (map friend doc)))))))))
   (ensure-same (length (document-property 
-			:rows (invoke-view "friend" "fname" :key "claire")))
+			:|rows| (invoke-view "friend" "fname" :key "claire")))
  	       (length (contains-property *people* :friends :pval "claire"))))
 
 ;;
--- /project/clouchdb/cvsroot/clouchdb/src/package.lisp	2007/12/21 19:58:32	1.3
+++ /project/clouchdb/cvsroot/clouchdb/src/package.lisp	2007/12/28 16:25:51	1.4
@@ -25,7 +25,7 @@
 (cl:in-package :cl-user)
 
 (defpackage :clouchdb
-  (:use :cl :drakma :json :flexi-streams)
+  (:use :cl :drakma :flexi-streams)
   (:export :*scheme*
 	   :*host*
 	   :*port*
--- /project/clouchdb/cvsroot/clouchdb/src/examples.lisp	2007/12/21 19:58:32	1.5
+++ /project/clouchdb/cvsroot/clouchdb/src/examples.lisp	2007/12/28 16:25:51	1.6
@@ -82,28 +82,28 @@
     ;; A simple example document using an auto-generated ID supplied
     ;; by CouchDb:
     (create-document '(;; Field with associated scalar value:
-		       (:name . "wine") 
+		       (:|name| . "wine") 
 		       ;; Field with array value:
-		       (:tags . ("beverage" "fun" "alcoholic"))))
+		       (:|tags| . ("beverage" "fun" "alcoholic"))))
     ;; A document with somewhat different structure, and that uses a
     ;; specified ID (does not use auto-generated ID):
-    (create-document '((:first-name . "Claude")
-		       (:last-name . "Debussy")
-		       (:tags . ("composer" "french" "impressionist" "european")))
+    (create-document '((:|first-name| . "Claude")
+		       (:|last-name| . "Debussy")
+		       (:|tags| . ("composer" "french" "impressionist" "european")))
 		     ;; Specify an ID for this document:
 		     :id "cdebussy")
     ;; Strings may be used for field names instead of symbols when
     ;; submitting documents. Fetched documents will always have
     ;; symbols for field names regardless of how they were created.
-    (create-document '((:name . "Czech Republic")
-		       (:tags . ("country" "european"))
-		       (:motto . "Truth prevails")
-		       (:demographics . ((:population . 10230000)
+    (create-document '((:|name| . "Czech Republic")
+		       (:|tags| . ("country" "european"))
+		       (:|motto| . "Truth prevails")
+		       (:|demographics| . ((:|population| . 10230000)
                                          ;; A nested map property:
-                                         (:religion . ((:agnostic . 0.59)
-                                                       (:roman-catholic . 0.26)
-                                                       (:protestant . 2.5)))
-                                         (:political-system . "democracy"))))
+                                         (:|religion| . ((:|Agnostic| . 0.59)
+                                                         (:|Roman Catholic| . 0.26)
+                                                         (:|Protestant| . 2.5)))
+                                         (:|Political System| . "democracy"))))
 		     :id "czechrepublic")
     ;; Create a persistant view that retrieves documents by their
     ;; tags. Views can also be queried with a browser at:
@@ -122,8 +122,8 @@
 		     (map tag doc)))))))
     ;; Query the view defined above and print the results
     (let ((result (invoke-view "tags" "tag" :key "european")))
-      (format t "found: ~S documents:~%" (length (document-property :rows result)))
-      (dolist (doc (document-property :rows result))
+      (format t "found: ~S documents:~%" (length (document-property :|rows| result)))
+      (dolist (doc (document-property :|rows| result))
 	(format t "---~%ID: ~S~%document:~%~S~%" 
 		(document-property :id doc) doc)))))
 
--- /project/clouchdb/cvsroot/clouchdb/src/encoder.lisp	2007/12/21 20:04:34	1.4
+++ /project/clouchdb/cvsroot/clouchdb/src/encoder.lisp	2007/12/28 16:25:51	1.5
@@ -66,15 +66,12 @@
       (format stream "~d" nr)
       (format stream "~f" nr)))
 
-(defmethod write-json-symbol(symbol stream)
+(defun write-json-symbol(symbol stream)
   (cond
     ((null symbol) (write-json-chars "null" stream))
     ((eq 't symbol) (write-json-chars "true" stream))
     (t (write-json-string (as-field-name-string symbol) stream))))
 
-;;    (t (write-json-string (symbol-to-js symbol) stream))))
-;;    (t (write-json-string (funcall *symbol-to-string-fn* symbol) stream))))
-
 (defun keyword-assocp (e)
   "Return true if element is a list that begins with a keyword. This
   is used to help determine associative list-ness."
--- /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp	2007/12/28 12:43:15	1.14
+++ /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp	2007/12/28 16:25:51	1.15
@@ -210,9 +210,9 @@
 between an error due to a missing document and a missing database."
   (let ((result (gensym)))
     `(let ((,result (progn , at body)))
-       (when (equal "not_found" (document-property :error ,result))
+       (when (equal "not_found" (document-property :|error| ,result))
 	 (let ((dbn (if ,db-name-p ,db-name *db-name*)))
-	   (if (document-property :error  (get-db-info :db-name dbn))
+	   (if (document-property :|error|  (get-db-info :db-name dbn))
 	       (error 'db-does-not-exist
 		      :result ,result :db-name dbn
 		      :uri (make-uri dbn)))))
@@ -243,40 +243,11 @@
 	   new-doc))
 	(t doc)))
 
-(defun camel-case-to-lisp (string)
-  "Converts a string in camelCase to the same lisp-friendly syntax used in parenscript.
-Stolen from the cl-json library since it's not exported from
-there. Examples: \"camelCase\" -> \"CAMEL-CASE\", \"CamelCase\" ->
-\"*CAMEL-CASE\", \"dojo.widget.TreeNode\" ->
-\"DOJO.WIDGET.*TREE-NODE\""
-  (with-output-to-string (out)
-    (loop for ch across string
-       do
-         (when (upper-case-p ch)
-           (write-char #\- out))
-         (write-char (char-upcase ch) out))))
-
-(defun lisp-to-camel-case (string)
-  "Reverses the output of camel-case-to-lisp"
-  (with-output-to-string (out)
-    (loop for ch across string
-       with last-char do
-         (cond ((char= #\- ch)
-                (if (and last-char (char= #\- last-char))
-                    (write-char #\- out)))
-               (t (write-char (if (and last-char (char= #\- last-char))
-                                  (char-upcase ch)
-                                  (char-downcase ch))
-                              out)))
-         (setf last-char ch))))
-
 (defun as-keyword-symbol (value)
   "Return value in a form that would be used to identify the car of a
-value in a document. For example, a value of \"FIELD-NAME\" would
-return :FIELD-NAME, 'FIELD-NAME would become :FIELD-NAME, and
-\"Field-Name\" would become \":*FIELD-NAME\"."
+value in a document. For example, a value"
   (cond ((stringp value)
-         (intern (camel-case-to-lisp value) "KEYWORD"))
+         (intern value "KEYWORD"))
         ((keywordp value)
          value)
         ((symbolp value)
@@ -286,7 +257,7 @@
 (defun as-field-name-string (value)
   "Convert a case-encoded symbol to a potentially mixed case string."
   (cond ((symbolp value)
-         (lisp-to-camel-case (symbol-name value)))
+         (symbol-name value))
         (t value)))
 
 (defun document-property (name doc)
@@ -316,7 +287,7 @@
 ;;      (format t "  -> headers: ~S~%" headers)
       (cond (must-close
 ;;             (format t "body: ~S~%" body)
-             (json:decode-json-from-string body))
+             (decode-json-from-string body))
             (t nil)))))
 
 ;;
@@ -371,9 +342,9 @@
   (let* ((name (if db-name-p db-name *db-name*))
 	 (res (db-request (cat (url-encode name) "/") 
                           :method :put)))
-    (if (equal "database_already_exists" (document-property :error res))
+    (if (equal "database_already_exists" (document-property :|error| res))
       (ecase if-exists
-	((:ignore) (list (cons :ok t) (cons :ignored t)))
+	((:ignore) (list (cons :|ok| t) (cons :|ignored| t)))
 	((:recreate) 
 	 (delete-db :db-name name) 
 	 (create-db :db-name name))
@@ -392,7 +363,7 @@
 if-missing parameter."
   (let* ((name (if db-name-p db-name *db-name*))
 	 (res (db-request (cat (url-encode name) "/") :method :delete)))
-    (if (and (document-property :error res) (not (eq :ignore if-missing)))
+    (if (and (document-property :|error| res) (not (eq :ignore if-missing)))
 	(restart-case 
 	    (error 'db-does-not-exist
 		   :result res :db-name name
@@ -418,9 +389,9 @@
   "Create a temporary database."
   (let ((db-name (funcall db-name-creator)))
     (let ((res (create-db :db-name db-name)))
-      (if (document-property :error res)
+      (if (document-property :|error| res)
 	  (error (format t "Error ~S creating database: ~A"
-		       (document-property :error res) db-name))))
+		       (document-property :|error| res) db-name))))
     db-name))
 
 (defmacro with-temp-db (&body body)
@@ -471,7 +442,7 @@
                                               (url-encode id))
 					 :method :get 
 					 :parameters parameters))))
-      (if (document-property :error res)
+      (if (document-property :|error| res)
           (progn
             (cond ((eq if-missing :ignore)
                    nil)
@@ -488,7 +459,7 @@
 differs from the existing :_id value, then a new document is created
 with the new ID and the non-special properties of the specified
 document, since the latter would generate a CouchDb error."
-  (let ((current-id (document-property :_id doc)))
+  (let ((current-id (document-property :|_id| doc)))
     (cond ((not (or current-id id))
 	   (error 'id-missing))
 	  ;; If an ID was specified and that ID does not match the
@@ -507,11 +478,11 @@
                              :content-length nil
                              :content (document-to-json doc)
 			     :method :put))))
-      (when (document-property :error res)
-	(error (if (equal "conflict" (document-property :error res)) 
+      (when (document-property :|error| res)
+	(error (if (equal "conflict" (document-property :|error| res)) 
 		   'id-or-revision-conflict 'doc-error)
 	       :id (if id id current-id)
-	       :reason (document-property :reason res)))
+	       :reason (document-property :|reason| res)))
       res)))
 		      
 (defun post-document (doc)
@@ -524,8 +495,8 @@
                            :content-length nil
                            :content (document-to-json doc)
                            :method :post))))
-    (when (document-property :error res)
-      (error 'doc-error) :id nil :reason (document-property :reason res))
+    (when (document-property :|error| res)
+      (error 'doc-error) :id nil :reason (document-property :|reason| res))
     res))
 
 (defun create-document (doc &key id)
@@ -561,8 +532,8 @@
                               (url-encode (value-as-string rev)))
 			 :method :delete)))
     (cond ((not (null document))
-	   (delete-document :id (document-property :_id document)
-			    :revision (document-property :_rev document)
+	   (delete-document :id (document-property :|_id| document)
+			    :revision (document-property :|_rev| document)
                             :if-missing if-missing))
 	  ((not id)
 	   (error 'id-missing))
@@ -571,7 +542,7 @@
                                                        :ignore
                                                        :error))))
              (when doc
-               (del id (document-property :_rev doc)))))
+               (del id (document-property :|_rev| doc)))))
 	  (t (del id revision)))))
 ;;
 ;; Views API
--- /project/clouchdb/cvsroot/clouchdb/src/clouchdb.asd	2007/12/20 23:57:09	1.3
+++ /project/clouchdb/cvsroot/clouchdb/src/clouchdb.asd	2007/12/28 16:25:51	1.4
@@ -38,9 +38,10 @@
   :serial t
   :version #.*clouchdb-version*
   :depends-on (:drakma
-               :cl-json
+               :parenscript
                :flexi-streams)
   :components ((:file "package")
                (:file "clouchdb")
+               (:file "decoder")
                (:file "encoder")))
 




More information about the clouchdb-cvs mailing list