This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Guile web page scripting, anyone?


Hi,

I'm new to this list (and Guile/Scheme in general) so be kind!

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 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:

	...
	HTML stuff
	...
	<% ...guile code to run... %>
	...
	more HTML here
	...
	<%= ...guile code to run and return an expression... %>
	...
	some more HTML
	...

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.

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

	create_instance () - does any initialisation required to set up a new
instance of Guile for each web page we're working with.

	evaluate_line () - takes a line of text and evaluates/interprets it.
It can handle incomplete lines.

That's sortof what I want, but it doesn't seem to be available through
the GH library.  I've read the docs and it says I have to call gh_enter
with a main routine of my own, but I can't do that (easily) since I'm
writing an Apache module and I really need to return (whereas gh_enter()
calls exit()).

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...

Finally, I try and avoid high-scoping variables, but it looks like I'm
being forced into using one here.  The current way I'm doing it is:

	1. my module receives a request
	2. it reads and outputs the HTML until it gets to one of the special
tags.
	3. it reads in the code embedded in the page.
	4. it fires up Guile, with the special guile_main () method.
	5. the guile_main () method calls guile to interpret the code.

The problem here is that the parsing of the file is done at point 2.,
and the code is read in at point 3.  How do I pass this through gh_enter
() at point 4. so it's available for my guile_main () method to use in
point 5., without using a module-scope variable?

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 do think this is worth pursuing though - a standard for 'Guile Server
Pages' (or 'GNU Server Pages', or whatever) could benefit everyone as
well as raise Guile's profile.  And the ability to use different
languages would be very cool indeed.

Thanks for listening - any help gratefully received.

			Geoff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]