From: Adam Warner
Subject: mod_lisp Hello World?
Date: 
Message-ID: <aa52a9$7qhcj$1@ID-105510.news.dfncis.de>
Hi all,

I see Marc Battyani posts here frequently so I'm sure he will also see
this :-)

I have installed mod_lisp and it's now apparent that you write HTML within
Lisp code rather than embed Lisp into HTML (like happens with PHP). This
seems fine to me because I imagine I could define Lisp functions to help
me write more compact HTML--since even in the most trivial example a
closing bracket is more compact than a closing tag, e.g. compare
<blockquote></blockquote> with (blockquote ).

With the PHP approach I write a page (file) and when a browser accesses
that file the embedded PHP code is processed. Zero code is needed to
determine the page because that information is contained within the file
structure on the disk. It appears I should also be able to do this if I
execute (for example) all *.lisp files as lisp scripts by default.

I would appreciate a Hello World for mod_lisp in order to better
understand how this works (it would also be a useful addition to the
Fractal Concepts web site). A Hello World in PHP is trivial:

1. Place this text in a file called temp.html on the web site
website.invalid:

   <?php echo "<p>Hello World</p>"; ?>

2. Browse http://website.invalid/temp.html

How would you go about doing this in mod_lisp for a script called
temp.lisp? It appears I'm supposed to read and write from/to Apache
sockets and something simple like (write-string "<p>Hello World</p>") just
isn't going to work.

Thanks,
Adam

From: Dr. Edmund Weitz
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <pu0pee8l.fsf@agharta.de>
Adam Warner <······@consulting.net.nz> writes:

> Hi all,
>
> I see Marc Battyani posts here frequently so I'm sure he will also see
> this :-)
>
> I have installed mod_lisp and it's now apparent that you write HTML within
> Lisp code rather than embed Lisp into HTML (like happens with PHP). This
> seems fine to me because I imagine I could define Lisp functions to help
> me write more compact HTML--since even in the most trivial example a
> closing bracket is more compact than a closing tag, e.g. compare
> <blockquote></blockquote> with (blockquote ).
>
> With the PHP approach I write a page (file) and when a browser accesses
> that file the embedded PHP code is processed. Zero code is needed to
> determine the page because that information is contained within the file
> structure on the disk. It appears I should also be able to do this if I
> execute (for example) all *.lisp files as lisp scripts by default.
>
> I would appreciate a Hello World for mod_lisp in order to better
> understand how this works (it would also be a useful addition to the
> Fractal Concepts web site). A Hello World in PHP is trivial:
>
> 1. Place this text in a file called temp.html on the web site
> website.invalid:
>
>    <?php echo "<p>Hello World</p>"; ?>
>
> 2. Browse http://website.invalid/temp.html
>
> How would you go about doing this in mod_lisp for a script called
> temp.lisp? It appears I'm supposed to read and write from/to Apache
> sockets and something simple like (write-string "<p>Hello World</p>") just
> isn't going to work.

The download section of the mod_lisp website has several "Hello World"
examples for different CL implementations. (Basically, they only
differ in how they handle the non-ANSI stuff like sockets and MP.)

Edi.
From: Adam Warner
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <aa5v4m$84iv2$1@ID-105510.news.dfncis.de>
On Wed, 24 Apr 2002 19:40:26 +1200, Dr. Edmund Weitz wrote:

> The download section of the mod_lisp website has several "Hello World"
> examples for different CL implementations. (Basically, they only differ
> in how they handle the non-ANSI stuff like sockets and MP.)

OK, so Hello World requires approximately 100 lines of code. And that code
has to be incorporated into every Lisp script that is going to provide
such functionality. So I can get to what I consider a suitable "Hello
World" by going through these steps:

1. Write a function that accepts string input and writes it to the browser
using the Apache socket code.

2. Compile all the Apache socket code and this function into a single
file.

3. Load this compiled code in at the beginning of every Lisp script.

Then I think we would be at the point of an appropriate "Hello World". It
might look something like this:

   (load "functions.x86f")
   (write-to-browser "Hello World")

Could the typing overhead of explictly loading in the socket code for each
script be avoided?

Regards,
Adam
From: Dr. Edmund Weitz
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <it6hs4uy.fsf@agharta.de>
Adam Warner <······@consulting.net.nz> writes:

> On Wed, 24 Apr 2002 19:40:26 +1200, Dr. Edmund Weitz wrote:
>
>> The download section of the mod_lisp website has several "Hello
>> World" examples for different CL implementations. (Basically, they
>> only differ in how they handle the non-ANSI stuff like sockets and
>> MP.)
>
> OK, so Hello World requires approximately 100 lines of code. And
> that code has to be incorporated into every Lisp script that is
> going to provide such functionality.

No, that's the wrong approach. What you describe would be correct if
you were working with CGI scripts. The whole idea of mod_lisp is that
you don't have to do this. You have one Lisp image that dispatches and
serves all the request, i.e. those 100 lines of code that you're
referring to will be written and loaded once when the Lisp image is
started. From then on, you just add, modify or remove functions (or
'handlers') for the incoming http requests - no need to restart the
Lisp or the Apache, no need to write stand-alone 'scripts'.

Edi.
From: Fernando Rodr�guez
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <2mbdcuo43am6tvfltmjj4ak9ptha4rskba@4ax.com>
On Wed, 24 Apr 2002 13:39:17 +0200, ···@agharta.de (Dr. Edmund Weitz) wrote:


>No, that's the wrong approach. What you describe would be correct if
>you were working with CGI scripts. The whole idea of mod_lisp is that
>you don't have to do this. You have one Lisp image that dispatches and
>serves all the request, i.e. those 100 lines of code that you're
>referring to will be written and loaded once when the Lisp image is
>started. From then on, you just add, modify or remove functions (or
>'handlers') for the incoming http requests - no need to restart the
>Lisp or the Apache, no need to write stand-alone 'scripts'.

I'm currently struggling with a cgi script to do something apparently simple:
on the onblur event of a control in a form, save some data in a db.

This script shouldn't return a thing and shouldn't change the contents of the
browser. Something like calling a function for its side-effects only.

Is this sort of thing possible or easier with mod_lisp? O:-)



-----------------------
Fernando Rodriguez
From: Edi Weitz
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <m3pu0pysic.fsf@dyn138.dbdmedia.de>
Fernando Rodr�guez <····@wanadoo.es> writes:

> I'm currently struggling with a cgi script to do something
> apparently simple: on the onblur event of a control in a form, save
> some data in a db.
> 
> This script shouldn't return a thing and shouldn't change the
> contents of the browser. Something like calling a function for its
> side-effects only.
> 
> Is this sort of thing possible or easier with mod_lisp? O:-)

No, I don't think so. The problem is that you have a mixture of code
that's running on the client (the onBlur event trigger which is
Javascript in the browser) and code that's running on the server (the
stuff needed to update the database).

I could think of a couple of ways to achieve what you want but as this
is rather off-topic I'd suggest that you email me privately.

For this particular problem I'd say it wouldn't make any difference
whether you used mod_lisp, mod_perl, mod_php, or whatever on the
server.

Edi.
From: Adam Warner
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <aa69c0$82407$1@ID-105510.news.dfncis.de>
Dr. Edmund Weitz wrote:

>> OK, so Hello World requires approximately 100 lines of code. And that
>> code has to be incorporated into every Lisp script that is going to
>> provide such functionality.
> 
> No, that's the wrong approach. What you describe would be correct if you
> were working with CGI scripts. The whole idea of mod_lisp is that you
> don't have to do this. You have one Lisp image that dispatches and
> serves all the request, i.e. those 100 lines of code that you're
> referring to will be written and loaded once when the Lisp image is
> started. From then on, you just add, modify or remove functions (or
> 'handlers') for the incoming http requests - no need to restart the Lisp
> or the Apache, no need to write stand-alone 'scripts'.

Wow! That's an amazing approach (these are paradigm shifting ideas).
Thanks for setting me on the right path.

Regards,
Adam
From: Marc Battyani
Subject: Re: mod_lisp Hello World?
Date: 
Message-ID: <24A65585D679182D.45F8EF3DC9650145.40A11755B3AAB53E@lp.airnews.net>
"Adam Warner" <······@consulting.net.nz> wrote
> Hi all,
>
> I see Marc Battyani posts here frequently so I'm sure he will also see
> this :-)

I generally try to read c.l.l but don't always have the time to do so ;-)

> I have installed mod_lisp and it's now apparent that you write HTML within
> Lisp code rather than embed Lisp into HTML (like happens with PHP). This
> seems fine to me because I imagine I could define Lisp functions to help
> me write more compact HTML--since even in the most trivial example a
> closing bracket is more compact than a closing tag, e.g. compare
> <blockquote></blockquote> with (blockquote ).
>
> With the PHP approach I write a page (file) and when a browser accesses
> that file the embedded PHP code is processed. Zero code is needed to
> determine the page because that information is contained within the file
> structure on the disk. It appears I should also be able to do this if I
> execute (for example) all *.lisp files as lisp scripts by default.

Edi has answered to your questions, so I will just insist on the fact that
systems like mod_lisp are not intended to simply generate HTML pages but
rather for developping complete applications. Apache+mod_lisp provide the
web front end for them but do not provide other support for those
applications. You will have to get or write an HTML generation macro, some
kind of session management, etc.

Marc