[rucksack-devel] (not) Understanding proxy

Dr. Helmut G. Enders helmut at cybernetic-systems.de
Mon Aug 25 08:12:10 UTC 2008


In my rucksack are persons (p1..p3), each has a slot with a list of friend.
I set the the friends of p1 to (list p1 p2 p3).
Now I want to put p1 onto the friends list of p2:
   (see ;<-------------- below)
and got the error message:

There is no applicable method for the generic function
   #<STANDARD-GENERIC-FUNCTION (SETF RUCKSACK-TUTORIAL::FRIENDS) (1)>
when called with arguments
   ((#<RUCKSACK-TUTORIAL::PERSON #27 with transaction id 342863958800000>)
    #<RUCKSACK::PROXY {B9D1E19}>).

The problem is propably in my (not) understanding what a Proxy is.
Are there some more docs than in the doc directory? :-)

Thanks,
Helmut

-------EXAMPLE----------------------------------------------

(with-rucksack (rs *rs-tute-directory* :if-exists :supersede)
   (with-transaction ()
     (defclass person ()
       ((unique-id    :initarg :unique-id :accessor unique-id-of
		     :index :number-index :unique t)
        (name         :initarg :name :accessor name
		     :index :case-insensitive-string-index)
        (friends      :initarg :friends :accessor friends
		     :documentation "List of Friends."))
       (:index t)
       (:metaclass persistent-class))))

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


(defun link-friends ()
  (declare (optimize (debug 3)))
  (with-rucksack (rs *rs-tute-directory*)
   (with-transaction ()
       (let* ((uid 0)
              (p1 (make-instance 'person :unique-id (incf uid) :name "p1" :friends nil))
              (p2 (make-instance 'person :unique-id (incf uid) :name "p2" :friends nil))
              (p3 (make-instance 'person :unique-id (incf uid) :name "p3" :friends nil))
              (fs (list p1 p2 p3))

         (setf (friends p1) fs))))

   (with-rucksack (rs *rs-tute-directory*)
     (with-transaction ()
       (let ((person (find-person-by-name "p1")))
          ;; Set p1 on the friends list of p2.
          (setf (friends (second (friends person))) (list person))))))  ;<-------------------

---------------------------------------------sbcl-------------------------------------------
CL-USER> (rs-tute::link-friends)

There is no applicable method for the generic function
   #<STANDARD-GENERIC-FUNCTION (SETF RUCKSACK-TUTORIAL::FRIENDS) (1)>
when called with arguments
   ((#<RUCKSACK-TUTORIAL::PERSON #27 with transaction id 342863958800000>)
    #<RUCKSACK::PROXY {B9D1E19}>).
    [Condition of type SIMPLE-ERROR]




More information about the rucksack-devel mailing list