unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: rm@fabula.de
Cc: rm@fabula.de, guile-devel@gnu.org
Subject: Re: scm_* API extension? [was] scm_* API question
Date: Mon, 5 Aug 2002 18:06:39 +0200	[thread overview]
Message-ID: <20020805160639.GA19325@www> (raw)
In-Reply-To: <lj4re9ibr6.fsf@burns.dt.e-technik.uni-dortmund.de>

On Mon, Aug 05, 2002 at 05:08:45PM +0200, Marius Vollmer wrote:
> rm@fabula.de writes:
> > Ok this is for my current (frankensteinish) hacking with Dave's mod_guile:
> > i'm working on implementing a mod_guile mode in which URLs get mapped to
> > so-called 'handlers' in modules - meaning i (ab?)use the hierarchical module
> > space a namespace enclosures.
> 
> That sounds rather reasonable to me.  But do you need to invoke
> 'use-modules' for this?

As i just found out, no ;-) 

> What I would probably do is to have a single Scheme function that gets
> called from C, and perform all the dispatching in Scheme.  That
> function would be called with different arguments for different
> <Location>s.

This is probably a matter of taste, but i'd like to reuse guiles
allready existing dispatch mechanisms.

> 
> I suppose, all Apache can really handle in its configuration file are
> strings.  

Well, on one level, yes (since a configuration file _is_ a looong
string). Currently i handle these configuration options as 'raw'
options, i.e. Apache does no tokenisation at all -- the character
stream gets fed to scm_read_string, so after reading of the configuration
file i have all configuration settings as SCM structures. It would 
be trivial to extend the configuration process to actually have the
handler defined in the configuration file:
<Location /fou>
 GuileContentLamda (lambda (request)
                       (let ((user (req:remote-user request))
		             (hist (req:host  request))
			     .....
			     )
</Location>

> So I would make my Scheme function take a string as its
> argument.  When the function wants to interpret that string as a
> Scheme form, it can do so.  (Calling 'read' from Scheme is no less
> efficient than calling it from C, but more convenient.)
> 
> Maybe I would even require the Scheme code to register the dispatching
> function with the C code before it can be used.  That way, the C code
> is completely independent from the Scheme code and the interactions
> between the too are not via magic names but by explicit API calls.
> 
> > I'll also plan to add something like
> > 
> >  GuileBind a-symbol '(arbitrary (guile data) structure)
> > 
> > i.e. i want guile to 'read' from the configuration file and bind
> > 'a-symbol' to whatever was read.
> 
> I think I would pass extra information via the handler callback, not
> as a variable, but of course I can't say whether that will be feasible
> in your case.

Hmmm, "filling up" the environment in which the handler executes with
some predifined values can be rather handy. I wanted to implement this
because it's a feature i often used in mod_perl projects. Imagine an
online shop:

<Location /golfers-online>
  ...
  GuileDefine bg-color   "PapayaWhip"
  GuileDefine text-color "DarkSlateGey"
<Location>
<Location /heavy-metal/shop>
  ...
  GuileDefine bg-color   "black"
  GuileDefine text-color "orange"
<Location>

> 
> I see.  mod_guile should probably have a 'call a function per request'
> kind of model.  That is just as flexible but does not have to be slow.

Right now, i try to get my hands on the actual handler function during
configuration reading/parsing (as a side effect we can raise an error
if there's a problem with the configuration). The SCM value gets stored
in Apache's per-location configuration. Whenever a location (URL) that's
handled by mod_guile gets requested the appropriate hander function gets
appied to the request [scm_call_1(...)] (possibly after setting up 
the environment).

Thank's for your input

   Ralf Mattes

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2002-08-05 16:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-30 12:14 scm_* API question rm
2002-07-31  1:09 ` Christopher Cramer
2002-07-31 10:03   ` scm_* API extension? [was] " rm
2002-07-31 10:10     ` Marius Vollmer
2002-07-31 18:21       ` rm
2002-07-31 21:59         ` Rob Browning
2002-08-01 10:10           ` rm
2002-08-01 16:51             ` Rob Browning
2002-08-05 15:08         ` Marius Vollmer
2002-08-05 16:06           ` rm [this message]
2002-08-05 16:49             ` Marius Vollmer
2002-07-31 20:06       ` Christopher Cramer
2002-07-31 22:14         ` Rob Browning
2002-08-01  9:41         ` rm
2002-08-05 17:51           ` Marius Vollmer
2002-08-05 18:12             ` Han-Wen Nienhuys
2002-08-05 18:45               ` Rob Browning
2002-08-05 18:31             ` Rob Browning
2002-08-05 18:33             ` rm
2002-08-05 15:12         ` Marius Vollmer
2002-07-31 10:11 ` Marius Vollmer
2002-07-31 10:30   ` rm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020805160639.GA19325@www \
    --to=rm@fabula.de \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).