find-kahua-instance

(find-kahua-instance class slot-name slot-value)で使うときは、slot-nameが:indexでかつ:uniqueでないといけないらしい。

blog(3sq:59mvs)> (find-kahua-instance <article> 'title "test2")
*** ERROR: value for key :index is not provided: (:allocation :persistent :init-keyword :title :init-value "")
Stack Trace:
_______________________________________
  0  (kahua-error-string e #t)
        At line 285 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  1  (slot-definition-option slot :index)
        At line 1664 of "/home/troter/c/kahua/lib/kahua/kahua/persistence.scm"
  2  (index-slot-type class slot-name)
        At line 1670 of "/home/troter/c/kahua/lib/kahua/kahua/persistence.scm"
  3  (eval body env)
        At line 287 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  4  (with-error-to-port error-output (cut with-output-to-port std-outp ...
        At line 212 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  5  (kahua-default-handler header body reply-cont default-handler :err ...
        At line 116 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
  6  proc

  7  (with-error-handler (lambda (e) (let ((e e)) (%guard-rec e e (else ...
        [unknown location]
  8  (for-each (lambda (h) (apply (car h) (cdr h))) (append (pick-handl ...
        At line 130 of "/home/troter/local/share/gauche/0.8.9/lib/gauche/selector.scm"
  9  (selector-select selector)
        At line 165 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
 10  (do ((limit 100) (_ 0 (+ _ 1))) ((>= _ limit)) (selector-select se ...
        [unknown location]
 11  proc

 12  (run-server worker-id sockaddr profile)
        At line 245 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
 13  (call/cc (lambda (bye) (define (finish-server sig) (log-format "[~ ...
        At line 231 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"

blog(3sq:59mvs)> (find-kahua-instance <article> 'title "test2")
*** KAHUA-PERSISTENCE-ERROR: title is not a unique index slot
Stack Trace:
_______________________________________
  0  (kahua-error-string e #t)
        At line 285 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  1  (eval body env)
        At line 287 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  2  (with-error-to-port error-output (cut with-output-to-port std-outp ...
        At line 212 of "/home/troter/c/kahua/lib/kahua/kahua/server.scm"
  3  (kahua-default-handler header body reply-cont default-handler :err ...
        At line 116 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
  4  proc

  5  (with-error-handler (lambda (e) (let ((e e)) (%guard-rec e e (else ...
        [unknown location]
  6  (for-each (lambda (h) (apply (car h) (cdr h))) (append (pick-handl ...
        At line 130 of "/home/troter/local/share/gauche/0.8.9/lib/gauche/selector.scm"
  7  (selector-select selector)
        At line 165 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
  8  (do ((limit 100) (_ 0 (+ _ 1))) ((>= _ limit)) (selector-select se ...
        [unknown location]
  9  proc

 10  (run-server worker-id sockaddr profile)
        At line 245 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"
 11  (call/cc (lambda (bye) (define (finish-server sig) (log-format "[~ ...
        At line 231 of "/home/troter/c/kahua/lib/kahua/kahua-server.scm"

make-kahua-collectionで:indexを使うときはslot-nameは:indexである必要があるけど、:uniqueを指定しなくてもよい。