[elephant-cvs] CVS elephant/src/elephant

ieslick ieslick at common-lisp.net
Sun Apr 22 03:35:10 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/elephant
In directory clnet:/tmp/cvs-serv15141/src/elephant

Modified Files:
	classes.lisp controller.lisp package.lisp serializer2.lisp 
Log Message:
Provide simple restarts for some potentially annoying error conditions.  Especially storing an instance of one store in another database

--- /project/elephant/cvsroot/elephant/src/elephant/classes.lisp	2007/04/21 17:22:50	1.28
+++ /project/elephant/cvsroot/elephant/src/elephant/classes.lisp	2007/04/22 03:35:09	1.29
@@ -260,16 +260,16 @@
   "Ensures that object can be written as a reference into store sc"
   (eq (dbcn-spc-pst object) (controller-spec sc)))
 
-(define-condition cross-store-reference ()
-  ((object :accessor cross-store-reference-object :initarg :object)
-   (home-controller :accessor cross-store-reference-home-controller :initarg :home-ctrl)
-   (foreign-controller :accessor cross-store-reference-foreign-controller :initarg :foreign-ctrl))
+(define-condition cross-reference-error ()
+  ((object :accessor cross-reference-error-object :initarg :object)
+   (home-controller :accessor cross-reference-error-home-controller :initarg :home-ctrl)
+   (foreign-controller :accessor cross-reference-error-foreign-controller :initarg :foreign-ctrl))
   (:documentation "An error condition raised when an object is being written into a data store other
                    than its home store"))
 
-(defun raise-cross-store-condition (object sc)
-  (cerror "Proceed and patch later"
-	  'cross-store-reference
+(defun signal-cross-reference-error (object sc)
+  (cerror "Proceed to write incorrect reference"
+	  'cross-reference-error
 	  :format-control "Attempted to write object ~A with home store ~A into store ~A"
 	  :format-arguments (list object (get-con object) sc)
 	  :object object
--- /project/elephant/cvsroot/elephant/src/elephant/controller.lisp	2007/04/21 17:22:50	1.47
+++ /project/elephant/cvsroot/elephant/src/elephant/controller.lisp	2007/04/22 03:35:09	1.48
@@ -32,8 +32,8 @@
     )
   "Tells the main elephant code the tag used in a store spec to
    refer to a given data store.  The second argument is an asdf
-   dependency list.  Entries have the form of (data store type
-   asdf-depends-list")
+   dependency list.  Entries have the form of 
+  (data-store-type-tag asdf-depends-list")
 
 (defvar *elephant-controller-init* (make-hash-table))
 
@@ -57,17 +57,29 @@
    we re-open the controller from the spec if it's not
    cached?  That might be dangerous so for now we error"))
 
+(define-condition controller-lost-error ()
+   ((object :initarg :object :accessor store-controller-closed-error-object)
+    (spec :initarg :spec :accessor store-controller-closed-error-spec)))
+
+(defun signal-controller-lost-error (object)
+  (cerror "Open a new instance and continue?"
+	  'controller-lost-error
+	  :format-string "Store controller for specification ~A for object ~A cannot be found."
+	  :format-arguments (list object (dbcn-spc-pst object))
+	  :object object
+	  :spec (dbcn-spc-pst object)))
+
 (defmethod get-con ((instance persistent) &optional (sc *store-controller*))
   (declare (ignore sc))
   (let ((con (gethash (dbcn-spc-pst instance) *dbconnection-spec*)))
     (cond ((not con)
-	   ;; ISE NOTE: Create a new one here & warn instead?
-	   ;; (get-controller spec)
-	   (error "Object's store controller was lost"))
+	   (progn (signal-controller-lost-error instance)
+		  (open-controller 
+		   (get-controller (dbcn-spc-pst instance)))))
 	  ;; If it's valid and open
 	  ((and con (connection-is-indeed-open con))
 	   con)
-	  ;; If the object exists but is closed, reopen
+	  ;; If the controller object exists but is closed, reopen
 	  (t (open-controller con)))
     con))
 
--- /project/elephant/cvsroot/elephant/src/elephant/package.lisp	2007/04/21 17:22:50	1.31
+++ /project/elephant/cvsroot/elephant/src/elephant/package.lisp	2007/04/22 03:35:09	1.32
@@ -266,7 +266,8 @@
    #:struct-constructor
 
    ;; Various error conditions
-   #:cross-store-reference
+   #:cross-reference-error
+   #:controller-lost-error
 
    #:map-class-query
    #:get-query-instances
--- /project/elephant/cvsroot/elephant/src/elephant/serializer2.lisp	2007/04/21 17:22:51	1.39
+++ /project/elephant/cvsroot/elephant/src/elephant/serializer2.lisp	2007/04/22 03:35:09	1.40
@@ -42,7 +42,7 @@
 		database-version
 		translate-and-intern-symbol
 		valid-persistent-reference-p
-		raise-cross-store-condition))
+		signal-cross-reference-error))
 
 (in-package :elephant-serializer2)
 




More information about the Elephant-cvs mailing list