this accesses some internal ucw symbols. this will have to be changed with some patch...
[clinton/lisp-on-lines.git] / lisp-on-lines.lyx
index 9a3b5ed..dcbe7b4 100644 (file)
@@ -6,8 +6,9 @@
 \fontscheme default
 \graphics default
 \paperfontsize default
-\papersize Default
-\paperpackage a4
+\spacing single 
+\papersize a4paper
+\paperpackage widemarginsa4
 \use_geometry 0
 \use_amsmath 0
 \use_natbib 0
@@ -62,6 +63,18 @@ Common Lisp
 \layout Section
 
 Introduction
+\layout Standard
+
+
+\noun on 
+Lisp-On-Lines
+\noun default 
+ was founded and developed and continues to be developed and mantained by
+\noun on 
+Drew Crapmsie
+\noun default 
+.
 \layout Subsection
 
 Conventions
@@ -70,9 +83,10 @@ Conventions
 The conventions used in this manual are:
 \layout Itemize
 
-Lisp code is shown as a monospace font.
- It is assumed that the user is working in an interactive environment and
- what the user should type appears as bold, for example:
+Dode is shown as a monospace font.
+ When it is expected that the user is working in an interactive environment
+ what the user should type appears as bold, while the computer result appears
+ non-bold, for example:
 \begin_deeper 
 \layout LyX-Code
 
@@ -97,16 +111,13 @@ Lisp-On-Lines
 \layout Itemize
 
 Sections marked with 
-\series bold 
 \color red
 ToDo
-\series default 
 \color default
  require further revision.
 \layout Standard
 
 
-\series bold 
 \color red
 ToDo: Add more conventions as they are needed, possible classes of text:
  names of concepts, name of programming entities, like variables, functions,
@@ -266,7 +277,16 @@ or the types with:
 ((USERID INTEGER) (USERNAME STRING) (PASSWORD STRING))
 \layout Standard
 
-We can run:
+To see the default attributes of a class
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+Is this correct ? Drew, please, check.
+\end_inset 
+
+ we run.
 \layout LyX-Code
 
 > 
@@ -283,12 +303,12 @@ We can run:
  (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD))
 \layout Standard
 
-What does this do ?
+To set the attributes of a class to the default values we use:
 \layout LyX-Code
 
 > 
 \series bold 
-(set-default-attributes user)
+(lisp-on-lines::set-default-attributes user)
 \layout LyX-Code
 
 ((USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
@@ -300,6 +320,11 @@ What does this do ?
  (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD))
 \layout Standard
 
+which takes an object of the class we are working with.
+ This is going to be change so we can do this action directly on the class.
+ It is on the TODO file.
+\layout Standard
+
 Class attributes?
 \layout LyX-Code
 
@@ -359,60 +384,121 @@ note that the mewa functions (find-attribute, set-attribute etc) can take
 \layout Standard
 
 Using that information, we have enough to create an interface to the object.
- UncommonWeb includes a powerful presentation system, but it is not quite
- dynamic enough for our needs.
- Mewa defines an approach to presentations that suits our purposes, but
- the paper is written from a smalltalk point of view.
- A mixture of the two , Mewa Presentations(MP), is described here.
+\noun on 
+UnCommon Web
+\noun default 
+ includes a powerful presentation system
+\begin_inset Foot
+collapsed true
+
 \layout Standard
 
-MP introduces to UCW the concept of attributes.
- an attribute is essentially a named version of the defpresentation slot-like
- arguments.
- for example in :
+To see this system in action, we strongly recomend to study the presentations
+ example which comes with 
+\noun on 
+UnCommon Web
+\noun default 
+.
+ Reading components/presentations.lisp can help understand a lot about how
+ presentations are built.
+\end_inset 
+
+, but it is not dynamic enough for some of the most advanced applications.
+ Mewa defines an approach to presentations that solves that problem, but
+ the paper is written from a 
+\noun on 
+Smalltalk
+\noun default 
+ point of view.
+ A mixture of the two , Mewa Presentations(MP), is described here.
 \layout Standard
 
+MP introduces to 
+\noun on 
+UnCommon Web
+\noun default 
+ the concept of 
+\emph on 
+attributes
+\emph default 
+.
+ An attribute is essentially a named version of the DEFPRESENTATION slot-like
+ arguments, for example in :
+\layout LyX-Code
+
+> 
+\series bold 
 (defpresentation person-editor (object-presentation)
-\layout Standard
+\layout LyX-Code
+
 
-((string :label "First Name" :slot-name 'first-name :max-length 30)))
+\series bold 
+   ((string :label "First Name" :slot-name 'first-name :max-length 30)))
 \layout Standard
 
 the (string :label "First Name" ...) form is an attribute definiton.
  Attributes are accessed through FIND-ATTIRIBUTES, and are composed at run
- time (where the current system is done at compile time) to display the
- object.
+ time (where the 
+\noun on 
+UnCommon Web
+\noun default 
+'s presentation system is done at compile time) to display the object.
  This allows a very flexible system of displaying objects which is reminiscent
- of CSS.
- I discovered this, rather than invent or design it, so there are some rough
+ of 
+\noun on 
+CSS
+\noun default 
+
+\begin_inset Foot
+collapsed true
+
+\layout Standard
+
+
+\noun on 
+Drew Crapmsie
+\noun default 
+ discovered this, rather than invent or design it, so there are some rough
  edges, but its a good start.
+\end_inset 
+
+.
 \layout Standard
 
-Its much easier to show this then to tell.
+Its much easier to show this than to tell.
  Lets present our user class.
- Currently in UCW, you'd define a presentation as such :
-\layout Standard
+ Currently in 
+\noun on 
+UnCommon Web
+\noun default 
+, you'd define a presentation as such :
+\layout LyX-Code
 
+> 
+\series bold 
 (defpresentation user-presentation (object-presentation)
-\layout Standard
+\layout LyX-Code
 
 ((INTEGER :LABEL "USERID" :SLOT-NAME USERID)
-\layout Standard
+\layout LyX-Code
 
-(STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
-\layout Standard
+ (STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
+\layout LyX-Code
 
-(STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)))
+ (STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)))
 \layout Standard
 
 which could be presented using PRESENT-OBJECT :
-\layout Standard
+\layout LyX-Code
 
+> 
+\series bold 
 (present-object user :using 'user-presentation)
 \layout Standard
 
-The equiv approach using mewa presentations is actually longer and more
- verbose(!) but it serves to demonstrate how the MP system works.
+The equivalent approach using mewa presentations is actually longer and
more verbose(!) but it serves to demonstrate how the MP system works.
 \layout Standard
 
 Mewa Presentations adds a set of attributes to a class, keyed off the class
@@ -422,102 +508,187 @@ Mewa Presentations adds a set of attributes to a class, keyed off the class
 \layout Standard
 
 MP stores named attributes keyed on a class name.
to achieve the same functionality as the above using mp would look like
To achieve the same functionality as the above using mp would look like
  this :
-\layout Standard
+\layout LyX-Code
+
+> 
+\series bold 
+(setf (lisp-on-lines::find-attribute 'user :viewer)
+\begin_inset Marginal
+collapsed true
 
-LISP-ON-LINES> (setf (find-attribute 'user :viewer) '(mewa-object-presentation
- :attributes (userid username password) :global-properties (:editablep nil)))
 \layout Standard
 
+Isn't this too imperative (in contrast to functional, lispy).
+\end_inset 
+
+
+\layout LyX-Code
+
+
+\series bold 
+        '(lisp-on-lines::mewa-object-presentation
+\layout LyX-Code
+
+
+\series bold 
+          :attributes (userid username password)
+\layout LyX-Code
+
+
+\series bold 
+          :global-properties (:editablep nil)))
+\layout LyX-Code
+
 (:VIEWER MEWA-OBJECT-PRESENTATION
-\layout Standard
+\layout LyX-Code
 
-:ATTRIBUTES
-\layout Standard
+         :ATTRIBUTES
+\layout LyX-Code
 
-(USERID USERNAME PASSWORD)
-\layout Standard
+         (USERID USERNAME PASSWORD)
+\layout LyX-Code
 
-:GLOBAL-PROPERTIES
-\layout Standard
+         :GLOBAL-PROPERTIES
+\layout LyX-Code
 
-(:EDITABLEP NIL))
-\layout Standard
+         (:EDITABLEP NIL))
+\layout LyX-Code
+
+> 
+\series bold 
+(setf (lisp-on-lines::find-attribute 'user 'userid)
+\begin_inset Marginal
+collapsed true
 
-LISP-ON-LINES> (setf (find-attribute 'user 'userid) '(INTEGER :LABEL "USERID"
- :SLOT-NAME USERID))
 \layout Standard
 
+Are this setfs to 'userid, 'username and 'password needed ? I (Pupeno) inspected
+ they contents at of this moment and they seem to already contain what they
+ are being set to.
+\end_inset 
+
+
+\layout LyX-Code
+
+
+\series bold 
+        '(integer :label "userid" :slot-name userid))
+\layout LyX-Code
+
 (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
-\layout Standard
+\layout LyX-Code
 
-LISP-ON-LINES> (setf (find-attribute 'user 'username) '(STRING :LABEL "USERNAME"
- :SLOT-NAME USERNAME))
-\layout Standard
+> 
+\series bold 
+(setf (lisp-on-lines::find-attribute 'user 'username)
+\layout LyX-Code
+
+
+\series bold 
+        '(STRING :LABEL "USERNAME" :SLOT-NAME USERNAME))
+\layout LyX-Code
 
 (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
-\layout Standard
+\layout LyX-Code
+
+> 
+\series bold 
+(setf (lisp-on-lines::find-attribute 'user 'password)
+\layout LyX-Code
 
-LISP-ON-LINES> (setf (find-attribute 'user 'password) '(STRING :LABEL "USERNAME"
- :SLOT-NAME PASSWORD))
-\layout Standard
+
+\series bold 
+        '(STRING :LABEL "USERNAME" :SLOT-NAME PASSWORD))
+\layout LyX-Code
 
 (PASSWORD STRING :LABEL "USERNAME" :SLOT-NAME PASSWORD)
-\layout Standard
+\layout LyX-Code
 
-LISP-ON-LINES> (find-class-attributes 'user) 
-\layout Standard
+> 
+\series bold 
+(lisp-on-lines::find-class-attributes 'user)
+\layout LyX-Code
 
-(USER (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
-\layout Standard
+(USER
+\layout LyX-Code
 
-(USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
-\layout Standard
+ (:VIEWER MEWA-OBJECT-PRESENTATION
+\layout LyX-Code
 
-(USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
-\layout Standard
+          :ATTRIBUTES
+\layout LyX-Code
 
-(:VIEWER MEWA-OBJECT-PRESENTATION
-\layout Standard
+          (USERID USERNAME PASSWORD)
+\layout LyX-Code
 
-:ATTRIBUTES
-\layout Standard
+          :GLOBAL-PROPERTIES
+\layout LyX-Code
 
-(USERID USERNAME PASSWORD)
-\layout Standard
+          (:EDITABLEP NIL))
+\layout LyX-Code
 
-:GLOBAL-PROPERTIES
-\layout Standard
+ (PASSWORD STRING :LABEL "PASSWORD" :SLOT-NAME PASSWORD)
+\layout LyX-Code
 
-(:EDITABLEP NIL))
-\layout Standard
+ (USERNAME STRING :LABEL "USERNAME" :SLOT-NAME USERNAME)
+\layout LyX-Code
 
-COMMON-LISP:NIL)
-\layout Standard
+ (USERID INTEGER :LABEL "USERID" :SLOT-NAME USERID)
+\layout LyX-Code
 
-this is all turned into a UCW presentation at runtime using MAKE-PRESENTATION
- :
+ NIL)
 \layout Standard
 
-(defmethod render-on ((res response) (e presentations-index))
-\layout Standard
+this is all turned into a 
+\noun on 
+UnCommon Web
+\noun default 
+ presentation at runtime using MAKE-PRESENTATION, for example, the following
+ code should be enough to show what's built so far attached to the examples
+ application:
+\layout LyX-Code
 
-"
-\layout Standard
+> 
+\series bold 
+(defcomponent lol-example (window-component)
+\layout LyX-Code
 
-As you'll see, nothing is exported from the LISP-ON-LINES package.
-\layout Standard
 
-if you wish to use LOL in your own package (or in UCW-USER or whatever),
-\layout Standard
+\series bold 
+   ())
+\layout LyX-Code
 
-you simply need to use the MEWA and META-MODEL packages" 
+> 
+\series bold 
+(defmethod render-on ((res response) (lol-example lol-example))
+\layout LyX-Code
+
+
+\series bold 
+    (<:h1 "User")
+\layout LyX-Code
+
+
+\series bold 
+    (<ucw:render-component :component (lisp-on-lines::make-presentation
+ user :type :viewer)))
+\layout LyX-Code
+
+> 
+\series bold 
+(defentry-point "lol.ucw" (:application *example-application*) ()
+\layout LyX-Code
+
+
+\series bold 
+    (call 'products-presentation))
 \layout Standard
 
-(<ucw:render-component :component (lisp-on-lines::make-presentation lisp-on-line
-s::user :type :viewer)))
+As you'll see, nothing is exported from the LISP-ON-LINES package.
+ If you wish to use LOL in your own package (or in UCW-USER or whatever),
+ you simply need to use the MEWA and META-MODEL packages.
 \layout Standard
 
 SET-ATTRIBUTE can be used in place of (setf (find-attribute)) when you want
@@ -604,4 +775,217 @@ s::user :type :editor)))
 
 that should give you some idea on how it works ..
  ask me when you get confused :)
+\layout Section
+
+Pupeno's Example
+\layout Standard
+
+This is Pupeno's view of how to do rapid developing of a database-driven
+ web application.
+ It currently is going to assume a very specific case but latter it may
+ be made bigger.
+\layout Standard
+
+We first start with a 
+\noun on 
+PostgreSQL
+\noun default 
+ connection of CLSQL which is set up with one line:
+\layout LyX-Code
+
+> 
+\series bold 
+(clsql:connect '("localhost" "geo" "geo" "geogeo"))
+\layout Standard
+
+which connect us to the server on 
+\family typewriter 
+localhost
+\family default 
+, to the database 
+\family typewriter 
+geo
+\family default 
+ as user 
+\begin_inset Quotes eld
+\end_inset 
+
+geo
+\begin_inset Quotes erd
+\end_inset 
+
+ with password 
+\begin_inset Quotes eld
+\end_inset 
+
+geogeo
+\begin_inset Quotes erd
+\end_inset 
+
+ (this is not a smart way to generate password, don't do this).
+ To have a nice SQL environment, we also want:
+\layout LyX-Code
+
+> 
+\series bold 
+(clsql:locally-enable-sql-reader-syntax)
+\layout LyX-Code
+
+> 
+\series bold 
+(setf clsql:*default-caching* nil)
+\layout Standard
+
+Actually, it is more than a nice environmnet, without those lines the rest
+ of the code won't work.
+\layout Standard
+
+On the 
+\family typewriter 
+geo
+\family default 
+ database, there's a table called 
+\family typewriter 
+product
+\family default 
+ which has the following structure:
+\layout LyX-Code
+
+
+\series bold 
+CREATE TABLE product (
+\layout LyX-Code
+
+
+\series bold 
+    id serial NOT NULL,
+\layout LyX-Code
+
+
+\series bold 
+    name text NOT NULL,
+\layout LyX-Code
+
+
+\series bold 
+    details text,
+\layout LyX-Code
+
+
+\series bold 
+    description text,
+\layout LyX-Code
+
+
+\series bold 
+    cost double precision,
+\layout LyX-Code
+
+
+\series bold 
+    CONSTRAINT product_cost_check CHECK ((cost > (0)::double precision))
+\layout LyX-Code
+
+
+\series bold 
+);
+\layout LyX-Code
+
+
+\series bold 
+ALTER TABLE ONLY product ADD CONSTRAINT product_name_key UNIQUE (name);
+\layout LyX-Code
+
+
+\series bold 
+ALTER TABLE ONLY product ADD CONSTRAINT product_pkey PRIMARY KEY (id);
+\layout Standard
+
+
+\color red
+ToDo: express the table structure in a better way.
+\layout Standard
+
+Now we'll create the class that represents a product, mirroring the database
+ structure:
+\layout LyX-Code
+
+> 
+\series bold 
+(lisp-on-lines::def-view-class/table "product")
+\layout Standard
+
+and then we generate the default attributes (from 
+\family typewriter 
+product
+\family default 
+'s slots) and assign it to 
+\family typewriter 
+product
+\family default 
+:
+\layout LyX-Code
+
+> 
+\series bold 
+(lisp-on-lines::set-default-attributes (make-instance 'product))
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+set-default-attributes is marked to be renamed to set-generated-attributes.
+\end_inset 
+
+
+\layout Standard
+
+As you can see, we instantiate 
+\family typewriter 
+product
+\family default 
+ to pass it to 
+\family typewriter 
+set-default-attributes
+\family default 
+, because it expects an object instead of a class.
+ We don't need the object anymore, so we don't save any reference to it.
+ In the future we might have a 
+\family typewriter 
+set-default-attributes
+\family default 
+ that can use a class directly.
+ Now we set a the attribute 
+\family typewriter 
+:viewer
+\family default 
+ to contain the 
+\family typewriter 
+mewa-object-presentation
+\family default 
+ exposing the attributes we like the user to work with:
+\layout LyX-Code
+
+> 
+\series bold 
+(setf (lisp-on-lines::find-attribute (make-instance 'product) :viewer)
+\layout LyX-Code
+
+
+\series bold 
+        '(lisp-on-lines::mewa-object-presentation 
+\layout LyX-Code
+
+
+\series bold 
+          :attributes (name details description cost)
+\layout LyX-Code
+
+
+\series bold 
+          :global-properties (:editablep nil)))
+\layout Standard
+
+The last parameter shows that it is not editable, which makes sense for
+ a viewer.
 \the_end