This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Guile web page scripting, anyone?
- To: <geoff at aspforums dot com>
- Subject: Re: Guile web page scripting, anyone?
- From: Jorgen `forcer' Schaefer <forcer at mindless dot com>
- Date: 28 Dec 1999 05:42:24 +0100
- Cc: <guile at sourceware dot cygnus dot com>
- References: <001901bf50ae$f1230940$d08701d4@marburg>
"Geoff" <geoff@eLancer2000.com> writes:
> One of the projects listed on the GNU Guile web pages is about using
> Guile for server-side scripting of HTML pages. I figured that was
> something I could do, and it would be a good learning exercise for me.
I'm currently writing mod_guile, which should be able to do what
you want with just a bit of action on your part. That's the good
news. The bad news is that i'm a bit busy lately, and waiting
for the environment patches, because i want to do The Right Thing.
> I figured what was really needed was a web page scripting model that web
> developers would find familiar. I started with the idea of Guile code
> interwoven with HTML using the following tag mechanism:
>
> <% ...guile code to run... %>
> <%= ...guile code to run and return an expression... %>
>
> This is the same way MS' Active Server Pages and Sun's JavaServer Pages
> interleave HTML and code. I'm currently working on an Apache module
> that will do all this (as well as handle a couple more tags which aren't
> relevant here), and I've a couple of questions for you all.
This should be a pretty simple content-handler for mod_guile.
Just write a reader which turns that code into Scheme
expressions which can be evaluated, e.g.
Foo <% bar %> baz <%= qux %>
=> (display "Foo ") bar (display " baz ") (display qux)
That's about it, mod_guile should handle the rest.
That is, as soon as i have finished it ;)
I'll still answer your questions since you might want to write
mod_guileasp or something instead of using mod_guile... or want
to write other extensions using guile... or are interested on how
i solved the problems in mod_guile
> I suppose the main one is how do I get Guile to interpret the code?
> Now, it's not as dumb a question as it appears. What I really want is a
> library that'll allow something like:
>
> initialise_guile () -- does all the difficult startup stuff, just
> executed once per web server
Once at all. Guile just needs to be initialized once, before any
forking. (tried and worked) -- so far i solved this with a patch,
but i'm looking forward to the inclusion of Maciej's patches who
were able to do this without taking over the stack
completel. *sigh* hope they'll get it soon
> create_instance () - does any initialisation required to set up a new
> instance of Guile for each web page we're working with.
Guile doesn't work like most other extension languages - it's
different, just like Scheme is different, and imho it's better.
What you want to do (different namespaces) can be achieved with
different environments (*once* those are include...)
> evaluate_line () - takes a line of text and evaluates/interprets it.
> It can handle incomplete lines.
SCM gh_eval_str (char *scheme_code)
> Also, I have one line of the code buffered into memory. I'd like to be
> able to call a function to have it evaluated, or 'partially evaluated'
> so I can let the web developer know which line caused an error. Is
> there a way of doing this? The only method I can find that comes close
> is gh_eval_str (), but it requires the code be complete (all parentheses
> balanced). This limitation would also hamper web developers who want
> HTML to be output conditionally, but that's another story...
Not at all, you can do like i did and pointed out above - just
convert the whole webpage into Scheme code. Write a read function
which does that for you. Should be easy enough.
> Boy, this turned out to be longer than I expected. The questions are
> clear in my head, but I'm not sure how well they came across here. By
> all means rant at me if I've been unclear.
I think the biggest problem for you is that Guile is
Different[tm] - it does it right, though. (i had the same
starting problems)
You don't want to fire up guile multiple times. It's quite
strongly integrated with the C world. The big problem here is
that the way to get around this - First Class Environments - are
not yet in guile (*hint* *hint*) ;)
-- forcer
--
((email . "forcer@mindless.com") (www . "http://forcix.cx/")
(irc . "forcer@#StarWars (IRCnet)") (gpg . "/other/forcer.gpg"))