-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.lisp
49 lines (40 loc) · 1.96 KB
/
component.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;;; CLEWS Base class for applications and plugins
;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]>
;;;; Released under the GNU General Public License (GPL)
;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details
;;;;
;;;; $Id: component.lisp,v 1.3 2007/07/08 11:20:33 willijar Exp $
(in-package :clews)
(defgeneric id(component)
(:documentation "Return a unique id for an object"))
(defclass component (access-controlled-entity)
((id :initarg :id :type symbol :reader id
:documentation "Unique id for this component - used as key for
application specific properties for users - should be unique across
all applications") )
(:default-initargs
:acl '((:view . (:all))
(:manage . (:manager))))
(:documentation
"Abstract Base Class for clews components - applications or plugins"))
(defmethod has-permission :around(action (component component) &optional user)
(or (call-next-method)
(unless (typep user 'user)
(let ((email-address (email-address user)))
(and email-address (has-permission action component email-address))))))
(defgeneric user-component-properties(component user &key defaults)
(:documentation "Return a property-subset in user properties for
given component creating it if necessary")
(:method(component user &key defaults)
(property-subset user (id component) :defaults defaults)))
(declaim (inline user-preference))
(defun user-preference(key component user &optional default)
"Return a user preference relating to component - checks user
properties, then component properties, otherwise returns default"
(property (property user (id component)) key default))
(defgeneric user-component-preferences(component user)
(:documentation "Method should return the user preferences list
(suitable for make-form) for the given component or nil if none available"))
(defmethod user-component-preferences((component component) user)
(declare (ignore user))
nil)