SiteMap, URL Rewriting, and Dispatching

30 views
Skip to first unread message

David Pollak

unread,
Mar 28, 2008, 1:48:53 PM3/28/08
to liftweb
Folks,

lift services HTTP requests in a "render pipeline".

lift is implemented as a Filter (thanks to the excellent suggestion from Viktor).

When a request comes in, any functions defined in LiftRules.early (see LiftRules.appendEarly) as executed.  This can be used to set Tomcat to UTF-8 for parameter parsing (although this is dangerous if lift is one of many Filters and the other Filters expect different behavior).

When a request comes in, the request re-writing is repeatedly applied to the request until there are no more matches in the request re-writer partial function.

The re-written request is then used to create a RequestState instance.

Next, the filter tests the request against LiftRules.isLiftRequest_? to see if there's a specific rule about the request being handled by lift.

If the request should be handled by lift, the request is passed to an instance of LiftServlet.

The request is matched against LiftRules.statelessDispatchTable and serviced if there's a match (this is useful for REST requests that are truly stateless and there's no desire to create a new Servlet Session for each request.)

All of the subsequent handlers are done inside the "S" context (thus, they have access to session state):

If the request matches LiftRules.dispatchTable, then the request is handled by dispatchTable.

If the request is a Comet request, it's handled by the Comet handler.

If the request is an Ajax request, it's handled by the Ajax handler.

Otherwise, the request is handed off the the LiftSession for further processing.

In the LiftSession, the request is tested against session specific dispatchers (see S.highlevelSessionDispatcher) and dispatched if there's a match.

Next, the request is tested against SiteMap (if SiteMap is defined).  If the page is guarded by SiteMap and the guard fails, then the appropriate response is sent to the browser.

Otherwise, the template for the incoming request is located.

First, the LiftRules.templateTable is consulted (this is a method which combines session specific template lookup with LiftRules-based template lookup.)  If the template is located, it's returned.

Otherwise, the parts of the path that start with '.', '_' or contain '-hidden' are removed and the resource is looked up in LiftSession.findAnyTemplate.

findAnyTemplate looks for a given named resource (given suffixes and locales).  If the resource cannot be located, a class and method are searched for in the "valid packages".view packages.

Once the template is located, it is processed by processSurroundAndInclude.

Questions?

Thanks,

David



--
Scala lift off unconference, May 10th 2008, San Francisco http://scalaliftoff.com
lift, the secure, simple, powerful web framework http://liftweb.net
Collaborative Task Management http://much4.us

Steve Jenson

unread,
Mar 28, 2008, 2:04:29 PM3/28/08
to lif...@googlegroups.com
On Fri, Mar 28, 2008 at 10:48 AM, David Pollak
<feeder.of...@gmail.com> wrote:

> The request is matched against LiftRules.statelessDispatchTable and serviced
> if there's a match (this is useful for REST requests that are truly
> stateless and there's no desire to create a new Servlet Session for each
> request.)

Thanks, I just closed a bug on my product with this little tip.

Steve

David Pollak

unread,
Mar 28, 2008, 2:05:53 PM3/28/08
to lif...@googlegroups.com
the needs of folks with addresses that start with 164 drive a fair amount of lift features. :-)

Steve


  

Viktor Klang

unread,
Mar 28, 2008, 2:20:28 PM3/28/08
to lif...@googlegroups.com

Not a single one.
Great description, Dave!

-V
 


Thanks,

David



--
Scala lift off unconference, May 10th 2008, San Francisco http://scalaliftoff.com
lift, the secure, simple, powerful web framework http://liftweb.net
Collaborative Task Management http://much4.us




--
Viktor Klang
Rogue Software Architect

etorreborre

unread,
Mar 29, 2008, 2:07:00 AM3/29/08
to liftweb
Thanks a lot for that description. That's really helpful!

Eric

Emmanuel Okyere

unread,
Mar 29, 2008, 2:20:50 AM3/29/08
to lif...@googlegroups.com
Thanks.

cheers,
Emmanuel.

---
(*--p->foo+1)(2,4), don't memorize precedence rules; use scheme

etorreborre

unread,
Apr 4, 2008, 2:11:04 AM4/4/08
to liftweb
Hi all,

I have added and formatted David's post on the wiki:
http://liftweb.net/index.php/How_lift_processes_HTTP_requests.

However I also left the the old version of "How lift processes HTTP
requests" because there are some implementation details which may be
worth mentioning.

Can someone, with a better knowledge that me, merge the 2 parts into
one?

Thanks,

Eric.

David Pollak

unread,
Apr 4, 2008, 8:35:25 AM4/4/08
to lif...@googlegroups.com
Thanks!

--
David Pollak
http://blog.lostlake.org

Reply all
Reply to author
Forward
0 new messages