On Mon, Aug 10, 2009 at 9:07 AM, Jeppe Nejsum Madsen <[email protected]>wrote:

>
> David Pollak <[email protected]> writes:
>
> > (1) Don't use open_! unless you have a very, very, very good reason to do
> > so.  It defeats the purpose of Box.
>
> I'm aware of this. But in this situation, most Locs are protected, ie the
> user is always logged in, so the only alternatives I see are:
>
> 1) wrap the code in map or something similar which will then return
> Empty if no user is found. But this is dangerous, giving the user the
> impression that no data is found when in fact this is a coding error.


User.currentUserId.map(... business logic here) openOr defaultValue


>
>
> 2) Redirect to a nice error page if this code is called with no user
> active. This is of course the nice solution, but we have more pressing
> needs atm :-)
>
> But maybe I've missed something obvious and there are better ways to
> handle this?


See the above code.

>
>
> > (2) If you have a particular question/example of what you want to do (a
> > complete, runnable example), I can work out a pattern for you.
>
> The question comes down to: Why is User.currentUserId Empty when
> findForParam is called?


Because this method is called during the re-writing phase.

I've updated Lift to make the session available during the re-writing phase
if there is a session (a new session will not be created) to deal with this
situation.


> The user is signed in, since
> findForListParams works fine.
>
> If I remember the previous thread correctly, there is some tension
> between request rewriting (as is done in CRUDify when edit/delete
> actions are called ) and the session/request var initialization. Wonder
> if I'm seeing more of the same here?
>
> I might be able to put together an example, but that will have to wait a
> few days (lots of stuff to catch up with after vacation :-)
>
> /Jeppe
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
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