[elephant-devel] Re: Deferred indexing
Leslie P. Polzer
leslie.polzer at gmx.net
Sat Aug 2 06:49:00 UTC 2008
> It would be nice to be able to say:
>
> (defpclass banana () (:index t))
>
> (setf banana (make-instance 'banana))
>
> ; do stuff with banana, then later optionally:
>
> (store-indexed-object banana)
>
> We could then do without proxy objects in Weblocks.
(defun make-deferred-instance (classname &rest initargs)
(with-transaction ()
(let ((obj (apply #'make-instance classname initargs)))
(remove-kv (slot-value obj 'elephant::%oid)
(find-class-index classname)))))
(defun activate-deferred-instance (obj)
(let ((oid (slot-value obj 'elephant::%oid))
(idx (find-class-index (class-of obj))))
(if (get-value oid idx)
(warn "Attempted to activate Object ~S which is already indexed!" obj)
(setf (get-value oid idx) obj))))
This seems to work nicely, even with secondary indices.
Haven't tested derived, though.
Leslie
More information about the elephant-devel
mailing list