> Ok, now that you all have had time to play with this, please explain why this
> is less difficult and unwieldy than mod_rewrite.

Okay, that's a fair comment.  If the original goal was to make the
dispatch routes clear and free of line noise, then adding regexes to
them is probably not helpful.

> Thirdly: Links belong in my templates, not in my app, so I have no business
> knowing how to generate them.

I agree with Dan Horne's remark later in this thread.  Links are
positioned and styled and worded in the templates, but if an URL is
essentially a piece of code, why should it be constructed by the
designer?

> Quarto: If the idea behind pretty urls is hiding the implementation details,
> then the dispatcher should be decoupled from the app as much as possible too.
> It should not need to know whether the app is RoR, Struts, Catalyst, or a
> plain shell script. And we already have that in the form of mod_rewrite(*).

I think this is a noble goal.  And if we leave aside the link
generation side of things for a moment, maybe it's possible to achieve
this with mod_rewrite alone.  I'm not very familiar with mod_rewrite, so
maybe it would meet my needs.  Here's a dispatch table, using the
proposed syntax:

  'arch/:path'             => { app => 'Blog::Archive'            },
  'admin/tmpl_edit/:path'  => { app => 'Blog::Admin::Tmpl_Editor' },

  'admin/:controller/:rm'  => { prefix => 'Blog::Admin'           },
  ':controller/:rm'        => { prefix => 'Blog::'                },

This would dispatch the following example URLs as follows:

  /arch/foo/bar.html        => Blog::Arch (path = /foo/bar.html)
  /arch/other.html          => Blog::Arch (path = /other.html)
  /admin/users/edit         => Blog::Admin::Users (rm = edit)
  /admin/users/edit_process => Blog::Admin::Users (rm = edit_process)
  /comment/add              => Blog::Comment (rm = add)
  /admin/tmpl_edit/a.html   => Blog::Admin::Tmpl_Editor (path = /a.html)


How would this be done with mod_rewrite?  Without knowing too much about
rewrite, I can see a few immediate challenges:

  * how to dispatch directly to Perl C::A modules without using an
    intermediate CGI script for each app

  * how to handle capitalization of module names (tmpl_editor vs.
    Tmpl_Editor)


Finally, one of the things I do at work is share the same codebase
amongst multiple sites.  So 'Blog::Admin::Foo' might actually be
transformed into 'Site1::Blog::Admin::Foo' or 'Site9::Blog::Admin::Foo'.

These classes are generated dynamically at request time if they don't
already exist, using something like this:

   @Site1::Blog::Admin::Foo::ISA = ('Common::Blog::Admin::Foo');

This allows me to add site-specific behaviour on a case-by-case basis by
dropping in a subclass for a specific app.  But for the most part, the
app directory for most sites is empty.

I have a feeling that if I wanted to use mod_rewrite I would end up
writing a dispatch.cgi anyways, except instead of dispatching based on
the contents of PATH_INFO, it would dispatch based on the contents of
the CGI $query.


Michael


---
Michael Graham <[EMAIL PROTECTED]>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to