[clouchdb-cvs] CVS clouchdb/src

peddy peddy at common-lisp.net
Mon Dec 17 23:22:23 UTC 2007


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

Modified Files:
	examples.lisp clouchdb.lisp changelog.txt 
Log Message:
Fixed utf-8 encoding


--- /project/clouchdb/cvsroot/clouchdb/src/examples.lisp	2007/12/14 23:22:58	1.3
+++ /project/clouchdb/cvsroot/clouchdb/src/examples.lisp	2007/12/17 23:22:23	1.4
@@ -55,9 +55,7 @@
     (create-db :if-exists :recreate)
     ;; Create a document with ID of "haussmann"
     (create-document '(;; Fields with scalar values:
-		       (:name . "Georges-Eugene Haussmann") 
-		       ;; Note: above should be "Georges-Eugène" but
-		       ;; there's a character handling bug somewhere
+		       (:name . "Georges-Eugène Haussmann") 
 		       (:aka . "Baron Haussmann")
 		       (:born . "1809-03-27")
 		       (:died . "1891-01-11"))
--- /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp	2007/12/17 13:58:32	1.5
+++ /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp	2007/12/17 23:22:23	1.6
@@ -38,8 +38,8 @@
 
 (defparameter *temp-db-counter* 0 "Used in the creation of temporary databases")
 
-;(defconstant +utf-8+ (make-external-format :utf-8 :eol-style :lf)
-;  "Default external format for document content.")
+(defconstant +utf-8+ (make-external-format :utf-8 :eol-style :lf)
+  "Default external format for document content.")
 
 ;;
 ;; URL Parameter helpers
@@ -212,6 +212,8 @@
 ;;          (cond ((equal "conflict" (document-property :error result))
 ;;                 (error 'id-or-revision-conflict 
                
+(defun test ()
+  (with-open-file 
 
 ;;
 ;;
@@ -445,9 +447,11 @@
     (let ((res (ensure-db ()
 		 (db-request (cat (url-encode *db-name*) "/" 
                                   (url-encode (if id id current-id)))
-                             :content-type "text/json"
-;;                             :external-format-out +utf-8+
-			     :method :put :content (document-to-json doc)))))
+                             :content-type "text/javascript"
+                             :external-format-out +utf-8+
+                             :content-length nil
+                             :content (document-to-json doc)
+			     :method :put))))
       (when (document-property :error res)
 	(error (if (equal "conflict" (document-property :error res)) 
 		   'id-or-revision-conflict 'doc-error)
@@ -460,22 +464,15 @@
 areturn value includes the new document ID, in the :ID property."
   (let ((res (ensure-db ()
                (db-request (cat (url-encode *db-name*) "/")
-                           :method :post
-                           :content (document-to-json doc)))))
+                           :content-type "text/javascript"
+                           :external-format-out +utf-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))
     res))
 
-;; (defun post-document (doc)
-;;   "Create a document and let the server assign an ID. A successful
-;; areturn value includes the new document ID, in the :ID property."
-;;   (ensure-db ()
-;;     (db-request (cat (url-encode *db-name*) "/")
-;; 		:method :post
-;;                 :content-type "text/plain;charset=utf-8"
-;;                 :external-format-out +utf-8+
-;; 		:content #p"/Users/peter/encodings.txt")))
-
 (defun create-document (doc &key id)
   "Create a new document, optionally specifying the new document
 ID."
@@ -490,7 +487,9 @@
   (ensure-db () 
     (db-request (cat (url-encode *db-name*) "/_bulk_docs")
 		:method :post
-		:content-type "text/javascript"
+                :content-type "application/xml"
+                :external-format-out +utf-8+
+                :content-length nil
 		:content 
                 (cat "[ " 
 		     (string-join (mapcar #'document-to-json docs)) 
@@ -503,7 +502,8 @@
 not the revision, the current document will be fetched and it's
 revision number will be used for the delete."
   (labels ((del (id rev)
-	     (db-request (cat (url-encode *db-name*) "/" (url-encode id) "?rev=" rev)
+	     (db-request (cat (url-encode *db-name*) "/" (url-encode id) "?rev=" 
+                              (url-encode (value-as-string rev)))
 			 :method :delete)))
     (cond ((not (null document))
 	   (delete-document :id (document-property :_id document)
@@ -523,7 +523,9 @@
   (ensure-db ()
     (db-request (cat (url-encode *db-name*) "/_temp_view")
 		:method :post
+                :external-format-out +utf-8+
 		:content-type "text/javascript"
+                :content-length nil
                 :parameters (transform-params options *view-options*)
 		:content view)))
 
@@ -540,6 +542,9 @@
     (ensure-db ()
       (db-request (cat (url-encode *db-name*) "/_design/" (url-encode id))
 		  :method :put
+                  :external-format-out +utf-8+
+                  :content-type "text/javascript"
+                  :content-length nil
 		  :content
 		  (cat "{\"language\" : \"text/javascript\"," 
 		       "\"views\" : {" (mk-view-js view-defs) "}}")))))
--- /project/clouchdb/cvsroot/clouchdb/src/changelog.txt	2007/12/17 13:58:32	1.3
+++ /project/clouchdb/cvsroot/clouchdb/src/changelog.txt	2007/12/17 23:22:23	1.4
@@ -1,4 +1,7 @@
 
+0.0.6:
+  - Finally fixed utf-8 encoding
+
 0.0.5:
   - Encode all URL parameters properly, this fixes issues reported by
   Daniel Farina having to do with the inability to use leagal




More information about the clouchdb-cvs mailing list