:clouchdb ID 错误

发布于 12-06 09:41 字数 1124 浏览 0 评论 0原文

我在 :clouchdb 示例代码(这是一个链接,但其中包含的 examples.lisp 文件也无法正常工作)。

具体来说,当我输入时,

> (create-document '((:|name| . "wine") (:|tags| . ("beverage" "fun" "alcoholic"))))

我得到一个 DOC-ERROR 条件

Reason "Content-Type must be application/json", Document ID: "NIL"
   [Condition of type DOC-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {10040D2E11}>)

Backtrace:
  0: (POST-DOCUMENT ((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic")))
  1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CREATE-DOCUMENT '((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic"))) #<NULL-LEXENV>)
 --more--

该示例的预期效果是让 CouchDB 为新文档分配一个 ID(这在链接页面和注释中都已明确说明)的代码文件)。

我正在运行来自 Debian 存储库的 SBCL 1.0.40.0、clouchdb_0.0.11(直接来自 Quicklisp)和 CouchDB 0.11,以防万一。我也在 64 位 Debian 机器上。

有人能指出我正确的方向吗?

I'm getting an error on one part of the :clouchdb example code (that's a link, but the examples.lisp file included doesn't work properly either).

Specifically, when I input

> (create-document '((:|name| . "wine") (:|tags| . ("beverage" "fun" "alcoholic"))))

I get a DOC-ERROR condition

Reason "Content-Type must be application/json", Document ID: "NIL"
   [Condition of type DOC-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {10040D2E11}>)

Backtrace:
  0: (POST-DOCUMENT ((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic")))
  1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CREATE-DOCUMENT '((:|name| . "wine") (:|tags| "beverage" "fun" "alcoholic"))) #<NULL-LEXENV>)
 --more--

The intended effect of the example is to have CouchDB assign an ID to the new document (this is made clear both in the linked page and in the comments of the code file).

I'm running SBCL 1.0.40.0, clouchdb_0.0.11 (straight out of quicklisp) and CouchDB 0.11 from the Debian repos, in case it matters. I'm also on a 64-bit Debian box.

Can anyone point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

CouchDB 在 POST 文档时需要“Content-Type: application/json”,这是一个相当新的要求,所以我认为 clouchdb 还没有这样做。

较短版本:听起来 clouchdb 与 CouchDB 的最新版本不兼容。

CouchDB requires a "Content-Type: application/json" when POST'ing documents, this is a fairly new requirement so I think clouchdb simply isn't doing it yet.

Shorter version: Sounds like clouchdb is not compatible with recent releases of CouchDB.

街角迷惘2024-12-13 09:41:30

刚刚检查了来源。罗伯特·纽森(Robert Newson)上述是正确的; clouchdb 仍在将 content-type 设置为“text/javascript”,同时posting 和 putting 文档(无论如何,后者似乎都可以工作,只有帖子错误)。

如果您不想按照我上面的建议使用 chillax,您可以进入 clouchdb.lisp 文件并更改 post-document 的定义,使其设置 :content-type< /code> 到“application/json”。

然后,您应该能够在没有 :id 设置的情况下create-document,CouchDB 将通过为您生成一个新文档来响应。

基于 clouchdbquicklisp 代码的补丁(并不是说这复杂到需要一个):

--- clouchdb.lispOLD    2011-09-24 09:38:20.000000000 -0400
+++ clouchdb.lisp    2011-09-24 09:38:58.000000000 -0400
@@ -753,7 +753,7 @@
 the :ID property."
   (let ((res (ensure-db ()
                (db-request (cat (url-encode (db-name *couchdb*)) "/")
-                           :content-type "text/javascript"
+                           :content-type "application/json"
                            :external-format-out +utf-8+
                            :content-length nil
                            :method :post

Just checked the source. Robert Newson above is correct; clouchdb is still setting the content-type to "text/javascript" while posting and putting documents (the latter seems to work anyway, only the post errors).

If you don't feel like using chillax as I suggest above, you can go into the clouchdb.lisp file and change the definition of post-document such that it sets :content-type to "application/json".

You should then be able to create-document without an :id set, and CouchDB will respond by generating a new one for you.

Patch based on the quicklisp code for clouchdb (not that this is complicated enough to need one):

--- clouchdb.lispOLD    2011-09-24 09:38:20.000000000 -0400
+++ clouchdb.lisp    2011-09-24 09:38:58.000000000 -0400
@@ -753,7 +753,7 @@
 the :ID property."
   (let ((res (ensure-db ()
                (db-request (cat (url-encode (db-name *couchdb*)) "/")
-                           :content-type "text/javascript"
+                           :content-type "application/json"
                            :external-format-out +utf-8+
                            :content-length nil
                            :method :post
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文