So, I've been using cl-prevalence, and like it,
mostly. :) I have 3 systems active in my application
(with at least 2 more expected before it will be
completely converted).
Two of them restore correctly. One reliably does
not, and while the fact that two work okay suggests
that the problem is in my code, I can't find one.
When I change prevailed objects, they seem to update
in the log. However, deeply nested objects seem not
to be restored correctly.
The classes involved are:
(defclass page (object-with-id)
((name :initarg :name :initform "" :accessor name)
(title :initarg :title :initform () :accessor title))
(:documentation ""))
(defclass xhtml-page (page)
((xhtml :initarg :xhtml :initform () :accessor xhtml)))
(defclass classroom (object-with-id)
((cover :initarg :cover :initform "" :accessor cover)
(toc :initarg :toc :initform () :accessor toc)
(pages :initarg :pages :initform (make-hash-table :test 'equal)
:accessor pages))
(:documentation ""))
(defclass course (accessible)
((name :initarg :name :initform "" :accessor name) ; used
as a human-readable id
(title :initarg :title :initform "" :accessor title) ; shown
to users as the title of the course
(classroom :initarg :classroom :initform () :accessor classroom)
(menu :initarg :menu :initform () :accessor menu))
(:documentation ""))
The "accessible" class just has some permissions control, which
works okay; I'm sure it's not essential to this problem.
When I create a course, giving it a classroom, with a single
xhtml-page in the pages hash, this is the XML output:
<OBJECT ID="1" CLASS="CL-PREVALENCE::TRANSACTION"><SLOT
NAME="CL-PREVALENCE::ARGS"><NULL/></SLOT><SLOT
NAME="CL:FUNCTION"><SYMBOL>CL-PREVALENCE::TX-CREATE-ID-COUNTER</
SYMBOL></SLOT></OBJECT>
<OBJECT ID="1" CLASS="CL-PREVALENCE::TRANSACTION"><SLOT
NAME="CL-PREVALENCE::ARGS"><SEQUENCE ID="2" CLASS="CL:LIST"
SIZE="3"><SYMBOL>COM.RANDALLSQUARED.COOL::COURSE</SYMBOL><SYMBOL>CL-
PREVALENCE::NAME</SYMBOL><SYMBOL>CL:EQUALP</SYMBOL></SEQUENCE></
SLOT><SLOT
NAME="CL:FUNCTION"><SYMBOL>CL-PREVALENCE::TX-CREATE-OBJECTS-S
LOT-INDEX</SYMBOL></SLOT></OBJECT>
<OBJECT ID="1" CLASS="CL-PREVALENCE::TRANSACTION"><SLOT
NAME="CL-PREVALENCE::ARGS"><SEQUENCE ID="2" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.COOL::XHTML-PAGE</SYMBOL><SEQUENCE
ID="3" CLASS="CL:LIST" SIZE="2"><SEQUENCE ID="4" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.COOL::TITLE</SYMBOL><SEQUENCE ID
="5" CLASS="CL:LIST"
SIZE="1"><STRING>default-page-title</STRING></SEQUENCE></
SEQUENCE><SEQUENCE ID="6" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.COOL::XHTML</SYMBOL><SEQUENCE
ID="7" CLASS="CL:LIST"
SIZE="1"><STRING>default-page-content</STRING></SEQUENCE></SEQUENCE></
SEQUENCE></SEQUENCE></SLOT><SLOT NAME="CL
:FUNCTION"><SYMBOL>CL-PREVALENCE::TX-CREATE-OBJECT</SYMBOL></SLOT></
OBJECT>
<OBJECT ID="1" CLASS="CL-PREVALENCE::TRANSACTION"><SLOT
NAME="CL-PREVALENCE::ARGS"><SEQUENCE ID="2" CLASS="CL:LIST"
SIZE="1"><SYMBOL>COM.RANDALLSQUARED.COOL::CLASSROOM</SYMBOL></
SEQUENCE></SLOT><SLOT
NAME="CL:FUNCTION"><SYMBOL>CL-PREVALENCE::TX-CREATE-OBJECT</SYMBOL></
SLOT></OBJECT>
<OBJECT ID="1" CLASS="CL-PREVALENCE::TRANSACTION"><SLOT
NAME="CL-PREVALENCE::ARGS"><SEQUENCE ID="2" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.COOL::COURSE</SYMBOL><SEQUENCE
ID="3" CLASS="CL:LIST" SIZE="3"><SEQUENCE ID="4" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.COOL::CLASSROOM</SYMBOL><OBJECT
ID="5" CLASS="COM.RANDALLSQUARED.COOL::CLASSROOM"><SLOT
NAME="CL-PREVALENCE::ID"><INT>2</INT></SLOT><SLOT
NAME="COM.RANDALLSQUARED.COOL::COVER"><STRING></STRING></SLOT><SLOT
NAME="COM.RANDALLSQUARED.COOL::TOC"><NULL/></SLOT><SLOT
NAME="COM.RANDALLSQUARED.COOL::PAGES"><HASH-TABLE ID="6"
TEST="CL:EQUAL"
SIZE="65"><ENTRY><KEY><STRING></STRING></KEY><VALUE><SEQUENCE ID="7"
CLASS="CL:LIST" SIZE="1"><OBJECT ID="8"
CLASS="COM.RANDALLSQUARED.COOL::XHTML-PAGE"><SLOT
NAME="CL-PREVALENCE::ID"><INT>1</INT></SLOT><SLOT
NAME="CL-PREVALENCE::NAME"><STRING></STRING></SLOT><SLOT
NAME="COM.RANDALLSQUARED.COOL::TITLE"><SEQUENCE ID="9" CLASS="CL:LIST"
SIZE="1"><STRING>default-page-title</STRING></SEQUENCE></SLOT><SLOT
NAME="COM.RANDALLSQUARED.COOL::XHTML"><SEQUENCE ID="10" CLASS="CL:LIST"
SIZE="1"><STRING>default-page-content</STRING></SEQUENCE></SLOT></
OBJECT></SEQUENCE></VALUE></ENTRY></HASH-TABLE></SLOT></OBJECT></
SEQUENCE><SEQUENCE ID="11" CLASS="CL:LIST"
SIZE="2"><SYMBOL>COM.RANDALLSQUARED.PSIUSER::HANDLES</SYMBOL><SEQUENCE
ID="12" CLASS="CL:LIST"
SIZE="2"><INT>78</INT><INT>75</INT></SEQUENCE></SEQUENCE><SEQUENCE
ID="13" CLASS="CL:LIST"
SIZE="2"><SYMBOL>CL-PREVALENCE::NAME</SYMBOL><STRING>course</STRING></
SEQUENCE></SEQUENCE></SEQUENCE></SLOT><SLOT
NAME="CL:FUNCTION"><SYMBOL>CL-
PREVALENCE::TX-CREATE-OBJECT</SYMBOL></SLOT></OBJECT>
So far, so good, I think. In case it's not clear from the
above (it isn't to me), the course has id 3, the classroom id
2, and the xhtml-page id 1, since the default contents get
created just before they're passed to tx-create-object in
managed-prevalence.lisp.
But upon restarting the system, while all the id integers are
correct, the xhtml-page isn't attached to the pages hash
anymore:
* (find-courses) ; a standin for (find-all-objects *system* 'course)
(#<COURSE {49115E15}>)
T
* (get-id (car (find-courses)))
3
* (get-id (classroom (car (find-courses))))
2
* (pages (classroom (car (find-courses))))
#<EQUAL hash table, 1 entry {491146FD}>
* (gethash "" (pages (classroom (car (find-courses)))))
NIL
NIL
* (find-object-with-id *system* 'xhtml-page 1)
#<XHTML-PAGE {49110995}>
T
So, the obvious question is, how come the hash doesn't
get it's xhtml-page back?
--
Randall Randall <randall(a)randallsquared.com>
"And no practical definition of freedom would be complete
without the freedom to take the consequences. Indeed, it
is the freedom upon which all the others are based."
- Terry Pratchett, _Going Postal_