[cells-devel] Where do you keep the models?

Ken Tilton kennytilton at optonline.net
Sun Aug 19 15:00:14 UTC 2007


Andy Chambers wrote:
> Where should you keep the data in a celtk app.  I tried doing the following...
> 
> (defmodel app (window)
>   ((my-model :initform nil :initarg :model :accessor my-model))
>   (:default-initargs
>       :kids (c? (the-kids
> 		 (mk-row (:packing (c?pack-self))
>                    (mk-popup-menubutton
>                     :id :view-selector
> 		    :initial-value (c? (first (^entry-values)))
> 		    :entry-values (c? '(codelists items item-groups forms events)))
>                    (mk-text-widget
> 		    :id :display
> 		    :value (c? (if *odm*
> 				   (case (selection (fm^ :view-selector))
> 				     (codelists
> 				      (codelists *odm*))
> 				     (items
> 				      (items *odm*))
> 				     (t (xml *odm*)))))))))))
> 
> 
> ...but I couldn't work out how to access my-model from the text
> widget's (c? ...).

As long as you are using my Family class you have a name/typespace to 
work with, meaning various utilities prefixed "fm-" which navigate 
parent/kids to find things by name or type.

In your case, (my-model (upper self app)) or more succinctly since self 
is so common, (my-model (u^ app)). Poke around fm-utilities for more such.

You can also search for things by name:

    (my-model (fm-other app))

If you do not want to use my Family class, just do something of your own 
which similarly effectively creates a namespace your own custom code is 
responsible for navigating.

cheers, ken



More information about the cells-devel mailing list