David Pollak <[email protected]> writes:

[...]

> Yes.  The rewrite phase takes place very early in the HTTP request/response
> cycle.  It takes place before the statelessDispatch call.  The
> statelessDispatch call is very important for REST style APIs as it does
> *not* cause the creation of a session, thus for lots of API calls, we don't
> have a session created for each call.
>
> The rewrite phase has to come before the statelessDispatch phase because the
> request has to be properly rewritten before being pattern matched against
> the partial functions that define the statelessDispatch
>
> Based on some of your prior needs, I've made the session available during
> the rewrite phase, but it's only if the session actually exists (basically,
> the request is checked for a session, but the request is not told "create
> one if it doesn't already exists".

I sort of guessed it had to do with this. I find rewriting really useful
to write apps that need to extract info from the URL in a type-safe way
before continuing the processing.

I seem to run into a number of issues with this approach (some which
you've fixed, thanks!), so was wondering if perhaps I'm misusing
rewriting and there are better ways to approach this?

A few thoughts: 

- Is it possible to create a session manually in the rewrite phase? If
  no, maybe a LiftRule PF that could be used to force session creation
  for certain requests? 

- Would it be possible to detect (at least in Dev mode) some of these
  misuses (i.e. using a SessionVar with no session) and emit a warning?

> So, the first request from a browser does not have a session and thus does
> not have session vars.  Is there a way you can use RequestVars here?

I guess I can hack something together for this case, but I need to think
a little more to make sure it fits cleanly with the rest. 

If I just redirect back to the same page, will this trigger the session
creation or does the redirect happen before the session is created?

It's a multipage workflow, so SessionVars seem like the easy way out
:-)

/Jeppe


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to