1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
11 \paperpackage widemarginsa4
15 \use_numerical_citations 0
16 \paperorientation portrait
19 \paragraph_separation indent
21 \quotes_language english
25 \paperpagestyle default
39 \begin_inset Quotes eld
43 \begin_inset Quotes erd
53 is a very useful module that works on top of the
57 framework to do rapid developing of complex data-driven web appilcations
72 was founded and developed and continues to be developed and mantained by
83 The conventions used in this manual are:
86 Lisp code is shown as a monospace font.
87 It is assumed that the user is working in an interactive environment and
88 what the user should type appears as bold, for example:
101 Names of people or products are show as small caps, like
116 require further revision.
121 ToDo: Add more conventions as they are needed, possible classes of text:
122 names of concepts, name of programming entities, like variables, functions,
123 etc (which are embedded in text, should they be shown monospaced ?).
131 Protocol A Protocol for introspection on relational objects.
135 Presentations A Mewa-like
141 http://www.adrian-lienhard.ch/files/mewa.pdf
144 layer for UncommonWeb
150 http://common-lisp.net/project/ucw/
159 First we start with the data model.
160 The Meta Model Protocol (MMP) is used to provide information on the data
161 objects and how they relate to one another.
162 Its is currently implemented as a layer over CLSQL
171 , although support is planned for other backends (
182 The MMP shares its definition syntax with
188 's Object Oriented Data Definition Language (OODDL)
194 http://clsql.b9.com/manual/ref-ooddl.html
200 Shouldn't this footnote be a bibliographical entry ? or something like that
208 The macro to define view-classes is named DEF-VIEW-CLASS/META, and takes
209 the same arguments as DEF-VIEW-CLASS from CLSQL.
210 For the purposes of this simple example, we will only need two functions
211 from the MMP beyond what CLSQL provides : LIST-SLOTS and LIST-SLOT-TYPES[5].
214 We'll define a simple class to hold a user.
219 (def-view-class/meta user ()
224 ((userid :initarg :userid :accessor userid :type integer :db-kind :key)
229 (username :initarg :username :accessor username :type string :db-kind
235 (password :initarg :password :accessor password :type string :db-kind
239 and now we create a user:
244 (defparameter user (make-instance 'user :userid 1
254 :password "p@ssw0rd"))
257 We can see the slots of users running:
262 (lisp-on-lines::list-slots user)
265 (USERID USERNAME PASSWORD)
273 (lisp-on-lines::list-slot-types user)
276 ((USERID INTEGER) (USERNAME STRING) (PASSWORD STRING))
284 (lisp-on-lines::default-attributes user)
287 ((USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
290 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
293 (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD))
301 (set-default-attributes user)
304 ((USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
307 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
310 (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD))
318 (lisp-on-lines::find-class-attributes user)
321 (USER (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
324 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
327 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
333 note that the mewa functions (find-attribute, set-attribute etc) can take
334 either an instance, or a class-name as a symbol:
339 (lisp-on-lines::find-class-attributes 'user)
342 (USER (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
345 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
348 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
356 (lisp-on-lines::find-class-attributes (make-instance 'user))
359 (USER (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
362 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
365 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
371 Using that information, we have enough to create an interface to the object.
376 includes a powerful presentation system
382 To see this system in action, we strongly recomend to study the presentations
383 example which comes with
388 Reading components/presentations.lisp can help understand a lot about how
389 presentations are built.
392 , but it is not dynamic enough for some of the most advanced applications.
393 Mewa defines an approach to presentations that solves that problem, but
394 the paper is written from a
399 A mixture of the two , Mewa Presentations(MP), is described here.
411 An attribute is essentially a named version of the DEFPRESENTATION slot-like
412 arguments, for example in :
417 (defpresentation person-editor (object-presentation)
422 ((string :label "First Name" :slot-name 'first-name :max-length 30)))
425 the (string :label "First Name" ...) form is an attribute definiton.
426 Attributes are accessed through FIND-ATTIRIBUTES, and are composed at run
431 's presentation system is done at compile time) to display the object.
432 This allows a very flexible system of displaying objects which is reminiscent
447 discovered this, rather than invent or design it, so there are some rough
448 edges, but its a good start.
454 Its much easier to show this than to tell.
455 Lets present our user class.
460 , you'd define a presentation as such :
465 (defpresentation user-presentation (object-presentation)
468 ((INTEGER :LABEL "USERID" :SLOT-NAME USERID)
471 (STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
474 (STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)))
477 which could be presented using PRESENT-OBJECT :
482 (present-object user :using 'user-presentation)
485 The equivalent approach using mewa presentations is actually longer and
486 more verbose(!) but it serves to demonstrate how the MP system works.
489 Mewa Presentations adds a set of attributes to a class, keyed off the class
491 Attributes are inherited, so if you define an attribute on T, you can use
495 MP stores named attributes keyed on a class name.
496 To achieve the same functionality as the above using mp would look like
502 (setf (lisp-on-lines::find-attribute 'user :viewer)
503 \begin_inset Marginal
508 Isn't this too imperative (in contrast to functional, lispy).
516 '(mewa-object-presentation :attributes (userid username password)
521 :global-properties (:editablep nil)))
524 (:VIEWER MEWA-OBJECT-PRESENTATION
530 (USERID USERNAME PASSWORD)
541 (setf (lisp-on-lines::find-attribute 'user 'userid)
542 \begin_inset Marginal
547 Are this setfs to 'userid, 'username and 'password needed ? I (Pupeno) inspected
548 they contents at of this moment and they seem to already contain what they
557 '(integer :label "userid" :slot-name userid))
560 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
565 (setf (find-attribute 'user 'username)
570 '(STRING :LABEL "USERNAME" :SLOT-NAME USERNAME))
573 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
578 (setf (find-attribute 'user 'password)
583 '(STRING :LABEL "USERNAME" :SLOT-NAME PASSWORD))
586 (PASSWORD STRING :LABEL "USERNAME" :SLOT-NAME PASSWORD)
591 (find-class-attributes 'user)
597 (:VIEWER MEWA-OBJECT-PRESENTATION
603 (USERID USERNAME PASSWORD)
612 (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
615 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
618 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
624 this is all turned into a UCW presentation at runtime using MAKE-PRESENTATION
628 (defmethod render-on ((res response) (e presentations-index))
634 As you'll see, nothing is exported from the LISP-ON-LINES package.
638 if you wish to use LOL in your own package (or in UCW-USER or whatever),
641 you simply need to use the MEWA and META-MODEL packages"
644 (<ucw:render-component :component (lisp-on-lines::make-presentation lisp-on-line
645 s::user :type :viewer)))
648 SET-ATTRIBUTE can be used in place of (setf (find-attribute)) when you want
649 to "inherit" the properties of an existing attribute definition :
652 LISP-ON-LINES> (set-attribute 'user 'password '(string :label "password:
653 (must be at leat 8 chars)"))
662 "password: (must be at leat 8 chars)"
671 Now we want to create a presentation with which to edit the username.
672 we will use the existing attributes on a subclass of mewa-object-presetation
676 LISP-ON-LINES> (defcomponent user-editor (mewa-object-presentation)
685 :attributes '((username :label "Enter your New Username") password)
688 :global-properties '(:editablep t)))
694 LISP-ON-LINES> (setf (find-attribute 'user :editor) '(user-editor))
697 (:EDITOR USER-EDITOR)
703 which we then can display below our earlier example :
706 (defmethod render-on ((res response) (e presentations-index))
712 As you'll see, nothing is exported from the LISP-ON-LINES package.
716 if you wish to use LOL in your own package (or in UCW-USER or whatever),
719 you simply need to use the MEWA and META-MODEL packages"
722 (<ucw:render-component :component (lisp-on-lines::make-presentation lisp-on-line
723 s::user :type :viewer))
726 (<ucw:render-component :component (lisp-on-lines::make-presentation lisp-on-line
727 s::user :type :editor)))
730 that should give you some idea on how it works ..
731 ask me when you get confused :)