guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scm_* API extension? [was] scm_* API question


From: rm
Subject: Re: scm_* API extension? [was] scm_* API question
Date: Mon, 5 Aug 2002 18:06:39 +0200
User-agent: Mutt/1.3.24i

On Mon, Aug 05, 2002 at 05:08:45PM +0200, Marius Vollmer wrote:
> address@hidden 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]