[rucksack-devel] SB-SYS:FD-STREAM for "file /tmp/rs-tute/objects" {B1CC241}> is closed

Helmut G. Enders helmut at cybernetic-systems.de
Tue Nov 4 09:36:05 UTC 2008


  Sorry, that I forgot to correct my mail,

I called with-rucksack within with-rucksack and the inner
with-rucksack closed the stream.

I have taken the find-contact-by-name function from the tutorial and
missed the with-rucksack in that function.

Helmut


;; --------------------------------Test Code ----------------------------------
(defpackage :rucksack-tutorial
  (:nicknames :rs-tute)
  (:use :cl :rucksack))
(in-package :rucksack-tutorial)
(defvar *rs-tute-directory* #p"/tmp/rs-tute/")

(with-rucksack (rs *rs-tute-directory* :if-exists :supersede)
   (with-transaction ()
     (defclass contact-details ()
        ((unique-id    :initarg :unique-id :accessor unique-id-of
              :index :number-index
                      :unique t
              :documentation "A unique number for each contact in our DB")
          (name       :initarg :name :accessor name-of
              :index :case-insensitive-string-index
                  :documentation "The full name of the contact")

         (list-of-friends
                      :initarg :friends :accessor friends
              :documentation "All the friends."))
       (:metaclass persistent-class)
       (:index t))
     ))


(defun make-my-friends ()
  (declare (optimize (debug 3)))
    (with-rucksack (rs *rs-tute-directory*)
     (with-transaction ()
       (loop with fs = nil
             for x from 1 upto 1000
             do  (setf fs (p-cons (make-instance 'contact-details
                                                  :unique-id x
                                                  :name (format nil "Friend~D" x)
                                                  :friends nil) fs))
             finally    (make-instance 'contact-details :name "Helmut" :friends fs)))))


(defun find-contact-by-name (name)
   (with-rucksack (rs *rs-tute-directory*)
     (with-transaction ()
       (rucksack-map-slot rs 'contact-details 'name
              (lambda (contact)
                (return-from find-contact-by-name contact))
              :equal name)))
   nil)

(defun list-my-friends ()
  (declare (optimize (debug 3)))
  (with-rucksack (rs *rs-tute-directory*)
     (with-transaction ()
        (loop with me =  (find-contact-by-name "Helmut")  <-----------------------------
              for f in (unwrap-persistent-list (friends me))
              do (print (name-of f))))))

(defun test ()
   (make-my-friends)
   (list-my-friends))






More information about the rucksack-devel mailing list