[bknr-cvs] hans changed trunk/bknr/datastore/src/data/object.lisp

BKNR Commits bknr at bknr.net
Tue Jul 15 13:14:17 UTC 2008


Revision: 3449
Author: hans
URL: http://bknr.net/trac/changeset/3449

Add automatically maintained LAST-CHANGE slot to STORE-OBJECT class.

U   trunk/bknr/datastore/src/data/object.lisp

Modified: trunk/bknr/datastore/src/data/object.lisp
===================================================================
--- trunk/bknr/datastore/src/data/object.lisp	2008-07-15 12:42:26 UTC (rev 3448)
+++ trunk/bknr/datastore/src/data/object.lisp	2008-07-15 13:14:17 UTC (rev 3449)
@@ -84,10 +84,13 @@
   (slot-value slot 'relaxed-object-reference))
 
 (defmethod (setf slot-value-using-class) :before (newval (class persistent-class) object slotd)
-  (when (and (persistent-slot-p slotd)
-	     (not (in-transaction-p)))
-    (error "Attempt to set persistent slot ~A of ~A outside of a transaction"
-	   (slot-definition-name slotd) object)))
+  (let ((slot-name (slot-definition-name slotd)))
+    (when (and (persistent-slot-p slotd)
+               (not (in-transaction-p)))
+      (error "Attempt to set persistent slot ~A of ~A outside of a transaction"
+             slot-name object))
+    (unless (eq 'last-change slot-name)
+      (setf (slot-value object 'last-change) (transaction-timestamp *current-transaction*)))))
 
 (defmethod (setf slot-value-using-class) :after (newval (class persistent-class) object slotd)
   (when (in-anonymous-transaction-p)
@@ -132,7 +135,9 @@
        :index-type unique-index
        :index-initargs (:test #'eql)
        :index-reader store-object-with-id :index-values all-store-objects
-       :index-mapvalues map-store-objects))
+       :index-mapvalues map-store-objects)
+   (last-change :initform (get-universal-time)
+                :initarg :last-change))
   (:metaclass persistent-class)
   (:class-indices (all-class :index-type class-skip-index
 			     :index-subclasses t




More information about the Bknr-cvs mailing list