On Fri, May 7, 2010 at 2:33 PM, Kris Kowal <
kris....@cixar.com> wrote:
> JSGI provides the scriptName and pathInfo which are useful for routing
> because the scriptName can serve as the portion of the path that has
> been routed, and the pathInfo can stand for the portion of the path
> that remains.
>
> I propose that the next system module specification divide system.args
> into a system.command array and a system.args array. The present
> specification calls for these arguments to be combined into a single
> args array, as provided to main() by the C runtime, but this is
> largely inadequate since our "main" functions often undergo some
> "routing".
Personally I think it is a poor choice to work with system.args at all
if you are doing web work. If you're writing to the JSGI
specification, then what is preventing the programmer from making sure
system.args looks however they want it to? The state of web
development is hardly concerned with command-line arguments at this
point.
The days of CGI being the latest thing were largely about reflecting
the filesystem and remote command execution over HTTP. To this end
things like argv have been reflected perfectly, and if what you want
is NOT proper reflection of C programming, then you should really just
man up and take on a higher level programming abstraction altogether.
Worth noting: the zeroth element of the "argv" vector can really only
be interpreted as the program name by convention: the POSIX APIs that
execute a new process, initialize everything and then enter main() do
not place any stipulations on what the zeroth argument can be. For
this reason as well, it should not be hard for JSGI programmers to
manipulate the zeroth argument to their liking without having to
divide argv into more symbolic names.
The whole pathInfo thing as a user-interface abstraction (if a URI is
a user interface) can sort of be compared to a user-land filesystem,
and this plays well with reflection/remote-command-execution style of
resource resolution when trying to design a ReSTful interface, but if
your emphasis is on ReST, why encumber yourself by tying yourself to a
real filesystem to begin with? Just look at stuff like Rails or
Django, they threw that baby out with the bathwater, and it pays off.
They're both well encapsulated and you don't have to worry about the
state of the filesystem really playing a very important role
(excepting initialization time when all your scripts are loaded into
mod_python or something) in how your web app behaves.
That's my 2 cents anyhow :)
Here's an example of what URL resolution looks like in Django:
urlpatterns = patterns('',
(r'^articles/2003/$', 'news.views.special_case_2003'),
(r'^articles/(\d{4})/$', 'news.views.year_archive'),
(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
(r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
)
Each regular expression is tested against the resource (the part of
the URL following the hostname) being requested and the view function
that is used, for convenience, can be specified as a string or as a
reference to the function itself.
It's important that JSGI offer a strong foundation for those who need
to work with a CGI environment, but I think trying to move JSGI up and
away from its roots is just ignoring the fact that there are so much
better abstractions to look forward to if you just stop building your
apps to anything CGI-like and build on top of a higher level
framework.
On Sat, May 8, 2010 at 3:39 AM, Christoph Dorn
<
christ...@christophdorn.com> wrote:
> I have been thinking of commands with arguments in terms of REST URIs with
> parameters for a while. They map well.
>
> I would like to see a reflective + interactive REST interface implemented as
> JSGI middleware for commands (narwhal's args parser) at some point. It could
> form the basis of a live command documentation and test runner tool.
Could you elaborate on this a bit?
--
http://codebad.com/