On Wed, Aug 19, 2009 at 5:20 AM, Jeppe Nejsum Madsen <[email protected]>wrote:

>
> Seems I missed this response....more comments below
>
> On Wed, Aug 12, 2009 at 8:49 PM, David
> Pollak<[email protected]> wrote:
> >
> >
> > 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
>
> But the problem arise when there is no good default to apply. I.e.
> suppose the business logic was "list my items" where "my" depends on
> currentUser. If, for all intents and purposes, this list is only
> available to signed in users, it doesn't really make sense to show no
> list  or some random user's list.


In general, it's "good practice" to comment the use of "open_!" as to why
you are using it.  For example "Box tested at a level above this method" or
"no alternative, so an exception should be thrown if the box is empty"


>
>
> [...]
>
> >> 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.
>
> As noted above, I missed this post earlier and went ahead to create an
> example showing the problem. When I didn't succeed to show the error,
> I scratched my head a few times and went back to my app to see if it
> failed. Lo and behold, it worked!
>
> Thanks for the fix, sorry for the late reply :-)


No worries.


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