[rucksack-devel] Indexed classes

Brad Beveridge brad.beveridge at gmail.com
Wed Jan 16 05:35:53 UTC 2008


Hello list,
I am writing a unit test suit for Rucksack and have come across a use
case that makes no sense to me.
I have defined a class such:
(defclass foo ()
  ((data :initarg :data :accessor data
	 :index :case-insensitive-string-index))
  (:index t)
  (:metaclass persistent-class))

If I run the following code:

(with-rucksack-and-transaction
  (make-instance 'foo :data "foobar")
  )

(with-rucksack-and-transaction
  (rucksack-map-class *rucksack* 'foo
		      (lambda (obj)
			(format t "~A~%" obj)
			))
  )

I get nothing printed out!
If I wrap the DEFCLASS in a WITH-RUCKSACK-AND-TRANSACTION, then it
works.  I am guessing that at defclass time you must have a open
rucksack and valid transaction, and that some MOP magic will populate
a btree index.
This feels quite strange to me, for example it would be common for an
application to startup with no object store & expect to be able to
correctly instance indexed objects and have them persist.  Otherwise
you need to arrange to re-evaluate the defclass form whenever you
delete your store.
I would expect that when you MAKE-INSTANCE an indexed class Rucksack
should test to see if the index exists, and if it doesn't it should
create one.

I'm new to MOP & haven't looked into this yet.  Any hints on where I
should look to try & fix this.  Or am I misunderstanding a design
feature/goal as a bug?

Cheers,
Brad



More information about the rucksack-devel mailing list