KPAX - A CL Web Application Framework
Sunday, April 8, 2007
I've written in the past about some of the things that Sven Van Caekenberghe has done:
- Rebel With a Cause case study
- Object Prevalence in CL
- Article about Seaside - a continuation-based Web Framework in Smalltalk
- LispWorks HTTP Client/Server Movie
- (Re)writing Reddit in Lisp Movie

Then, it was simply a matter of ticking the box for KPAX to install everything I needed.
Sven uses Edi's CL-WHO for HTML generation; so, if you're used to using Edi's tools, you'll find it easy to write HTML code for KPAX. However, Sven also provides a simple form-creation "defwebform" macro that makes it really easy to create data entry forms. For example, this demo page was created by the following code:
(defwebform demo-web-form
((:group personal-info
:label "Personal Info"
:members ((fullname :text :label "Fullname")
(username :text :label "Username"
:options (:size 10)
:validator (all required (limited-string 8 4) contains-no-spaces))
(password :password :label "Password"
:options (:size 10)
:validator (or optional (limited-string 32)))
(password2 :password :label "Password"
:options (:size 10) :comment "[Confirmation]"
:validator (or optional (limited-string 32)))
(gender :choice
:options (:values *genders* :style :buttons)
:parser parse-keyword :formatter string-capitalize
:validator (or optional (list-element *genders*)))
(age :text :label "Age"
:options (:size 4)
:parser s-utils:parse-integer-safely
:validator (integer-range 0 150))))
(:group admin-info
:label "Admin Info"
:members ((notes :text-area :label "Notes"
:options (:cols 40 :rows 10)
:validator (or optional (limited-string 256)))
(enabled-p :choice :label "Enabled"
:options (:values :boolean)
:parser parse-boolean
:validator boolean)))
(:group preferences
:label "Preferences"
:members ((interests :choice
:options (:values *interests* :selection :multiple :style :buttons)
:parser parse-symbol-kpax-user :formatter string-capitalize
:validator (or optional (list-elements *interests*)))
(language :choice
:options (:values *languages* :style :list)
:parser parse-symbol-kpax-user :formatter string-capitalize
:validator (or optional (list-element *languages*)))
(music-tastes :choice
:options (:values *music-tastes* :style :list :selection :multiple)
:parser parse-symbol-kpax-user :formatter string-capitalize
:validator (or optional (list-elements *music-tastes*)))))
(id :hidden))
(:title "Demo User")
(:validator validate-demo-web-form)
(:submit process-demo-web-form))
Sven hasn't provided very much documentation for
KPAX; however, a good "getting started" approach would be:- Play around with the live KPAX examples to get a feel for what KPAX can do.
- Read the Installing KPAX post that Sven made to the KPAX-devel mailing list. Then, use either the installation instructions he provides or STARTER-PACK (with my custom config.lisp file) to install KPAX.
- Read the Running KPAX post that Sven made to the KPAX-devel mailing list and play around with the examples locally. (if you want to use mod_lisp with Apache instead of the built-in HTTP server, read the Installation and Configuration of mod_lisp post too)
- Spend some time looking at the example code.
- Have a look at Sven's LispWorks HTTP Client/Server and (Re)writing Reddit in Lisp movies (for more tips and inspiration).
- Write some sample web apps.
- Create the next Viaweb, sell it to Google for millions and become a VC! ;-)

