Method: (INITIALIZE-INSTANCE AROUND PERSISTENT-OBJECT)

Source

(defmethod initialize-instance :around ((object persistent-object)
                                        &rest args
                                        &key rucksack
                                        ;; The DONT-INDEX argument is used
                                        ;; when creating the indexes themselves
                                        ;; (to prevent infinite recursion).
                                        (dont-index nil)
                                        &allow-other-keys)
  (maybe-update-slot-info (class-of object))
  ;; This happens when persistent-objects are created in memory, not when
  ;; they're loaded from the cache (loading uses ALLOCATE-INSTANCE instead).
  (let ((rucksack (or rucksack (rucksack object))))
    (unless (slot-boundp object 'object-id)
      (setf (slot-value object 'object-id)
	    (cache-create-object object (rucksack-cache rucksack))))
    ;; DO: Explain why we don't set the transaction-id slot here.
    (unless (slot-boundp object 'rucksack)
      (setf (slot-value object 'rucksack) rucksack))
    (unless dont-index
      (rucksack-maybe-index-new-object rucksack (class-of object) object)))
  ;;
  (let (;; Tell (SETF SLOT-VALUE-USING-CLASS), which may be called
        ;; by SHARED-INITIALIZE in some implementations, that we're
        ;; just initializing the instance and it shouldn't try to
        ;; update any indexes.
        (*initializing-instance* t))
    (let ((result (call-next-method)))
      ;; Update slot indexes for persistent slots that are bound now.
      (unless dont-index
        (let ((class (class-of object)))
          (dolist (slot (class-slots class))
            (let ((slot-name (slot-definition-name slot)))
              (when (and (slot-boundp object slot-name)
                         (slot-persistence slot))
                (rucksack-maybe-index-changed-slot (or rucksack (rucksack object))
                                                   class object slot
                                                   nil (slot-value object slot-name)
                                                   nil t))))))
      ;;
      result)))
Source Context