Hi, I'd like to rewrite a url like this:

/manufacturer/product

e.g.

    LiftRules.statelessRewrite.append( {
      case RewriteRequest(
        ParsePath( manufacturerName :: productName :: Nil, _, _,_), _,
_)  =>

        RewriteResponse("productView" :: Nil)
    })

But, I'd like to the ParsePath case to not 'catch' for non-existant
manufacturers, and non-existant products by the manufacturer.

So, I might do this:

    LiftRules.statelessRewrite.append( {
      case RewriteRequest(
        ParsePath( Manufacturer(manufacturer) :: Product(product) ::
Nil, _, _,_), _, _)  =>

        RewriteResponse("productView" :: Nil)
    })

Where Manufacturer and Product objects provide an extractor which does
a lookup.

However, the product lookup depends on the manufacturer.. is there a
way to handle that?

ideas:
1. use an if guard

      case RewriteRequest(
        ParsePath( Manufacturer(manufacturer) :: productName :: Nil,
_, _,_), _, _)  if manufacturer.contains(productName) =>
          val product = manufacturer.getProduct(productName)

sucks because it looks up the product twice.

2. some time of nested case?

      case RewriteRequest(
        ParsePath( Manufacturer(manufacturer) :: Product(manufacturer,
product) :: Nil, _, _,_), _, _)  =>

obviously doesn't work..

any suggestions welcome, thanks!

- Alex

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