[Lift] Passing functions as arguments

2008-10-16 Thread Tim Perrett
Hey guys, Im just implementing the IPN stuff for paypal and had a quick question. I think it would be cool to write something like: PaypalIPNHandler().onFailure(FailureHandler).onVerified(VerifiedHandler) object FailureHandler { ... } // or case class etc object VerifiedHandler { ... } Im

[Lift] Re: Passing functions as arguments

2008-10-16 Thread Marius
Hey Tim, Do default handlers actually do anything? Why not using functions or a List[(String) = Any] (Instead of String you may pass any type so the function signature is not so important). This is a paradigm used in Lift a lot. Br's, Marius On Oct 16, 1:36 pm, Tim Perrett [EMAIL PROTECTED]

[Lift] Re: Passing functions as arguments

2008-10-16 Thread Tim Perrett
Do default handlers actually do anything? Right now, no they don't, I need to noodle the design to make sure there's nothing that it would be usefull to inherit Why not using functions or a List[(String) = Any] (Instead of String you may pass any type so the function signature is not so

[Lift] Re: A stupid question

2008-10-16 Thread David Pollak
Cans inside Cans says Use a for comprehension to me: for (r - S.request; loc - r.location; link - loc.createDefaultLink) yield link.text It's a few more characters, but IMHO, more readable. On Wed, Oct 15, 2008 at 7:14 PM, Charles F. Munat [EMAIL PROTECTED] wrote: Yes, this does help a

[Lift] Re: JPA questions (was Re: SnippetFailure)

2008-10-16 Thread Tim Perrett
Wow, I've just seen this post! Thats some sweet sugar... what's the ETA on scala 2.7.2 final and when lift will be merging the master with the 2.7.2 branch? IMO, its improvements like this which make great technologies like JPA accessible - great work guys Cheers Tim On 15 Oct 2008, at

[Lift] Re: Passing functions as arguments

2008-10-16 Thread Marius
well List[(String) = Any] is a list of functions that take a String as an argument and return an Any Assume we have two functions that we want tobe called when a failure occurs def f1(s: String) = ... def f2(s: Sting) = ... PaypalIPNHandler().onFailure(f1 _ :: f2 _ :: NIL) We're passed here a

[Lift] Re: Passing functions as arguments

2008-10-16 Thread Tim Perrett
Thanks for the explanation Marius - that makes perfect sense. I'll take that advice as your right, it fits the need perfectly. If I wanted a list of functions that could have a couple of different parameters I guess it would be: List[(String,Int) = Any] Or whatever, right? Also, what is the

[Lift] Re: Passing functions as arguments

2008-10-16 Thread Marius
On Oct 16, 9:33 pm, Tim Perrett [EMAIL PROTECTED] wrote: Thanks for the explanation Marius - that makes perfect sense. I'll take that advice as your right, it fits the need perfectly. If I wanted a list of functions that could have a couple of different parameters I guess it would be:

[Lift] Weird SessionVar behavior

2008-10-16 Thread Charles F. Munat
I've got a JPA Lift site and have set up a login in which the User's id is stored in a session variable thus, as shown below. This works just fine. The user can log in and go from page to page. But after some random number of clicks, whoops! I'm suddenly no longer logged in. Hmmm. I must be

[Lift] () = xxx... but I want to use parameters

2008-10-16 Thread Charles F. Munat
In the Loc I can do: If( () = true, ) So I can do: def isLoggedIn_?() = true If(isLoggedIn_?, ) But what if I want to pass in a list of roles? def isInRole_?(List[String]) = true Now If complains because it expects a parameterless function. There is probably some easy way around this,

[Lift] Re: Weird SessionVar behavior

2008-10-16 Thread Charles F. Munat
The compiler doesn't like that at all (even after replacing : with =) error: type mismatch; [WARNING] found : Boolean(true) [WARNING] required: (Long) = ? [WARNING] def isAuthenticated_? = CurrentUserId.map(true) openOr false [WARNING] ^ Also,

[Lift] Re: Weird SessionVar behavior (working now)

2008-10-16 Thread Charles F. Munat
Ah, that's clever. I'll switch to that. I forget that if map works at all, the Can is full. I'm not sure what the problem was. I wrote some more code to fill things in while waiting for a response, and now it's running beautifully. I'm really liking JPA. It's rocking fast and very powerful.

[Lift] Re: Multiple menus and LocStuff

2008-10-16 Thread efleming969
Was anything like this every implemented? On Sep 22, 12:18 pm, David Pollak [EMAIL PROTECTED] wrote: On Sun, Sep 21, 2008 at 5:21 PM, Charles F. Munat [EMAIL PROTECTED] wrote: It would be useful to me to be able to reuse the Menu.builder function to build different menus, thus:

[Lift] Re: Multiple menus and LocStuff

2008-10-16 Thread David Pollak
On Thu, Oct 16, 2008 at 8:23 PM, efleming969 [EMAIL PROTECTED] wrote: Was anything like this every implemented? Yes. On Sep 22, 12:18 pm, David Pollak [EMAIL PROTECTED] wrote: On Sun, Sep 21, 2008 at 5:21 PM, Charles F. Munat [EMAIL PROTECTED] wrote: It would be useful to

[Lift] Re: Multiple menus and LocStuff

2008-10-16 Thread Charles F. Munat
http://groups.google.com/group/liftweb/msg/f96d5988c4a359e9?hl=en; David Pollak wrote: On Thu, Oct 16, 2008 at 8:23 PM, efleming969 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Was anything like this every implemented? Yes. On Sep 22, 12:18 pm, David Pollak

[Lift] Re: Multiple menus and LocStuff

2008-10-16 Thread efleming969
Thanks guys. Also add an entry in the FAQ section http://www.liftweb.net/index.php/FAQ On Oct 16, 11:21 pm, Charles F. Munat [EMAIL PROTECTED] wrote: http://groups.google.com/group/liftweb/msg/f96d5988c4a359e9?hl=en; David Pollak wrote: On Thu, Oct 16, 2008 at 8:23 PM, efleming969 [EMAIL

[Lift] Re: Weird SessionVar behavior

2008-10-16 Thread Derek Chen-Becker
Ah, the compiler error made me actually look at my code (doh), and here's what I really use: def isLoggedIn_? = currentUserIdVar.is.isDefined I actually have a few things defined around this: object currentUserIdVar extends SessionVar[Can[Long]](Empty) def currentUserId =