From 9763450a51441b4f9919ae7e6b19dd9950988e5c Mon Sep 17 00:00:00 2001 From: Maciej Pasternacki Date: Wed, 22 Oct 2008 00:33:04 +0200 Subject: [PATCH] - DAO dirtiness protocol --- src/common.lisp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common.lisp b/src/common.lisp index 86da969..c4b0c1c 100644 --- a/src/common.lisp +++ b/src/common.lisp @@ -8,6 +8,7 @@ (defpackage #:trane-common (:use #:common-lisp) ; referenced with package name: #:py-configparser (:export #:id #:slug #:slug-dao #:slugify + #:dirtyness-mixin #:dirty-p #:mark-as-dirty #:update-dao-if-dirty #:*config* #:*init-functions* #:on-init #:*setup-functions* #:on-setup #:*db* #:make-keyword #:named-lambda #:random-string)) @@ -55,6 +56,17 @@ Usually it will be a reader method automatically defined for ID column of a DAO. (collect #\- result-type string)) (collect c result-type string)))) +(defclass dirtyness-mixin () + ((dirty-p :initform nil :accessor dirty-p))) + +(defun mark-as-dirty (dao) + (setf (dirty-p dao) t)) + +(defun update-dao-if-dirty (dao) + (when (dirty-p dao) + (update-dao dao) + (setf (dirty-p dao) nil))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Initialization and setup protocol -- 2.11.4.GIT