mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-15 15:00:24 -08:00
retrieve data from objects
This commit is contained in:
parent
6d8c410e38
commit
7e6a21261b
2 changed files with 17 additions and 3 deletions
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
(defun data-load-plist (obj plist &key (upcase-key t))
|
||||
"Load a PLIST in to OBJ where key of plist is the name of slot on
|
||||
OBJ and the value is the data to load. If slot is a clog-element
|
||||
OBJ and the value is the data to load. If slot is a CLOG-ELEMENT
|
||||
TEXT-VALUE is set, if not the slot is set to the value. If key is not
|
||||
the name of a slot it is ignored. The key is coverted to a string and
|
||||
upper cased before attempting to match it to a slot if :UPCASE-KEY t
|
||||
|
|
@ -35,4 +35,17 @@ upper cased before attempting to match it to a slot if :UPCASE-KEY t
|
|||
(setf (text-value (slot-value obj slot-sym)) value)
|
||||
(setf (slot-value obj slot-sym) value))))))))
|
||||
|
||||
|
||||
(defun data-write-list (obj slot-name-list)
|
||||
"Returns a list, one member for each slot name in SLOT-NAME-LIST. If
|
||||
a slot contains a CLOG-ELEMENT then TEXT-VALUE is used to retrieve the
|
||||
value. Slot names may be symbols or text (and will be upcased before
|
||||
looking up symbol). All slot-names must be bound."
|
||||
(let ((result))
|
||||
(dolist (slot (reverse slot-name-list))
|
||||
(unless (symbolp slot)
|
||||
(setf slot (find-symbol (string-upcase slot))))
|
||||
(if (and (slot-boundp obj slot)
|
||||
(typep (slot-value obj slot) 'clog:clog-element))
|
||||
(push (text-value (slot-value obj slot)) result)
|
||||
(push (slot-value obj slot) result)))
|
||||
result))
|
||||
|
|
|
|||
|
|
@ -524,7 +524,8 @@ embedded in a native template application.)"
|
|||
|
||||
(defsection @clog-data (:title "CLOG Data")
|
||||
"CLOG-Data - CLOG Data Binding"
|
||||
(data-load-plist function))
|
||||
(data-load-plist function)
|
||||
(data-write-list function))
|
||||
|
||||
(defsection @clog-panels (:title "CLOG Panels")
|
||||
"CLOG-Panel - CLOG Panels"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue