Some answers inline:

On Nov 10, 2009, at 6:05 PM, Strom wrote:
> Questions
> 1. I see "unapply" it in the Req object's methods list in the API, but
> I have NO idea what it's doing. Lift book has 1 sentence about it, but
> I'm still lost.

unapply is part of scala proper, not lift particularly. It is the  
converse of apply, and is used in pattern matching:

class MyMatchableObject(val value: Int)
object MyMatchableObject {
     def unapply(o: MyMatchableObject): Option[Int] = Some(o.value)
}

val foo = new MyMatchableObject(1)

foo match { case MyMatchableObject(value) => ... } // calls  
MyMatchableObject.unapply to yield value

> 2. What's the difference between DispatchPF and dispatch.append? I see
> no documentation on what DispatchPF is, but from reading the API it
> sounds like some sort of member object or something to be associated
> with custom dispatches.

DispatchPF is a type alias. vscaladoc is pretty bad about showing  
inner types, so here's its definition from LiftRules.scala:

   type DispatchPF = PartialFunction[Req, () => Box[LiftResponse]];

That is, a dispatching partial function is a partial function taking a  
Req and yielding a function that generates a response. Partial  
functions, in case you aren't already aware are extensions of simple  
functions (Function1) except that in addition to application, you can  
test whether or not the function is defined for a particular argument.

> 3. What is the "r @ Req" syntax? I'm having a hard time searching for
> the syntax on a web search engine. Is it specific to Lift, or is it
> something in Scala?

It's scala -- this captures the req itself as the variable "r" -- that  
is, you can refer to "r" in the case statement and it'll be the whole  
Req, not some of Req's arguments.

> 4. For the "servImage" method, what is the effect of the HTTP 304 code
> if the image hasn't been modified? I looked it up and it's "Error Not
> Modified". Will this image generation fail?

This indicates to the browser that the image has not changed since the  
last time it asked, as an optimization. The browser will sometimes  
send a header "If-Modified-Since" which says basically "give me this  
resource if it has changed since this date when I last got it, else  
give me 304 and I'll use what I already have". I assume the test on If- 
Modified-Since is wrapped up in Req.testIfModifiedSince.

-Ross


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

Reply via email to