lua-users home
lua-l archive

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


Hi,

Although a bit late in the thread I'd like to try contributing to it, long
response ahead...

> > Javier Guerra wrote:
> > well, i've just coded cookies and session modules for Xavante, to be
used from
> > handlers, without CGILua.
>
> William Trenker wrote:
> Hmm.  I'm surprised.  Why not refactor CGILua to expose more of its
> functionality in its API and use that within Xavante?  Why rewrite
> code that's already available?

Basically because CGILua components aren't (currently) easily reusable. We
are working on this refactoring and if it works as expected, you both should
be able to reuse most of its code.

The refactoring would separate more clearly CGILua modules as:

- URL processing (parsing and generation)
- Upload, Form and Query string processing
- Cookies processing
- Session processing (and persistence)
- Lua Pages parsing (this is already separated as lp.lua)
- SAPI dependent functions

> So xavante is evolving from a web server with built-in cgi scripting
> support towards a web applications framework?  That sounds very
> promising.

This is one way to look at it, another would be that the framework would use
modules such as Javier's and some other that could also help solving one of
your points:

> ...(Here's another way of looking at what I'm trying to implement: I see a
master
> script as a dispatcher with several, small .lp CGILua scripts as user
> input forms.  The master script coordinates everything including using
> CGILua sessions for state (and maybe even an sqlite database for
> long-term data).  The master script is the brains and the .lp scripts
> are just for html forms as a simple GUI for user input.  In otherwords
> I don't envision using any .lua CGI scripts for coding, just this
> single master script.)

This is precisely what Orbit is doing now. Orbit is a MVC framework that
runs over CGILua and uses a metaphor very close to the one you've mentioned
(think Ruby on Rail if you prefer). The only reason Orbit has not gone
public yet is that we are waiting for this new vision of CGILua and the
platform itself to settle down.

Basically, Orbit allows the mapping of an URL to a Lua module (the so called
controller) that is responsible for the logic behind the application and the
choice of views (.lp files) to be used in the responses.

> How would you write a Xavante/config.lua simplerule to direct
> everything to a single cgilua script?

Orbit implements this over CGILua by simply adding an "open" function to it.
This function is called before any processing and is responsible for the
creation of the controller environment. Once in the controller the execution
can skip to different LP files, so in your case the controller could detect
that the user wasn't logged and simply make a redirect to a login.lp page.

An interesting point here is that both Orbit and Javier's work aim at a
similar problem, but offers very different views of the solution. If
everything goes right, we will be able to choose the best of them for each
case.

Let see what comes out of all this. :o)

André