[Lift] Re: Using Roles and LIftRules.authentication

2009-09-08 Thread marius d.



On Sep 8, 1:18 am, glenn gl...@exmbly.com wrote:
 Marius,

 Please bear with me. I'm a little slow in following the logic here.

Don't worry glen.


 I understand I can protect the resource as you suggest from all
 but users with admin roles, using the LocParam,

 HttpAuthProtected(() = Full(AuthRole(admin) .

 Now, when I click on the link, if no user is logged in, the system
 asks for a username and password to connect, but that's a user
 on the host. not an application user.

Not necessarily. It is any type of user. In your authentication
function you can go in DB and validate the receiving credentials as
application user.

 Somewhere, I need to assign the
 currently logged in user the AuthRole(admin) needed to access
 the resource.

Correct. And you dothis by setting userRoles RequestVar.


 Seems to me I need code like this to run someplace:

 def authorize(roleName:String): Box[Role] = {
       object userRoles extends RequestVar[Role](null)

       val credentials : (String,String) = User.currentUser match {
           case Full(u) = (u.email.is, u.password.is)
          case Empty = (null, null)
       }

       User.isa_?(roleName) match {
         case true = {
             LiftRules.authentication = HttpBasicAuthentication(lift)
 {
                 case (credentials._1, credentials._2, req) =
                         println(John is authenticated!)
                         userRoles(_root_.net.liftweb.http.auth.AuthRole
 (roleName))
                         true
             }
             Full(new _root_.net.liftweb.http.auth.Role{
                         def name = roleName})
             }
       case false = Empty
     }
  }

 Can't be in Boot,

No you do not. Lift takes care of the roles matching for you. You
don't need to manually test if a user is-an admin or some other role
in order to access that resource. Please keep in mind that is just for
accessing resources (URI-s) if you need to do more complex logic in
your code and see if the user is an admin or having some other Role
that you'd probably need to save the Role into a SessionVar or into
your User object.

All I want here is to explain how HTTP based authentication and roles
based authorization works. I am definitely not claiming that this is
enough for all applications as currently we don't have HTTP based
authentication with forms for example ... but I think we should add
that as well.


 Glenn

 On Sep 7, 1:36 pm, marius d. marius.dan...@gmail.com wrote:

  On Sep 7, 10:53 pm, glenn gl...@exmbly.com wrote:

   Marius,

   In practical terms, if I am already using an If LocParam, as in the
   following:

   If(() = User.isa_?(admin), S.?(not_authorized))

   what does adding

   HttpAuthProtected(() = User.authorize(admin)) to the Loc do?

  It sais that this Loc is protected by the returned Role. Thus to
  access this after passing the authentication the Role specified in the
  authentication function (by setting userRoles) must be the same as or
  a child of the Role the is protecting the Loc.

   Here, I've had to define User.authorize to make things work, as:

    def authorize(roleName:String): Box[Role] =  {
         val credentials : (String,String) = User.currentUser match {
             case Full(u) = (u.email.is, u.password.is)
             case Empty = (null, null)
         }

         User.isa_?(roleName) match {
           case true = {
               LiftRules.httpAuthProtectedResource.append {
                   case (ParsePath(listContents :: _, _, _, _)) = Full
   (AuthRole(admin))
               }

  Why do you need to use httpAuthProtectedResource if you' using
  HttpAuthProtected LocParam ?

               LiftRules.authentication = HttpBasicAuthentication(lift)
   {
                   case (credentials._1, credentials._2, req) =
                           AuthRole(roleName)
                           true
               }
               Full(new _root_.net.liftweb.http.auth.Role{
                           def name = roleName})
               }
         case false = Empty
       }

   Rather verbose, don't you think.

  Your code is verbose but I don't see the justification for this
  verbosity:

     LiftRules.authentication = HttpBasicAuthentication(lift) {
            case (username, password, req) = {
               // Do you authentication in DB or whatever and you
  determined that this is an admin user
               userRoles(AuthRole(admin)) // userRoles needs to be
  set. It is a RquestVar.
               true
            }

  In Boot you have:

  Menu(Loc(listContents, List(listContents), listContents,
  HttpAuthProtected(() = Full(AuthRole(admin)

  When you use HttpAuthProtected LocParam Lift appends a function to
  LiftRules.httpAuthProtectedResource so you don't need to do it
  manually.

  This authorixation scheme is only about protecting resource by roles
  and you do this almost declaratively and for authentication I thing
  the things are pretty straight forward. One a user is 

[Lift] Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread jon

Hi,

I've noticed that some special char xml tags are being interpreted by
lift rather than passing through to the browser.

source code in my template:
div
  amp;
  copy;
  quot;
  raquo;
  lt;
  gt;
/div

result from curl http://localhost:8080/
div
  amp;
  ©
  quot;
  »
  lt;
  gt;
/div

The rendered characters are problematic in IE7.  A fix or workaround
would be much appreciated.

Thanks,

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



[Lift] Re: Crazy idea for lift's mega proto user: admin panel.

2009-09-08 Thread marius d.

Nice thoughts but personally I don't think this should be part of Lift
core framework. However an admin panel could be provided via a lift
widget and would be pretty interesting thing to have.

Br's,
Marius

On Sep 8, 2:16 am, DFectuoso santiago1...@gmail.com wrote:
 I was thinking about how wonderful it is to get a login/register/
 forgotPassword functionality with mega proto user and how it could
 become even better with a good tool for creating an admin section.

 I'm just adding the idea here so maybe if other people find value it
 could be considered for development(or probably it already is, i don't
 know).

 Adding an admin panel to mega proto user where the moderators/admins
 could change some options(like the way a user is validated, if gzip is
 enabled, etc) would be great for the end users of our apps, since it
 would be easier to change and maintain the site.

 Being a administrator at a Invision Power Board forum and having a
 couple of wordpress blogs, i see a lot of potential on this as a admin/
 dev tool! Listing some of the things that i can imagine in this panel
 are:

 -phpMyAdmin-type of DB admin(browse your data easily, remove/change/
 add stuff to it without having to create a CRUD for each thing)
 -execute queries
 -List the actor(and comet actors) with possibility to kill/reset them
 -Memory use analysis.
 -Statistics of use(hits, referrals, etc)
 -Options (any object/class/trait could have a val foo =
 adminPanel.option(category,optionName,description,defaultValue,
 otherValues[]) and be included in this place, of course the categories
 could create different menus.
 -User management(ban, authorize, give admin-rights).
 -Simple to-do list that all admins can edit
 -Log of errors/warnings/exceptions
 -Css editor
 -Easy-logo changer
 -File Manager(upload your images and stuff here)
 -String editor (you can change any default string from the
 megaprotouser forms and the index?)

 Also, a very polemic(and i think bad idea, but its common to see this
 in admin panels):
 -Installable plug-ins for this panel

 I know this seems like one step away from being a full blown CMS,
 forum, blog, etc. But if its extensible while we are building an app,
 it will be very useful for the different moments of development and
 use.

 Of course i don't expect any of this to be done right now, i
 understand there are a couple of integrations and bigger things going
 on but i really wanted to brainstorm on this with you guys!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: rewrite problem

2009-09-08 Thread Xavi Ramirez

That's because the url post/show is being intercepted by the same
rewrite rule that matches post/id urls.  To get around this, try
adding an if statement to your rewrite rule:

LiftRules.rewrite.append {
  case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
 if (id != show) =
RewriteResponse(List(post,show), Map(id-urlDecode(id)))

Hope this helps!

~Xavi

On Tue, Sep 8, 2009 at 12:12 AM, night_stalkerusur...@gmail.com wrote:

 I want to make RESTful urls (not REST API), for example:

  /post/123 is mapped to post/show.html with param id=123

 but the following rewrite rule seems recursive

    LiftRules.rewrite.append {
      case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
 =
        RewriteResponse(List(post,show), Map(id-urlDecode(id)))
    }

 and loops forever ...

 


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



[Lift] Re: solution to jetty:run locks files on windows problem

2009-09-08 Thread David Pollak
On Mon, Sep 7, 2009 at 3:05 PM, Timothy Perrett timo...@getintheloop.euwrote:


 Thanks Jon, thats super.


Super +1



 Cheers, Tim

 On Sep 7, 7:25 pm, jon jonhoff...@gmail.com wrote:
  Done:
 http://wiki.github.com/dpp/liftweb/how-to-fix-file-locking-problem-wi...
 
  On Sep 7, 1:49 pm, Timothy Perrett timo...@getintheloop.eu wrote:
 
 
 
   Jon, good stuff - perhaps write this up on the wiki:
 
  http://wiki.github.com/dpp/liftweb
 
   Cheers, Tim
 
   On Sep 7, 6:09 pm, jon jonhoff...@gmail.com wrote:
 
Hi all,
 
If you happen to be developing under windows you will notice that mvn
jetty:run locks files and prevents editing while the server is
running.   Super annoying. The problem is that jetty memory maps
 files
by default and windows locks memory mapped files.  The solution is to
turn off the mapped files switch in jetty.  Instructions are here:
 
When using jetty:run, CSS and JavaScript files are locked - how can
 I
fix this?http://appfuse.org/display/APF/FAQ
 



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



[Lift] Re: Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread David Pollak
On Mon, Sep 7, 2009 at 11:38 PM, jon jonhoff...@gmail.com wrote:


 Hi,

 I've noticed that some special char xml tags are being interpreted by
 lift rather than passing through to the browser.

 source code in my template:
 div
  amp;
  copy;
  quot;
  raquo;
  lt;
  gt;
 /div

 result from curl http://localhost:8080/
div
  amp;
  ©
  quot;
  »
  lt;
  gt;
/div

 The rendered characters are problematic in IE7.


Why?


  A fix or workaround
 would be much appreciated.


The raw XHTML is valid.  Lift is yielding non-ASCII characters, but they are
UTF-8 encoded and should be correctly rendered on all browsers.  I have
never seen a problem with IE6 or IE7 (I have not tested in IE8)



 Thanks,

 - Jon
 



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



[Lift] Re: Where did AnyVar go ?

2009-09-08 Thread David Pollak
Sorry.  I did an end of friday commit and forgot to add some untracked
files.
I moved a bunch of stuff from http to util so that that stuff could be used
more broadly.

If I've got bandwidth today, I'll write up the changes and how they can help
in a variety of situations.

On Mon, Sep 7, 2009 at 9:44 AM, Ross Mellgren dri...@gmail.com wrote:



 http://github.com/dpp/liftweb/commit/4dce48dfe938b92ae2ed50445dab1f4c2d104a4f

 Looks like DPP removed it, and based on the surrounding commit, maybe
 the intention was to put it in util somewhere, though the commit did
 not add it back anywhere.

 -Ross

 On Sep 7, 2009, at 9:21 AM, marius d. wrote:

 
  Same question for Injector, SimpleInjector etc.
 
  Br's,
  Marius
 
  On Sep 7, 4:08 pm, Marius marius.dan...@gmail.com wrote:
  Hi,
 
  I just did a pull and get a bunch of compile time errors obviously.
  Seems like someone kidnapped AnyVar?
 
  Br's,
  Marius
  


 



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



[Lift] Re: vs amp; within attributes in templates

2009-09-08 Thread David Pollak
On Mon, Sep 7, 2009 at 9:17 PM, Grant Wood smackt...@gmail.com wrote:


 Hello Lifters,

 If I create a template with the following:

 lift:surround with=page_master at=content
  a class=thickbox href=/media/?height=440width=640Foo/a
  lift:bind name=content /
 /lift:surround

 I will be served an empty page, containing none of my snippets, and
 throwing or logging no errors.  By empty I mean, the page contains
 only the outermost xhtml which Lift wraps a page with (liftajax, xml
 declaration, etc.) but nothing from any of my own templates or
 snippets.

 Very odd.

 On a hunch, I escaped the  to amp; and suddenly the page appeared
 fully rendered. i.e.:
 a class=thickbox href=/media/index.xml?
 height=440amp;width=640Foo/a

 My first concern is that I should not have had to escape the  at all
 in an attribute.  This is a valid character in any XML attribute.


 is not a valid character in an XML attribute.  The  character must be
escaped as amp;



 Second, if there is some reasonable lift-specific reason that I need
 to escape  in attributes, then shouldn't Lift decode each amp;
 back to  inside attributes upon page rendering?  ( and if that's
 the case, then couldn't that same test be used to prevent the need to
 escape the  in the first place?)


Lift yields valid XHTML to the browser.  amp; is valid xhtml, a href='
http://something?height=440width=660' is *not* valid XHTML and will be
rejected by your browser.



 I am using lift 1.1-SNAPSHOT

 Thanks for your comments.

 



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



[Lift] setting user-agent header

2009-09-08 Thread jack

Has anyone used dispatch from databinder.net?  Its an http library in
Scala.
I do not know how to set the User-Agent header.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: Using Roles and LIftRules.authentication

2009-09-08 Thread glenn

Marius,

With your help, I think I'm getting closer to understanding what is
needed
here.

One thing though, is that I believe I do need to manually check if the
user has the
appropriate role (in the DB) before I can set userRoles RequestVar.
See, in my application,
I have no way of knowing in advance if a logged-in user is authorized
to access
a particular resource. I'm trying to accomplish that programatically.
And, don't forget, roles
can be changed at any time in the application.  In other words, I
can't just assume it in my
authentication function and make the assignment there.

Does that make sense?  This is not to say that I can't work
tangentially to Http basic authentication
in Lift and create my own, just that I'm trying to incorporate the
work already done so I don't have to.

Glenn

On Sep 7, 11:24 pm, marius d. marius.dan...@gmail.com wrote:
 On Sep 8, 1:18 am, glenn gl...@exmbly.com wrote:

  Marius,

  Please bear with me. I'm a little slow in following the logic here.

 Don't worry glen.



  I understand I can protect the resource as you suggest from all
  but users with admin roles, using the LocParam,

  HttpAuthProtected(() = Full(AuthRole(admin) .

  Now, when I click on the link, if no user is logged in, the system
  asks for a username and password to connect, but that's a user
  on the host. not an application user.

 Not necessarily. It is any type of user. In your authentication
 function you can go in DB and validate the receiving credentials as
 application user.

  Somewhere, I need to assign the
  currently logged in user the AuthRole(admin) needed to access
  the resource.

 Correct. And you dothis by setting userRoles RequestVar.





  Seems to me I need code like this to run someplace:

  def authorize(roleName:String): Box[Role] = {
        object userRoles extends RequestVar[Role](null)

        val credentials : (String,String) = User.currentUser match {
            case Full(u) = (u.email.is, u.password.is)
           case Empty = (null, null)
        }

        User.isa_?(roleName) match {
          case true = {
              LiftRules.authentication = HttpBasicAuthentication(lift)
  {
                  case (credentials._1, credentials._2, req) =
                          println(John is authenticated!)
                          userRoles(_root_.net.liftweb.http.auth.AuthRole
  (roleName))
                          true
              }
              Full(new _root_.net.liftweb.http.auth.Role{
                          def name = roleName})
              }
        case false = Empty
      }
   }

  Can't be in Boot,

 No you do not. Lift takes care of the roles matching for you. You
 don't need to manually test if a user is-an admin or some other role
 in order to access that resource. Please keep in mind that is just for
 accessing resources (URI-s) if you need to do more complex logic in
 your code and see if the user is an admin or having some other Role
 that you'd probably need to save the Role into a SessionVar or into
 your User object.

 All I want here is to explain how HTTP based authentication and roles
 based authorization works. I am definitely not claiming that this is
 enough for all applications as currently we don't have HTTP based
 authentication with forms for example ... but I think we should add
 that as well.



  Glenn

  On Sep 7, 1:36 pm, marius d. marius.dan...@gmail.com wrote:

   On Sep 7, 10:53 pm, glenn gl...@exmbly.com wrote:

Marius,

In practical terms, if I am already using an If LocParam, as in the
following:

If(() = User.isa_?(admin), S.?(not_authorized))

what does adding

HttpAuthProtected(() = User.authorize(admin)) to the Loc do?

   It sais that this Loc is protected by the returned Role. Thus to
   access this after passing the authentication the Role specified in the
   authentication function (by setting userRoles) must be the same as or
   a child of the Role the is protecting the Loc.

Here, I've had to define User.authorize to make things work, as:

 def authorize(roleName:String): Box[Role] =  {
      val credentials : (String,String) = User.currentUser match {
          case Full(u) = (u.email.is, u.password.is)
          case Empty = (null, null)
      }

      User.isa_?(roleName) match {
        case true = {
            LiftRules.httpAuthProtectedResource.append {
                case (ParsePath(listContents :: _, _, _, _)) = Full
(AuthRole(admin))
            }

   Why do you need to use httpAuthProtectedResource if you' using
   HttpAuthProtected LocParam ?

            LiftRules.authentication = HttpBasicAuthentication(lift)
{
                case (credentials._1, credentials._2, req) =
                        AuthRole(roleName)
                        true
            }
            Full(new _root_.net.liftweb.http.auth.Role{
                        def name = roleName})
            }
      case 

[Lift] Re: rewrite problem

2009-09-08 Thread night_stalker

Cool, thank you very much!

On Sep 8, 8:56 pm, Xavi Ramirez xavi@gmail.com wrote:
 That's because the url post/show is being intercepted by the same
 rewrite rule that matches post/id urls.  To get around this, try
 adding an if statement to your rewrite rule:

 LiftRules.rewrite.append {
   case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
      if (id != show) =
         RewriteResponse(List(post,show), Map(id-urlDecode(id)))

 Hope this helps!

 ~Xavi

 On Tue, Sep 8, 2009 at 12:12 AM, night_stalkerusur...@gmail.com wrote:

  I want to make RESTful urls (not REST API), for example:

   /post/123 is mapped to post/show.html with param id=123

  but the following rewrite rule seems recursive

     LiftRules.rewrite.append {
       case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
  =
         RewriteResponse(List(post,show), Map(id-urlDecode(id)))
     }

  and loops forever ...

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



[Lift] setting user-agent header with Databinder

2009-09-08 Thread jack

Please forgive me for including so much code but I have an important
demo fast approaching and I'm kind of in a bind. I am using
Databinders Dispatch http library which is a wrapper around Javas
HttpClient library. I have included the Http class below. Does anyone
see how to set the user-agent header. Once again I apologize and would
be much obliged for any help.

import collection.Map
import collection.immutable.{Map = IMap}
import util.DynamicVariable
import java.io.
{InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
import java.net.URI
import java.util.zip.GZIPInputStream

import org.apache.http._
import org.apache.http.client._
import org.apache.http.impl.client.{DefaultHttpClient,
BasicCredentialsProvider}
import org.apache.http.client.methods._
import org.apache.http.client.entity.UrlEncodedFormEntity
import org.apache.http.client.utils.URLEncodedUtils

import org.apache.http.entity.StringEntity
import org.apache.http.message.BasicNameValuePair
import org.apache.http.protocol.HTTP.UTF_8
import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
import org.apache.http.util.EntityUtils
import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
Credentials}

case class StatusCode(code: Int, contents:String)
  extends Exception(Exceptional resoponse code:  + code + \n +
contents)

/** Http access point. Standard instances to be used by a single
thread. */
class Http {
  val credentials = new DynamicVariable[Option[(AuthScope,
Credentials)]](None)
  val client = new ConfiguredHttpClient

  def credentialsProvider = new BasicCredentialsProvider {
override def getCredentials(scope: AuthScope) = null
  }

/**  /** Info Logger for this instance, default returns Connfiggy if
on classpath else console logger. */
  lazy val log: Logger = try {
new Logger {
  val delegate = net.lag.logging.Logger.get
  def info(msg: String, items: Any*) { delegate.info(msg, items:
_*) }
}
  } catch {
case e: NoClassDefFoundError = new Logger {
  def info(msg: String, items: Any*) {
println(INF: [console logger] dispatch:  + msg.format(items:
_*))
  }
}
  }
  **/
  /** Execute method for the given host, with logging. */
  def execute(host: HttpHost, req: HttpUriRequest) = {
//log.info(%s %s%s, req.getMethod, host, req.getURI)
client.execute(host, req)
  }
  /** Execute for given optional parametrs, with logging. Creates
local scope for credentials. */
  val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
= HttpResponse = {
case (Some(host), Some(creds), req) =
  client.credentials.withValue(Some((new AuthScope
(host.getHostName, host.getPort), creds)))(execute(host, req))
case (None, Some(creds), _) = error(Credentials specified
without explicit host)
case (Some(host), _, req) = execute(host, req)
case (_, _, req) =
  //log.info(%s %s, req.getMethod, req.getURI)
  client.execute(req)
  }
  /** Execute full request-response handler. */
  def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
  /** Execute request and handle response codes, response, and entity
in block */
  def x [T](req: Request)(block: Handler.F[T]) = {
val res = execute(req.host, req.creds, req.req)
val ent = res.getEntity match {
  case null = None
  case ent = Some(ent)
}
try { block(res.getStatusLine.getStatusCode, res, ent) }
finally { ent foreach (_.consumeContent) }
  }
  /** Apply Response Handler if reponse code returns true from chk. */
  def when[T](chk: Int = Boolean)(hand: Handler[T]) = x(hand.request)
{
case (code, res, ent) if chk(code) = hand.block(code, res, ent)
case (code, _, Some(ent)) = throw StatusCode(code,
EntityUtils.toString(ent, UTF_8))
case (code, _, _) = throw StatusCode(code, [no entity])
  }
  /** Apply a custom block in addition to predefined response Handler.
*/
  def also[A,B](hand: Handler[B])(block: Handler.F[A]) =
x(hand.request) { (code, res, ent) = ( hand.block(code, res,
ent), block(code, res, ent) ) }

  /** Apply handler block when response code is 200 - 204 */
  def apply[T](hand: Handler[T]) = (this when {code = (200 to 204)
contains code})(hand)
}

/** Nil request, useful to kick off a descriptors that don't have a
factory. */
object /\ extends Request(None, None, Nil)

/* Factory for requests from a host */
object :/ {
  def apply(hostname: String, port: Int): Request =
new Request(Some(new HttpHost(hostname, port)), None, Nil)

  def apply(hostname: String): Request = new Request(Some(new HttpHost
(hostname)), None, Nil)
}

/** Factory for requests from a directory, prepends '/'. */
object / {
  def apply(path: String) = /\ / path
}

object Request {
  /** Request transformer */
  type Xf = HttpRequestBase = HttpRequestBase
  /** Updates the request URI with the given string-to-string
function. (mutates request) */
  def uri_xf(sxf: String = String)(req: HttpRequestBase) = {

[Lift] Re: Using Roles and LIftRules.authentication

2009-09-08 Thread marius d.



On Sep 8, 7:00 pm, glenn gl...@exmbly.com wrote:
 Marius,

 I guess there is little more to be said on this issue. Keep in mind
 that
 in many real-world applications, dynamically assigned user roles are a
 requirement. And it's possible for users to have multiple roles, each
 in a different role hierarchy, in the same application.

Well Lift Roles are build on hierarchical model.


 Inevitably, I will have to implement my own, perhaps using
 JaaS or one of its variants. If you have any thoughts on that issue,
 I'd like to hear them.

I kind of doubt that JAAS will take you farther then Lift HTTP auth
support.


 Thanks,

 Glenn

 On Sep 8, 8:40 am, marius d. marius.dan...@gmail.com wrote:

  On Sep 8, 6:12 pm, glenn gl...@exmbly.com wrote:

   Marius,

   With your help, I think I'm getting closer to understanding what is
   needed
   here.

   One thing though, is that I believe I do need to manually check if the
   user has the
   appropriate role (in the DB) before I can set userRoles RequestVar.
   See, in my application,
   I have no way of knowing in advance if a logged-in user is authorized
   to access
   a particular resource. I'm trying to accomplish that programatically.

  Well if when authenticating a user (LiftRules.authentication) you
  can't determine the Role, then this mechanism probably won't help you
  and you need to build your own.

   And, don't forget, roles
   can be changed at any time in the application.

  I assume that a super-admin user would be able to change roles for
  other users right? ... If so you just need to update data in your DB
  for say user X. So when User X authenticates you'll get the new role
  assigned. But maybe this is not how your app is designed to work.

   In other words, I
   can't just assume it in my
   authentication function and make the assignment there.

   Does that make sense?  This is not to say that I can't work
   tangentially to Http basic authentication
   in Lift and create my own, just that I'm trying to incorporate the
   work already done so I don't have to.

  Lift's HTTP authentication and authorization is built on very simple
  principles such as:

  1. In the authentication function you typically know the role for that
  user.
  2. Resources (URI's essentially) are protected by hierarchically
  structured roles that are matched with the role determined by the
  authentication function.

   Glenn

   On Sep 7, 11:24 pm, marius d. marius.dan...@gmail.com wrote:

On Sep 8, 1:18 am, glenn gl...@exmbly.com wrote:

 Marius,

 Please bear with me. I'm a little slow in following the logic here.

Don't worry glen.

 I understand I can protect the resource as you suggest from all
 but users with admin roles, using the LocParam,

 HttpAuthProtected(() = Full(AuthRole(admin) .

 Now, when I click on the link, if no user is logged in, the system
 asks for a username and password to connect, but that's a user
 on the host. not an application user.

Not necessarily. It is any type of user. In your authentication
function you can go in DB and validate the receiving credentials as
application user.

 Somewhere, I need to assign the
 currently logged in user the AuthRole(admin) needed to access
 the resource.

Correct. And you dothis by setting userRoles RequestVar.

 Seems to me I need code like this to run someplace:

 def authorize(roleName:String): Box[Role] = {
       object userRoles extends RequestVar[Role](null)

       val credentials : (String,String) = User.currentUser match {
           case Full(u) = (u.email.is, u.password.is)
          case Empty = (null, null)
       }

       User.isa_?(roleName) match {
         case true = {
             LiftRules.authentication = HttpBasicAuthentication(lift)
 {
                 case (credentials._1, credentials._2, req) =
                         println(John is authenticated!)
                         
 userRoles(_root_.net.liftweb.http.auth.AuthRole
 (roleName))
                         true
             }
             Full(new _root_.net.liftweb.http.auth.Role{
                         def name = roleName})
             }
       case false = Empty
     }
  }

 Can't be in Boot,

No you do not. Lift takes care of the roles matching for you. You
don't need to manually test if a user is-an admin or some other role
in order to access that resource. Please keep in mind that is just for
accessing resources (URI-s) if you need to do more complex logic in
your code and see if the user is an admin or having some other Role
that you'd probably need to save the Role into a SessionVar or into
your User object.

All I want here is to explain how HTTP based authentication and roles
based authorization works. I am definitely not claiming that this is
enough for all applications as currently we 

[Lift] Re: setting user-agent header with Databinder

2009-09-08 Thread David Pollak
Jack,
I'm not sure where N8han (the author of Databinder) hangs out, but it's not
on the Lift list.  :-(

Sorry.

David

On Tue, Sep 8, 2009 at 8:58 AM, jack jack.wid...@gmail.com wrote:


 Please forgive me for including so much code but I have an important
 demo fast approaching and I'm kind of in a bind. I am using
 Databinders Dispatch http library which is a wrapper around Javas
 HttpClient library. I have included the Http class below. Does anyone
 see how to set the user-agent header. Once again I apologize and would
 be much obliged for any help.

 import collection.Map
 import collection.immutable.{Map = IMap}
 import util.DynamicVariable
 import java.io.
 {InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
 import java.net.URI
 import java.util.zip.GZIPInputStream

 import org.apache.http._
 import org.apache.http.client._
 import org.apache.http.impl.client.{DefaultHttpClient,
 BasicCredentialsProvider}
 import org.apache.http.client.methods._
 import org.apache.http.client.entity.UrlEncodedFormEntity
 import org.apache.http.client.utils.URLEncodedUtils

 import org.apache.http.entity.StringEntity
 import org.apache.http.message.BasicNameValuePair
 import org.apache.http.protocol.HTTP.UTF_8
 import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
 import org.apache.http.util.EntityUtils
 import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
 Credentials}

 case class StatusCode(code: Int, contents:String)
  extends Exception(Exceptional resoponse code:  + code + \n +
 contents)

 /** Http access point. Standard instances to be used by a single
 thread. */
 class Http {
  val credentials = new DynamicVariable[Option[(AuthScope,
 Credentials)]](None)
  val client = new ConfiguredHttpClient

  def credentialsProvider = new BasicCredentialsProvider {
override def getCredentials(scope: AuthScope) = null
  }

 /**  /** Info Logger for this instance, default returns Connfiggy if
 on classpath else console logger. */
  lazy val log: Logger = try {
new Logger {
  val delegate = net.lag.logging.Logger.get
  def info(msg: String, items: Any*) { delegate.info(msg, items:
 _*) }
}
  } catch {
case e: NoClassDefFoundError = new Logger {
  def info(msg: String, items: Any*) {
println(INF: [console logger] dispatch:  + msg.format(items:
 _*))
  }
}
  }
  **/
  /** Execute method for the given host, with logging. */
  def execute(host: HttpHost, req: HttpUriRequest) = {
//log.info(%s %s%s, req.getMethod, host, req.getURI)
client.execute(host, req)
  }
  /** Execute for given optional parametrs, with logging. Creates
 local scope for credentials. */
  val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
 = HttpResponse = {
case (Some(host), Some(creds), req) =
  client.credentials.withValue(Some((new AuthScope
 (host.getHostName, host.getPort), creds)))(execute(host, req))
case (None, Some(creds), _) = error(Credentials specified
 without explicit host)
case (Some(host), _, req) = execute(host, req)
case (_, _, req) =
  //log.info(%s %s, req.getMethod, req.getURI)
  client.execute(req)
  }
  /** Execute full request-response handler. */
  def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
  /** Execute request and handle response codes, response, and entity
 in block */
  def x [T](req: Request)(block: Handler.F[T]) = {
val res = execute(req.host, req.creds, req.req)
val ent = res.getEntity match {
  case null = None
  case ent = Some(ent)
}
try { block(res.getStatusLine.getStatusCode, res, ent) }
finally { ent foreach (_.consumeContent) }
  }
  /** Apply Response Handler if reponse code returns true from chk. */
  def when[T](chk: Int = Boolean)(hand: Handler[T]) = x(hand.request)
 {
case (code, res, ent) if chk(code) = hand.block(code, res, ent)
case (code, _, Some(ent)) = throw StatusCode(code,
 EntityUtils.toString(ent, UTF_8))
case (code, _, _) = throw StatusCode(code, [no entity])
  }
  /** Apply a custom block in addition to predefined response Handler.
 */
  def also[A,B](hand: Handler[B])(block: Handler.F[A]) =
x(hand.request) { (code, res, ent) = ( hand.block(code, res,
 ent), block(code, res, ent) ) }

  /** Apply handler block when response code is 200 - 204 */
  def apply[T](hand: Handler[T]) = (this when {code = (200 to 204)
 contains code})(hand)
 }

 /** Nil request, useful to kick off a descriptors that don't have a
 factory. */
 object /\ extends Request(None, None, Nil)

 /* Factory for requests from a host */
 object :/ {
  def apply(hostname: String, port: Int): Request =
new Request(Some(new HttpHost(hostname, port)), None, Nil)

  def apply(hostname: String): Request = new Request(Some(new HttpHost
 (hostname)), None, Nil)
 }

 /** Factory for requests from a directory, prepends '/'. */
 object / {
  def apply(path: String) = /\ / path
 }

 object Request {
  /** Request transformer */
  

[Lift] Re: rewrite problem

2009-09-08 Thread night_stalker

Can't find

   RewriteResponse.apply(List[String], Map[String, String], Boolean)

in 1.0 API, is it a new feature?

On Sep 8, 11:52 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 or:
 LiftRules.rewrite.append {
      case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
 =
        RewriteResponse(List(post,show), Map(id-urlDecode(id)), *true*
 )
    }

 The true parameter stops the rewriting process so you don't get the infinite
 loop.

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



[Lift] Lift WebServices

2009-09-08 Thread abruzzo

I'm trying to set up a simple web service using Lift v1.0. I've
scoured
across many examples but because of changes in the api's, none of them
compile. I finally found an example of a dispatcher tha compiles but
in the
sample as in others the dispatcher is added in the boot method of the
Boot
class as follows:

LiftRules.dispatch.prepend(RestApi.dispatch)


This compiles fine however, upon startup I get the following stack:

ERROR - Failed to Boot
java.lang.IllegalStateException: Cannot modify after boot.
at net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:885)
at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:892)
at net.liftweb.http.RulesSeq$$anon$3.prepend(LiftRules.scala:872)
at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:581)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:572)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:548)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
97)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.servlet.ServletHandler.initialize
(ServletHandler.java:653)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
1239)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
466)
at
org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
(Jetty6PluginWebAppContext.java:124)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart
(HandlerCollection.java:152)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart
(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart
(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.plugin.Jetty6PluginServer.start
(Jetty6PluginServer.java:132)
at
org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
(AbstractJettyMojo.java:441)
at
org.mortbay.jetty.plugin.AbstractJettyMojo.execute
(AbstractJettyMojo.java:383)
at
org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute
(AbstractJettyRunMojo.java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:
184)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo
(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
(DefaultLifecycleExecutor.java:558)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal
(DefaultLifecycleExecutor.java:512)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
(DefaultLifecycleExecutor.java:482)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:330)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:
430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
2009-09-07 11:57:17.823::INFO:  Started
selectchannelconnec...@0.0.0.0:8080

Any help would be greatly appreciated. Also, if anyone knows of where
I can
find a sample Lift / BlazeDS application that will actually compile
using
Lift 1.0, please let me know.

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

[Lift] Re: CRUDify

2009-09-08 Thread Ollie

I've added a page with links to my posts 
http://wiki.github.com/dpp/liftweb/example-crudify-a-entity
.  I am just starting out with Lift and Scala but am happy to receive
any comments.

On Sep 8, 12:16 am, Randinn rand...@gmail.com wrote:
 I'll ask the author.

 On Sep 2, 3:49 am, David Pollak feeder.of.the.be...@gmail.com wrote:



  Good stuff!  Care to add a wiki page
  http://wiki.github.com/dpp/liftwebthat points to these blog posts?

  On Tue, Sep 1, 2009 at 10:10 AM, Randinn rand...@gmail.com wrote:

   Here are a couple of good posts on seting up CRUDify, I thought
   initiates like myself might benefit.

  http://neuralmonkey.blogspot.com/search/label/lift

  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: Crazy idea for lift's mega proto user: admin panel.

2009-09-08 Thread Timothy Perrett

Agreed - cant help but feel this is a little gimmicky and not really  
part of lifts core values; that said, as Marius points out this might  
work as a widget.

Cheers, Tim


On 8 Sep 2009, at 11:36, marius d. wrote:


 Nice thoughts but personally I don't think this should be part of Lift
 core framework. However an admin panel could be provided via a lift
 widget and would be pretty interesting thing to have.

 Br's,
 Marius

 On Sep 8, 2:16 am, DFectuoso santiago1...@gmail.com wrote:
 I was thinking about how wonderful it is to get a login/register/
 forgotPassword functionality with mega proto user and how it could
 become even better with a good tool for creating an admin section.

 I'm just adding the idea here so maybe if other people find value it
 could be considered for development(or probably it already is, i  
 don't
 know).

 Adding an admin panel to mega proto user where the moderators/admins
 could change some options(like the way a user is validated, if gzip  
 is
 enabled, etc) would be great for the end users of our apps, since it
 would be easier to change and maintain the site.

 Being a administrator at a Invision Power Board forum and having a
 couple of wordpress blogs, i see a lot of potential on this as a  
 admin/
 dev tool! Listing some of the things that i can imagine in this panel
 are:

 -phpMyAdmin-type of DB admin(browse your data easily, remove/change/
 add stuff to it without having to create a CRUD for each thing)
 -execute queries
 -List the actor(and comet actors) with possibility to kill/reset them
 -Memory use analysis.
 -Statistics of use(hits, referrals, etc)
 -Options (any object/class/trait could have a val foo =
 adminPanel.option(category,optionName,description,defaultValue,
 otherValues[]) and be included in this place, of course the  
 categories
 could create different menus.
 -User management(ban, authorize, give admin-rights).
 -Simple to-do list that all admins can edit
 -Log of errors/warnings/exceptions
 -Css editor
 -Easy-logo changer
 -File Manager(upload your images and stuff here)
 -String editor (you can change any default string from the
 megaprotouser forms and the index?)

 Also, a very polemic(and i think bad idea, but its common to see this
 in admin panels):
 -Installable plug-ins for this panel

 I know this seems like one step away from being a full blown CMS,
 forum, blog, etc. But if its extensible while we are building an app,
 it will be very useful for the different moments of development and
 use.

 Of course i don't expect any of this to be done right now, i
 understand there are a couple of integrations and bigger things going
 on but i really wanted to brainstorm on this with you guys!
 



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



[Lift] Re: setting user-agent header with Databinder

2009-09-08 Thread Timothy Perrett

IMHO, you'd probably get better traction with such questions in a  
wider audience on the main scala-user list over at EPFL...

Cheers, Tim


On 8 Sep 2009, at 17:26, Jack Widman wrote:

 Right. I will try to keep to the topic :)

 I actually found him and he quickly answered me.

 On Tue, Sep 8, 2009 at 12:24 PM, David Pollak feeder.of.the.be...@gmail.com 
  wrote:
 Jack,

 I'm not sure where N8han (the author of Databinder) hangs out, but  
 it's not on the Lift list.  :-(

 Sorry.

 David


 On Tue, Sep 8, 2009 at 8:58 AM, jack jack.wid...@gmail.com wrote:

 Please forgive me for including so much code but I have an important
 demo fast approaching and I'm kind of in a bind. I am using
 Databinders Dispatch http library which is a wrapper around Javas
 HttpClient library. I have included the Http class below. Does anyone
 see how to set the user-agent header. Once again I apologize and would
 be much obliged for any help.

 import collection.Map
 import collection.immutable.{Map = IMap}
 import util.DynamicVariable
 import java.io.
 {InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
 import java.net.URI
 import java.util.zip.GZIPInputStream

 import org.apache.http._
 import org.apache.http.client._
 import org.apache.http.impl.client.{DefaultHttpClient,
 BasicCredentialsProvider}
 import org.apache.http.client.methods._
 import org.apache.http.client.entity.UrlEncodedFormEntity
 import org.apache.http.client.utils.URLEncodedUtils

 import org.apache.http.entity.StringEntity
 import org.apache.http.message.BasicNameValuePair
 import org.apache.http.protocol.HTTP.UTF_8
 import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
 import org.apache.http.util.EntityUtils
 import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
 Credentials}

 case class StatusCode(code: Int, contents:String)
  extends Exception(Exceptional resoponse code:  + code + \n +
 contents)

 /** Http access point. Standard instances to be used by a single
 thread. */
 class Http {
  val credentials = new DynamicVariable[Option[(AuthScope,
 Credentials)]](None)
  val client = new ConfiguredHttpClient

  def credentialsProvider = new BasicCredentialsProvider {
override def getCredentials(scope: AuthScope) = null
  }

 /**  /** Info Logger for this instance, default returns Connfiggy if
 on classpath else console logger. */
  lazy val log: Logger = try {
new Logger {
  val delegate = net.lag.logging.Logger.get
  def info(msg: String, items: Any*) { delegate.info(msg, items:
 _*) }
}
  } catch {
case e: NoClassDefFoundError = new Logger {
  def info(msg: String, items: Any*) {
println(INF: [console logger] dispatch:  + msg.format(items:
 _*))
  }
}
  }
  **/
  /** Execute method for the given host, with logging. */
  def execute(host: HttpHost, req: HttpUriRequest) = {
//log.info(%s %s%s, req.getMethod, host, req.getURI)
client.execute(host, req)
  }
  /** Execute for given optional parametrs, with logging. Creates
 local scope for credentials. */
  val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
 = HttpResponse = {
case (Some(host), Some(creds), req) =
  client.credentials.withValue(Some((new AuthScope
 (host.getHostName, host.getPort), creds)))(execute(host, req))
case (None, Some(creds), _) = error(Credentials specified
 without explicit host)
case (Some(host), _, req) = execute(host, req)
case (_, _, req) =
  //log.info(%s %s, req.getMethod, req.getURI)
  client.execute(req)
  }
  /** Execute full request-response handler. */
  def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
  /** Execute request and handle response codes, response, and entity
 in block */
  def x [T](req: Request)(block: Handler.F[T]) = {
val res = execute(req.host, req.creds, req.req)
val ent = res.getEntity match {
  case null = None
  case ent = Some(ent)
}
try { block(res.getStatusLine.getStatusCode, res, ent) }
finally { ent foreach (_.consumeContent) }
  }
  /** Apply Response Handler if reponse code returns true from chk. */
  def when[T](chk: Int = Boolean)(hand: Handler[T]) = x(hand.request)
 {
case (code, res, ent) if chk(code) = hand.block(code, res, ent)
case (code, _, Some(ent)) = throw StatusCode(code,
 EntityUtils.toString(ent, UTF_8))
case (code, _, _) = throw StatusCode(code, [no entity])
  }
  /** Apply a custom block in addition to predefined response Handler.
 */
  def also[A,B](hand: Handler[B])(block: Handler.F[A]) =
x(hand.request) { (code, res, ent) = ( hand.block(code, res,
 ent), block(code, res, ent) ) }

  /** Apply handler block when response code is 200 - 204 */
  def apply[T](hand: Handler[T]) = (this when {code = (200 to 204)
 contains code})(hand)
 }

 /** Nil request, useful to kick off a descriptors that don't have a
 factory. */
 object /\ extends Request(None, None, Nil)

 /* Factory for requests from a host */
 object :/ {
  

[Lift] Re: Lift WebServices

2009-09-08 Thread David Pollak
Can you privately send me a zipped file containing your project (please
remove the target directory before sending).  I think there is something
very wrong, but can't diagnose it from the stack trace.

On Tue, Sep 8, 2009 at 9:43 AM, abruzzo java.peri...@gmail.com wrote:


 I'm trying to set up a simple web service using Lift v1.0. I've
 scoured
 across many examples but because of changes in the api's, none of them
 compile. I finally found an example of a dispatcher tha compiles but
 in the
 sample as in others the dispatcher is added in the boot method of the
 Boot
 class as follows:

LiftRules.dispatch.prepend(RestApi.dispatch)


 This compiles fine however, upon startup I get the following stack:

 ERROR - Failed to Boot
 java.lang.IllegalStateException: Cannot modify after boot.
at net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:885)
at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:892)
at net.liftweb.http.RulesSeq$$anon$3.prepend(LiftRules.scala:872)
at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:581)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:572)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:548)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
 97)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.servlet.ServletHandler.initialize
 (ServletHandler.java:653)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at
 org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
 1239)
at
 org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
 517)
at
 org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
 466)
at
 org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
 (Jetty6PluginWebAppContext.java:124)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerCollection.doStart
 (HandlerCollection.java:152)
at
 org.mortbay.jetty.handler.ContextHandlerCollection.doStart
 (ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerCollection.doStart
 (HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
 130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.plugin.Jetty6PluginServer.start
 (Jetty6PluginServer.java:132)
at
 org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
 (AbstractJettyMojo.java:441)
at
 org.mortbay.jetty.plugin.AbstractJettyMojo.execute
 (AbstractJettyMojo.java:383)
at
 org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute
 (AbstractJettyRunMojo.java:210)
at
 org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:
 184)
at
 org.apache.maven.plugin.DefaultPluginManager.executeMojo
 (DefaultPluginManager.java:451)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
 (DefaultLifecycleExecutor.java:558)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal
 (DefaultLifecycleExecutor.java:512)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
 (DefaultLifecycleExecutor.java:482)
at

 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
 (DefaultLifecycleExecutor.java:330)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
 (DefaultLifecycleExecutor.java:291)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
 (DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke
 (NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke
 (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
 315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:
 430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
 2009-09-07 11:57:17.823::INFO:  Started
 selectchannelconnec...@0.0.0.0:8080

 Any help would be greatly appreciated. Also, if anyone knows of where
 

[Lift] Re: rewrite problem

2009-09-08 Thread David Pollak
On Tue, Sep 8, 2009 at 9:41 AM, night_stalker usur...@gmail.com wrote:


 Can't find

   RewriteResponse.apply(List[String], Map[String, String], Boolean)

 in 1.0 API, is it a new feature?


It's probably a new feature in 1.1 to address the issue that you identified.

I recommend running against 1.1-M4 or SNAPSHOT.



 On Sep 8, 11:52 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:
  or:
  LiftRules.rewrite.append {
   case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
  =
 RewriteResponse(List(post,show), Map(id-urlDecode(id)),
 *true*
  )
 }
 
  The true parameter stops the rewriting process so you don't get the
 infinite
  loop.

 



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



[Lift] how do you set system properties in lift?

2009-09-08 Thread george

say I wanted to change the port / host that the Mailer uses.

how would I go about that?

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



[Lift] Re: rewrite problem

2009-09-08 Thread David Pollak
On Tue, Sep 8, 2009 at 6:40 AM, night_stalker usur...@gmail.com wrote:


 Cool, thank you very much!

 On Sep 8, 8:56 pm, Xavi Ramirez xavi@gmail.com wrote:
  That's because the url post/show is being intercepted by the same
  rewrite rule that matches post/id urls.  To get around this, try
  adding an if statement to your rewrite rule:
 
  LiftRules.rewrite.append {
case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
   if (id != show) =
  RewriteResponse(List(post,show), Map(id-urlDecode(id)))


or:
LiftRules.rewrite.append {
 case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
=
   RewriteResponse(List(post,show), Map(id-urlDecode(id)), *true*
)
   }

The true parameter stops the rewriting process so you don't get the infinite
loop.



 
  Hope this helps!
 
  ~Xavi
 
  On Tue, Sep 8, 2009 at 12:12 AM, night_stalkerusur...@gmail.com wrote:
 
   I want to make RESTful urls (not REST API), for example:
 
/post/123 is mapped to post/show.html with param id=123
 
   but the following rewrite rule seems recursive
 
  LiftRules.rewrite.append {
case RewriteRequest(ParsePath(List(post, id), _, _, _), _, _)
   =
  RewriteResponse(List(post,show), Map(id-urlDecode(id)))
  }
 
   and loops forever ...

 



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



[Lift] Re: Hudson build down?

2009-09-08 Thread David Pollak
On Mon, Sep 7, 2009 at 11:22 AM, Timothy Perrett timo...@getintheloop.euwrote:


 OK, so its been running for a while now and it looks like its
 featuring that same file open problem as before

 Can one of the admins fix it?


restarted.

Also, if there are scala-tools.org related issues, please send them to
ad...@scala-tools.org.



 Cheers, Tim

 On Sep 7, 6:54 pm, Timothy Perrett timo...@getintheloop.eu wrote:
  I've just triggered a manual build - so lets see if it works.
 
  Cheers, Tim
 
  On Sep 7, 9:19 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:
 
 
 
   Hi,
 
   Seems like it's been 5 days without a build, but there has been plenty
   of action on github.
 
   But looking at the maven repo it looks like there has been a snapshot
   release on sep 7 Is this a manual build or is this no longer the
   build server for lift:http://hudson.scala-tools.org/job/Lift/
 
   /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 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
-~--~~~~--~~--~--~---



[Lift] Re: setting user-agent header with Databinder

2009-09-08 Thread Jack Widman
Right. I will try to keep to the topic :)
I actually found him and he quickly answered me.

On Tue, Sep 8, 2009 at 12:24 PM, David Pollak feeder.of.the.be...@gmail.com
 wrote:

 Jack,
 I'm not sure where N8han (the author of Databinder) hangs out, but it's not
 on the Lift list.  :-(

 Sorry.

 David


 On Tue, Sep 8, 2009 at 8:58 AM, jack jack.wid...@gmail.com wrote:


 Please forgive me for including so much code but I have an important
 demo fast approaching and I'm kind of in a bind. I am using
 Databinders Dispatch http library which is a wrapper around Javas
 HttpClient library. I have included the Http class below. Does anyone
 see how to set the user-agent header. Once again I apologize and would
 be much obliged for any help.

 import collection.Map
 import collection.immutable.{Map = IMap}
 import util.DynamicVariable
 import java.io.
 {InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
 import java.net.URI
 import java.util.zip.GZIPInputStream

 import org.apache.http._
 import org.apache.http.client._
 import org.apache.http.impl.client.{DefaultHttpClient,
 BasicCredentialsProvider}
 import org.apache.http.client.methods._
 import org.apache.http.client.entity.UrlEncodedFormEntity
 import org.apache.http.client.utils.URLEncodedUtils

 import org.apache.http.entity.StringEntity
 import org.apache.http.message.BasicNameValuePair
 import org.apache.http.protocol.HTTP.UTF_8
 import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
 import org.apache.http.util.EntityUtils
 import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
 Credentials}

 case class StatusCode(code: Int, contents:String)
  extends Exception(Exceptional resoponse code:  + code + \n +
 contents)

 /** Http access point. Standard instances to be used by a single
 thread. */
 class Http {
  val credentials = new DynamicVariable[Option[(AuthScope,
 Credentials)]](None)
  val client = new ConfiguredHttpClient

  def credentialsProvider = new BasicCredentialsProvider {
override def getCredentials(scope: AuthScope) = null
  }

 /**  /** Info Logger for this instance, default returns Connfiggy if
 on classpath else console logger. */
  lazy val log: Logger = try {
new Logger {
  val delegate = net.lag.logging.Logger.get
  def info(msg: String, items: Any*) { delegate.info(msg, items:
 _*) }
}
  } catch {
case e: NoClassDefFoundError = new Logger {
  def info(msg: String, items: Any*) {
println(INF: [console logger] dispatch:  + msg.format(items:
 _*))
  }
}
  }
  **/
  /** Execute method for the given host, with logging. */
  def execute(host: HttpHost, req: HttpUriRequest) = {
//log.info(%s %s%s, req.getMethod, host, req.getURI)
client.execute(host, req)
  }
  /** Execute for given optional parametrs, with logging. Creates
 local scope for credentials. */
  val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
 = HttpResponse = {
case (Some(host), Some(creds), req) =
  client.credentials.withValue(Some((new AuthScope
 (host.getHostName, host.getPort), creds)))(execute(host, req))
case (None, Some(creds), _) = error(Credentials specified
 without explicit host)
case (Some(host), _, req) = execute(host, req)
case (_, _, req) =
  //log.info(%s %s, req.getMethod, req.getURI)
  client.execute(req)
  }
  /** Execute full request-response handler. */
  def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
  /** Execute request and handle response codes, response, and entity
 in block */
  def x [T](req: Request)(block: Handler.F[T]) = {
val res = execute(req.host, req.creds, req.req)
val ent = res.getEntity match {
  case null = None
  case ent = Some(ent)
}
try { block(res.getStatusLine.getStatusCode, res, ent) }
finally { ent foreach (_.consumeContent) }
  }
  /** Apply Response Handler if reponse code returns true from chk. */
  def when[T](chk: Int = Boolean)(hand: Handler[T]) = x(hand.request)
 {
case (code, res, ent) if chk(code) = hand.block(code, res, ent)
case (code, _, Some(ent)) = throw StatusCode(code,
 EntityUtils.toString(ent, UTF_8))
case (code, _, _) = throw StatusCode(code, [no entity])
  }
  /** Apply a custom block in addition to predefined response Handler.
 */
  def also[A,B](hand: Handler[B])(block: Handler.F[A]) =
x(hand.request) { (code, res, ent) = ( hand.block(code, res,
 ent), block(code, res, ent) ) }

  /** Apply handler block when response code is 200 - 204 */
  def apply[T](hand: Handler[T]) = (this when {code = (200 to 204)
 contains code})(hand)
 }

 /** Nil request, useful to kick off a descriptors that don't have a
 factory. */
 object /\ extends Request(None, None, Nil)

 /* Factory for requests from a host */
 object :/ {
  def apply(hostname: String, port: Int): Request =
new Request(Some(new HttpHost(hostname, port)), None, Nil)

  def apply(hostname: String): Request = new Request(Some(new HttpHost
 

[Lift] Re: Using Roles and LIftRules.authentication

2009-09-08 Thread marius d.



On Sep 8, 6:12 pm, glenn gl...@exmbly.com wrote:
 Marius,

 With your help, I think I'm getting closer to understanding what is
 needed
 here.

 One thing though, is that I believe I do need to manually check if the
 user has the
 appropriate role (in the DB) before I can set userRoles RequestVar.
 See, in my application,
 I have no way of knowing in advance if a logged-in user is authorized
 to access
 a particular resource. I'm trying to accomplish that programatically.

Well if when authenticating a user (LiftRules.authentication) you
can't determine the Role, then this mechanism probably won't help you
and you need to build your own.

 And, don't forget, roles
 can be changed at any time in the application.

I assume that a super-admin user would be able to change roles for
other users right? ... If so you just need to update data in your DB
for say user X. So when User X authenticates you'll get the new role
assigned. But maybe this is not how your app is designed to work.

 In other words, I
 can't just assume it in my
 authentication function and make the assignment there.

 Does that make sense?  This is not to say that I can't work
 tangentially to Http basic authentication
 in Lift and create my own, just that I'm trying to incorporate the
 work already done so I don't have to.

Lift's HTTP authentication and authorization is built on very simple
principles such as:

1. In the authentication function you typically know the role for that
user.
2. Resources (URI's essentially) are protected by hierarchically
structured roles that are matched with the role determined by the
authentication function.



 Glenn

 On Sep 7, 11:24 pm, marius d. marius.dan...@gmail.com wrote:

  On Sep 8, 1:18 am, glenn gl...@exmbly.com wrote:

   Marius,

   Please bear with me. I'm a little slow in following the logic here.

  Don't worry glen.

   I understand I can protect the resource as you suggest from all
   but users with admin roles, using the LocParam,

   HttpAuthProtected(() = Full(AuthRole(admin) .

   Now, when I click on the link, if no user is logged in, the system
   asks for a username and password to connect, but that's a user
   on the host. not an application user.

  Not necessarily. It is any type of user. In your authentication
  function you can go in DB and validate the receiving credentials as
  application user.

   Somewhere, I need to assign the
   currently logged in user the AuthRole(admin) needed to access
   the resource.

  Correct. And you dothis by setting userRoles RequestVar.

   Seems to me I need code like this to run someplace:

   def authorize(roleName:String): Box[Role] = {
         object userRoles extends RequestVar[Role](null)

         val credentials : (String,String) = User.currentUser match {
             case Full(u) = (u.email.is, u.password.is)
            case Empty = (null, null)
         }

         User.isa_?(roleName) match {
           case true = {
               LiftRules.authentication = HttpBasicAuthentication(lift)
   {
                   case (credentials._1, credentials._2, req) =
                           println(John is authenticated!)
                           userRoles(_root_.net.liftweb.http.auth.AuthRole
   (roleName))
                           true
               }
               Full(new _root_.net.liftweb.http.auth.Role{
                           def name = roleName})
               }
         case false = Empty
       }
    }

   Can't be in Boot,

  No you do not. Lift takes care of the roles matching for you. You
  don't need to manually test if a user is-an admin or some other role
  in order to access that resource. Please keep in mind that is just for
  accessing resources (URI-s) if you need to do more complex logic in
  your code and see if the user is an admin or having some other Role
  that you'd probably need to save the Role into a SessionVar or into
  your User object.

  All I want here is to explain how HTTP based authentication and roles
  based authorization works. I am definitely not claiming that this is
  enough for all applications as currently we don't have HTTP based
  authentication with forms for example ... but I think we should add
  that as well.

   Glenn

   On Sep 7, 1:36 pm, marius d. marius.dan...@gmail.com wrote:

On Sep 7, 10:53 pm, glenn gl...@exmbly.com wrote:

 Marius,

 In practical terms, if I am already using an If LocParam, as in the
 following:

 If(() = User.isa_?(admin), S.?(not_authorized))

 what does adding

 HttpAuthProtected(() = User.authorize(admin)) to the Loc do?

It sais that this Loc is protected by the returned Role. Thus to
access this after passing the authentication the Role specified in the
authentication function (by setting userRoles) must be the same as or
a child of the Role the is protecting the Loc.

 Here, I've had to define User.authorize to make things work, as:

  def authorize(roleName:String): Box[Role] =  {
  

[Lift] never mind. I contacted the author of Databinder. But thanks

2009-09-08 Thread jack

setting user-agent header. My question is answered
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread jon

Ah, IE7 seems to be confused about the character encoding of the
page.  When the encoding is set to Auto Select it chooses Western
European (Windows) and the © displays as  ©.  If I turn off Auto
Select and manually set to Unicode (UTF-8) it displays correctly.

I have LiftRules.early.append(makeUtf8) in Boot.  And the page
includes ?xml version=1.0 encoding=UTF-8?

Any ideas?

Thanks,

Jon


On Sep 8, 9:26 am, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Mon, Sep 7, 2009 at 11:38 PM, jon jonhoff...@gmail.com wrote:

  Hi,

  I've noticed that some special char xml tags are being interpreted by
  lift rather than passing through to the browser.

  source code in my template:
  div
           amp;
           copy;
           quot;
           raquo;
           lt;
           gt;
  /div

  result from curlhttp://localhost:8080/
     div
           amp;
           ©
           quot;
           »
           lt;
           gt;
     /div

  The rendered characters are problematic in IE7.

 Why?

   A fix or workaround
  would be much appreciated.

 The raw XHTML is valid.  Lift is yielding non-ASCII characters, but they are
 UTF-8 encoded and should be correctly rendered on all browsers.  I have
 never seen a problem with IE6 or IE7 (I have not tested in IE8)



  Thanks,

  - Jon

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: how do you set system properties in lift?

2009-09-08 Thread Tim Nelson
You need to set system properties:

System.setProperty(mail.smtp.starttls.enable,true);
System.setProperty(mail.smtp.host, host)
System.setProperty(mail.smtp.port, 587)
System.setProperty(mail.smtp.auth, true)
Mailer.authenticator = Full(new Authenticator {
override def getPasswordAuthentication =
new PasswordAuthentication(user, password)
})

Tim

On Tue, Sep 8, 2009 at 12:03 PM, george geo...@mattandgeorge.com wrote:


 say I wanted to change the port / host that the Mailer uses.

 how would I go about that?

 thanks
 


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



[Lift] Re: Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread David Pollak
On Tue, Sep 8, 2009 at 10:37 AM, jon jonhoff...@gmail.com wrote:


 Ah, IE7 seems to be confused about the character encoding of the
 page.  When the encoding is set to Auto Select it chooses Western
 European (Windows) and the © displays as  ©.  If I turn off Auto
 Select and manually set to Unicode (UTF-8) it displays correctly.


I wonder if this is a header issue... I'll put this on my to do list to
investigate.

Although, I bet Tim has something to say about it.



 I have LiftRules.early.append(makeUtf8) in Boot.  And the page
 includes ?xml version=1.0 encoding=UTF-8?

 Any ideas?

 Thanks,

 Jon


 On Sep 8, 9:26 am, David Pollak feeder.of.the.be...@gmail.com wrote:
  On Mon, Sep 7, 2009 at 11:38 PM, jon jonhoff...@gmail.com wrote:
 
   Hi,
 
   I've noticed that some special char xml tags are being interpreted by
   lift rather than passing through to the browser.
 
   source code in my template:
   div
amp;
copy;
quot;
raquo;
lt;
gt;
   /div
 
   result from curlhttp://localhost:8080/
  div
amp;
©
quot;
»
lt;
gt;
  /div
 
   The rendered characters are problematic in IE7.
 
  Why?
 
A fix or workaround
   would be much appreciated.
 
  The raw XHTML is valid.  Lift is yielding non-ASCII characters, but they
 are
  UTF-8 encoded and should be correctly rendered on all browsers.  I have
  never seen a problem with IE6 or IE7 (I have not tested in IE8)
 
 
 
   Thanks,
 
   - Jon
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 



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



[Lift] Re: how do you set system properties in lift?

2009-09-08 Thread jon

Note that if you're on 1.1-SNAPSHOT you can set customProperties on
the Mailer which would allow to use some other configuration mechanism
than system property (like Props or Configgy).

val props = Map[String,String](mail.smtp.host - ...)

Mailer.customProperties = props
Mailer.authenticator = Full(new Authenticator(){
override def getPasswordAuthentication = new
PasswordAuthentication(f...@foo.com,bar)
})


Mailer.buildProps would return the Properties the Mailer is currently
using.

- Jon

On Sep 8, 2:29 pm, Tim Nelson tnell...@gmail.com wrote:
 You need to set system properties:

 System.setProperty(mail.smtp.starttls.enable,true);
         System.setProperty(mail.smtp.host, host)
         System.setProperty(mail.smtp.port, 587)
         System.setProperty(mail.smtp.auth, true)
         Mailer.authenticator = Full(new Authenticator {
             override def getPasswordAuthentication =
                 new PasswordAuthentication(user, password)
         })

 Tim



 On Tue, Sep 8, 2009 at 12:03 PM, george geo...@mattandgeorge.com wrote:

  say I wanted to change the port / host that the Mailer uses.

  how would I go about that?

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



[Lift] Box and bind

2009-09-08 Thread José María

Hi.

Boxes are giving me a hard time.

Say you have a model of a Product.

If I've a snippet that retrieves a Product from the DB:

val product : Box[Product] = Product.find(2)

And now I want to bind product with bind(),  product is a Box and it
can be empty, how can I bind something that doesn't exists? You have
to return a NodeSeq in a snippet. What should my code must do?

Best regards.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread jon

Aha,

It is a header problem.  If the charset is specified in the content-
type IE will pick the right encoding.  I added the following to my
Boot (I already had LiftRules.useXhtmlMimeType = false):

LiftRules.determineContentType = {
case _ = text/html; charset=utf-8
 }

Maybe this should be the default?

Thanks!

On Sep 8, 2:45 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Tue, Sep 8, 2009 at 10:37 AM, jon jonhoff...@gmail.com wrote:

  Ah, IE7 seems to be confused about the character encoding of the
  page.  When the encoding is set to Auto Select it chooses Western
  European (Windows) and the © displays as  Â©.  If I turn off Auto
  Select and manually set to Unicode (UTF-8) it displays correctly.

 I wonder if this is a header issue... I'll put this on my to do list to
 investigate.

 Although, I bet Tim has something to say about it.







  I have LiftRules.early.append(makeUtf8) in Boot.  And the page
  includes ?xml version=1.0 encoding=UTF-8?

  Any ideas?

  Thanks,

  Jon

  On Sep 8, 9:26 am, David Pollak feeder.of.the.be...@gmail.com wrote:
   On Mon, Sep 7, 2009 at 11:38 PM, jon jonhoff...@gmail.com wrote:

Hi,

I've noticed that some special char xml tags are being interpreted by
lift rather than passing through to the browser.

source code in my template:
div
         amp;
         copy;
         quot;
         raquo;
         lt;
         gt;
/div

result from curlhttp://localhost:8080/
   div
         amp;
         ©
         quot;
         »
         lt;
         gt;
   /div

The rendered characters are problematic in IE7.

   Why?

 A fix or workaround
would be much appreciated.

   The raw XHTML is valid.  Lift is yielding non-ASCII characters, but they
  are
   UTF-8 encoded and should be correctly rendered on all browsers.  I have
   never seen a problem with IE6 or IE7 (I have not tested in IE8)

Thanks,

- Jon

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

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://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 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
-~--~~~~--~~--~--~---



[Lift] Re: Box and bind

2009-09-08 Thread Naftoli Gugenheim

There should be implicits that allow you to bind to a Box of a NodeSeq, so you 
can bind to prodBox.map(_.toForm). Otherwise bind to 
prodBox.map(_.toForm).openOr(NodeSeq.Empty) etc.

-
José Maríajosemariar...@gmail.com wrote:


Hi.

Boxes are giving me a hard time.

Say you have a model of a Product.

If I've a snippet that retrieves a Product from the DB:

val product : Box[Product] = Product.find(2)

And now I want to bind product with bind(),  product is a Box and it
can be empty, how can I bind something that doesn't exists? You have
to return a NodeSeq in a snippet. What should my code must do?

Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread Ross Mellgren

Well it depends on precisely what you want. If you want your snippet  
to become empty if the product is not there, try:

productBox.map(product = {
   bind(product, ns, ...)
}).openOr(NodeSeq.Empty)

If you want only certain bind positions empty, do the same thing  
inside the bind:

bind(proudct, ns,
  field - productBox.map(p = Text(p.field.toString)).openOr 
(NodeSeq.Empty),
  ...)

map is of course just one of the (simpler) operations you can do with  
a Box, there's more complicated stuff if you need other variants.

-Ross

On Sep 8, 2009, at 3:06 PM, José María wrote:


 Hi.

 Boxes are giving me a hard time.

 Say you have a model of a Product.

 If I've a snippet that retrieves a Product from the DB:

 val product : Box[Product] = Product.find(2)

 And now I want to bind product with bind(),  product is a Box and it
 can be empty, how can I bind something that doesn't exists? You have
 to return a NodeSeq in a snippet. What should my code must do?

 Best regards.
 


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



[Lift] Re: Box and bind

2009-09-08 Thread José María

That's my code:

val product = Product.find(id)


producto.map(product =
  bind(product, xhtml,
   url_enlace -- /product/ + product.id.toString ,
  )
   ).openOr(NodeSeq.Empty)
}

and I get this error:

[INFO] use java command with args in file forced : false
/usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/helloworld/
snippet/Portada.scala:55: error: overloaded method value bind with
alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
=
scala.xml.MetaData],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
scala.xml.NodeSeq and
(String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
scala.xml.NodeSeq cannot be applied to
(java.lang.String,scala.xml.NodeSeq,java.lang.String,java.lang.String,net.liftweb.util.Helpers.BindParam,net.liftweb.util.Helpers.BindParam)
  bind(producto, xhtml,
  ^
one error found



What's wrong?



On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
 Well it depends on precisely what you want. If you want your snippet  
 to become empty if the product is not there, try:

 productBox.map(product = {
    bind(product, ns, ...)

 }).openOr(NodeSeq.Empty)

 If you want only certain bind positions empty, do the same thing  
 inside the bind:

 bind(proudct, ns,
       field - productBox.map(p = Text(p.field.toString)).openOr
 (NodeSeq.Empty),
       ...)

 map is of course just one of the (simpler) operations you can do with  
 a Box, there's more complicated stuff if you need other variants.

 -Ross

 On Sep 8, 2009, at 3:06 PM, José María wrote:



  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread Ross Mellgren

Because the compiler interpret your expression as you expect. Instead  
of:

url_enlace - (/product/ + product.id.toString)

which is what you wanted, it got:

(url_enlace - /product/) + product.id.toString)

which it can do because it can take an arbitrary object:

(url_enlace - /product/): ABindParam
or (the other implicit -)
(url_enlace - /product/): Tuple2[String, String]

and convert them to strings. Of course, once it converts to string, it  
won't fit in bind()'s argument list and so it gave you the could not  
find overload error.

Honestly I'm a bit fuzzy on Scala's operator precedence behavior, I  
think if I recall you can't set precedence, it comes pre-set on all  
the standard operators like + / -, etc.

-Ross


On Sep 8, 2009, at 3:42 PM, José María wrote:


 It worked when I put the () around the bind param

 and the question is ... why?




 On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind
 argument related thing, probably because you have a precedence
 problem... try:

 producto.map(product =
bind(product, xhtml,
 url_enlace - (/product/ + product.id.toString),
)
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over
 producto. I presume either producto is coming from somewhere else  
 (and
 val product is being shadowed inside the map) or that you pasted not
 exactly what you're compiling.

 -Ross

 On Sep 8, 2009, at 3:25 PM, José María wrote:



 That's my code:

val product = Product.find(id)

producto.map(product =
  bind(product, xhtml,
   url_enlace -- /product/ + product.id.toString ,
  )
   ).openOr(NodeSeq.Empty)
}

 and I get this error:

 [INFO] use java command with args in file forced : false
 /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
 helloworld/
 snippet/Portada.scala:55: error: overloaded method value bind with
 alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
 scala.xml.NodeSeq],net.liftweb.util.Box 
 [(scala.xml.PrefixedAttribute)
 =
 scala.xml.MetaData
 ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq and
 (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq cannot be applied to
 (java.lang.String
 ,scala.xml.NodeSeq
 ,java.lang.String
 ,java.lang.String
 ,net.liftweb.util.Helpers.BindParam
 ,net.liftweb.util.Helpers.BindParam)
  bind(producto, xhtml,
  ^
 one error found

 What's wrong?

 On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
 Well it depends on precisely what you want. If you want your  
 snippet
 to become empty if the product is not there, try:

 productBox.map(product = {
bind(product, ns, ...)

 }).openOr(NodeSeq.Empty)

 If you want only certain bind positions empty, do the same thing
 inside the bind:

 bind(proudct, ns,
   field - productBox.map(p = Text(p.field.toString)).openOr
 (NodeSeq.Empty),
   ...)

 map is of course just one of the (simpler) operations you can do  
 with
 a Box, there's more complicated stuff if you need other variants.

 -Ross

 On Sep 8, 2009, at 3:06 PM, José María wrote:

 Hi.

 Boxes are giving me a hard time.

 Say you have a model of a Product.

 If I've a snippet that retrieves a Product from the DB:

 val product : Box[Product] = Product.find(2)

 And now I want to bind product with bind(),  product is a Box
 and it
 can be empty, how can I bind something that doesn't exists? You  
 have
 to return a NodeSeq in a snippet. What should my code must do?

 Best regards.


 


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



[Lift] Re: Box and bind

2009-09-08 Thread Naftoli Gugenheim

Operators starting with - and + have the same precendence so they are combined 
left to right. Thus you are concatenating a BindParam with a String, returning 
a String.

-
José Maríajosemariar...@gmail.com wrote:


It worked when I put the () around the bind param

and the question is ... why?




On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind  
 argument related thing, probably because you have a precedence  
 problem... try:

 producto.map(product =
    bind(product, xhtml,
         url_enlace - (/product/ + product.id.toString),
        )
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over  
 producto. I presume either producto is coming from somewhere else (and  
 val product is being shadowed inside the map) or that you pasted not  
 exactly what you're compiling.

 -Ross

 On Sep 8, 2009, at 3:25 PM, José María wrote:



  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

  If you want only certain bind positions empty, do the same thing
  inside the bind:

  bind(proudct, ns,
        field - productBox.map(p = Text(p.field.toString)).openOr
  (NodeSeq.Empty),
        ...)

  map is of course just one of the (simpler) operations you can do with
  a Box, there's more complicated stuff if you need other variants.

  -Ross

  On Sep 8, 2009, at 3:06 PM, José María wrote:

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box  
  and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.




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



[Lift] Re: Box and bind

2009-09-08 Thread Naftoli Gugenheim

Precedence is determined by the first character of an operator.

-
Ross Mellgrendri...@gmail.com wrote:


Because the compiler interpret your expression as you expect. Instead  
of:

url_enlace - (/product/ + product.id.toString)

which is what you wanted, it got:

(url_enlace - /product/) + product.id.toString)

which it can do because it can take an arbitrary object:

(url_enlace - /product/): ABindParam
or (the other implicit -)
(url_enlace - /product/): Tuple2[String, String]

and convert them to strings. Of course, once it converts to string, it  
won't fit in bind()'s argument list and so it gave you the could not  
find overload error.

Honestly I'm a bit fuzzy on Scala's operator precedence behavior, I  
think if I recall you can't set precedence, it comes pre-set on all  
the standard operators like + / -, etc.

-Ross


On Sep 8, 2009, at 3:42 PM, José María wrote:


 It worked when I put the () around the bind param

 and the question is ... why?




 On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind
 argument related thing, probably because you have a precedence
 problem... try:

 producto.map(product =
bind(product, xhtml,
 url_enlace - (/product/ + product.id.toString),
)
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over
 producto. I presume either producto is coming from somewhere else  
 (and
 val product is being shadowed inside the map) or that you pasted not
 exactly what you're compiling.

 -Ross

 On Sep 8, 2009, at 3:25 PM, José María wrote:



 That's my code:

val product = Product.find(id)

producto.map(product =
  bind(product, xhtml,
   url_enlace -- /product/ + product.id.toString ,
  )
   ).openOr(NodeSeq.Empty)
}

 and I get this error:

 [INFO] use java command with args in file forced : false
 /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
 helloworld/
 snippet/Portada.scala:55: error: overloaded method value bind with
 alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
 scala.xml.NodeSeq],net.liftweb.util.Box 
 [(scala.xml.PrefixedAttribute)
 =
 scala.xml.MetaData
 ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq and
 (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq cannot be applied to
 (java.lang.String
 ,scala.xml.NodeSeq
 ,java.lang.String
 ,java.lang.String
 ,net.liftweb.util.Helpers.BindParam
 ,net.liftweb.util.Helpers.BindParam)
  bind(producto, xhtml,
  ^
 one error found

 What's wrong?

 On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
 Well it depends on precisely what you want. If you want your  
 snippet
 to become empty if the product is not there, try:

 productBox.map(product = {
bind(product, ns, ...)

 }).openOr(NodeSeq.Empty)

 If you want only certain bind positions empty, do the same thing
 inside the bind:

 bind(proudct, ns,
   field - productBox.map(p = Text(p.field.toString)).openOr
 (NodeSeq.Empty),
   ...)

 map is of course just one of the (simpler) operations you can do  
 with
 a Box, there's more complicated stuff if you need other variants.

 -Ross

 On Sep 8, 2009, at 3:06 PM, José María wrote:

 Hi.

 Boxes are giving me a hard time.

 Say you have a model of a Product.

 If I've a snippet that retrieves a Product from the DB:

 val product : Box[Product] = Product.find(2)

 And now I want to bind product with bind(),  product is a Box
 and it
 can be empty, how can I bind something that doesn't exists? You  
 have
 to return a NodeSeq in a snippet. What should my code must do?

 Best regards.


 




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



[Lift] Re: Lift WebServices

2009-09-08 Thread David Pollak
You declared the LiftFilter twice in your web.xml file:

  filter
filter-nameLiftFilter/filter-name
display-nameLift Filter/display-name
descriptionThe Filter that intercepts lift calls/description
filter-classnet.liftweb.http.LiftFilter/filter-class
  /filter

THis caused the filter to be loaded twice.

Remove one of the filter declarations and you should be fine.

On Tue, Sep 8, 2009 at 9:43 AM, abruzzo java.peri...@gmail.com wrote:


 I'm trying to set up a simple web service using Lift v1.0. I've
 scoured
 across many examples but because of changes in the api's, none of them
 compile. I finally found an example of a dispatcher tha compiles but
 in the
 sample as in others the dispatcher is added in the boot method of the
 Boot
 class as follows:

LiftRules.dispatch.prepend(RestApi.dispatch)


 This compiles fine however, upon startup I get the following stack:

 ERROR - Failed to Boot
 java.lang.IllegalStateException: Cannot modify after boot.
at net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:885)
at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:892)
at net.liftweb.http.RulesSeq$$anon$3.prepend(LiftRules.scala:872)
at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:581)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:572)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:548)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
 97)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.servlet.ServletHandler.initialize
 (ServletHandler.java:653)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at
 org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
 1239)
at
 org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
 517)
at
 org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
 466)
at
 org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
 (Jetty6PluginWebAppContext.java:124)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerCollection.doStart
 (HandlerCollection.java:152)
at
 org.mortbay.jetty.handler.ContextHandlerCollection.doStart
 (ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerCollection.doStart
 (HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
 130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start
 (AbstractLifeCycle.java:50)
at
 org.mortbay.jetty.plugin.Jetty6PluginServer.start
 (Jetty6PluginServer.java:132)
at
 org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
 (AbstractJettyMojo.java:441)
at
 org.mortbay.jetty.plugin.AbstractJettyMojo.execute
 (AbstractJettyMojo.java:383)
at
 org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute
 (AbstractJettyRunMojo.java:210)
at
 org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:
 184)
at
 org.apache.maven.plugin.DefaultPluginManager.executeMojo
 (DefaultPluginManager.java:451)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
 (DefaultLifecycleExecutor.java:558)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal
 (DefaultLifecycleExecutor.java:512)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
 (DefaultLifecycleExecutor.java:482)
at

 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
 (DefaultLifecycleExecutor.java:330)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
 (DefaultLifecycleExecutor.java:291)
at
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
 (DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke
 (NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke
 (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
 315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:
 430)
at 

[Lift] Re: Box and bind

2009-09-08 Thread Naftoli Gugenheim

Yup

-
José Maríajosemariar...@gmail.com wrote:


OMG

So, as - begins with - then it has the precedence of the operator
-



On Sep 8, 7:52 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Precedence is determined by the first character of an operator.

 -

 Ross Mellgrendri...@gmail.com wrote:

 Because the compiler interpret your expression as you expect. Instead  
 of:

 url_enlace - (/product/ + product.id.toString)

 which is what you wanted, it got:

 (url_enlace - /product/) + product.id.toString)

 which it can do because it can take an arbitrary object:

 (url_enlace - /product/): ABindParam
 or (the other implicit -)
 (url_enlace - /product/): Tuple2[String, String]

 and convert them to strings. Of course, once it converts to string, it  
 won't fit in bind()'s argument list and so it gave you the could not  
 find overload error.

 Honestly I'm a bit fuzzy on Scala's operator precedence behavior, I  
 think if I recall you can't set precedence, it comes pre-set on all  
 the standard operators like + / -, etc.

 -Ross

 On Sep 8, 2009, at 3:42 PM, José María wrote:



  It worked when I put the () around the bind param

  and the question is ... why?

  On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
  So that doesn't seem to be a box-related thing so much as a bind
  argument related thing, probably because you have a precedence
  problem... try:

  producto.map(product =
     bind(product, xhtml,
          url_enlace - (/product/ + product.id.toString),
         )
  ).openOr(NodeSeq.Empty)

  Also, FYI, you have val product = Product.find(id), but then map over
  producto. I presume either producto is coming from somewhere else  
  (and
  val product is being shadowed inside the map) or that you pasted not
  exactly what you're compiling.

  -Ross

  On Sep 8, 2009, at 3:25 PM, José María wrote:

  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box
  [(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your  
  snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

  If you want only certain bind positions empty, do the same thing
  inside the bind:

  bind(proudct, ns,
        field - productBox.map(p = Text(p.field.toString)).openOr
  (NodeSeq.Empty),
        ...)

  map is of course just one of the (simpler) operations you can do  
  with
  a Box, there's more complicated stuff if you need other variants.

  -Ross

  On Sep 8, 2009, at 3:06 PM, José María wrote:

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box
  and it
  can be empty, how can I bind something that doesn't exists? You  
  have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.




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



[Lift] Re: Box and bind

2009-09-08 Thread José María

It worked when I put the () around the bind param

and the question is ... why?




On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind  
 argument related thing, probably because you have a precedence  
 problem... try:

 producto.map(product =
    bind(product, xhtml,
         url_enlace - (/product/ + product.id.toString),
        )
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over  
 producto. I presume either producto is coming from somewhere else (and  
 val product is being shadowed inside the map) or that you pasted not  
 exactly what you're compiling.

 -Ross

 On Sep 8, 2009, at 3:25 PM, José María wrote:



  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

  If you want only certain bind positions empty, do the same thing
  inside the bind:

  bind(proudct, ns,
        field - productBox.map(p = Text(p.field.toString)).openOr
  (NodeSeq.Empty),
        ...)

  map is of course just one of the (simpler) operations you can do with
  a Box, there's more complicated stuff if you need other variants.

  -Ross

  On Sep 8, 2009, at 3:06 PM, José María wrote:

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box  
  and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: setting user-agent header with Databinder

2009-09-08 Thread Randinn

What was the answer now that you have attained it?

On Sep 9, 3:02 am, Jack Widman jack.wid...@gmail.com wrote:
 You are right. I will fine tune my determine which is a good question to ask
 mechanism :)

 On Tue, Sep 8, 2009 at 12:54 PM, Timothy Perrett 
 timo...@getintheloop.euwrote:



  IMHO, you'd probably get better traction with such questions in a
  wider audience on the main scala-user list over at EPFL...

  Cheers, Tim

  On 8 Sep 2009, at 17:26, Jack Widman wrote:

   Right. I will try to keep to the topic :)

   I actually found him and he quickly answered me.

   On Tue, Sep 8, 2009 at 12:24 PM, David Pollak 
  feeder.of.the.be...@gmail.com
wrote:
   Jack,

   I'm not sure where N8han (the author of Databinder) hangs out, but
   it's not on the Lift list.  :-(

   Sorry.

   David

   On Tue, Sep 8, 2009 at 8:58 AM, jack jack.wid...@gmail.com wrote:

   Please forgive me for including so much code but I have an important
   demo fast approaching and I'm kind of in a bind. I am using
   Databinders Dispatch http library which is a wrapper around Javas
   HttpClient library. I have included the Http class below. Does anyone
   see how to set the user-agent header. Once again I apologize and would
   be much obliged for any help.

   import collection.Map
   import collection.immutable.{Map = IMap}
   import util.DynamicVariable
   import java.io.
   {InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
   import java.net.URI
   import java.util.zip.GZIPInputStream

   import org.apache.http._
   import org.apache.http.client._
   import org.apache.http.impl.client.{DefaultHttpClient,
   BasicCredentialsProvider}
   import org.apache.http.client.methods._
   import org.apache.http.client.entity.UrlEncodedFormEntity
   import org.apache.http.client.utils.URLEncodedUtils

   import org.apache.http.entity.StringEntity
   import org.apache.http.message.BasicNameValuePair
   import org.apache.http.protocol.HTTP.UTF_8
   import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
   import org.apache.http.util.EntityUtils
   import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
   Credentials}

   case class StatusCode(code: Int, contents:String)
    extends Exception(Exceptional resoponse code:  + code + \n +
   contents)

   /** Http access point. Standard instances to be used by a single
   thread. */
   class Http {
    val credentials = new DynamicVariable[Option[(AuthScope,
   Credentials)]](None)
    val client = new ConfiguredHttpClient

    def credentialsProvider = new BasicCredentialsProvider {
      override def getCredentials(scope: AuthScope) = null
    }

   /**  /** Info Logger for this instance, default returns Connfiggy if
   on classpath else console logger. */
    lazy val log: Logger = try {
      new Logger {
        val delegate = net.lag.logging.Logger.get
        def info(msg: String, items: Any*) { delegate.info(msg, items:
   _*) }
      }
    } catch {
      case e: NoClassDefFoundError = new Logger {
        def info(msg: String, items: Any*) {
          println(INF: [console logger] dispatch:  + msg.format(items:
   _*))
        }
      }
    }
    **/
    /** Execute method for the given host, with logging. */
    def execute(host: HttpHost, req: HttpUriRequest) = {
      //log.info(%s %s%s, req.getMethod, host, req.getURI)
      client.execute(host, req)
    }
    /** Execute for given optional parametrs, with logging. Creates
   local scope for credentials. */
    val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
   = HttpResponse = {
      case (Some(host), Some(creds), req) =
        client.credentials.withValue(Some((new AuthScope
   (host.getHostName, host.getPort), creds)))(execute(host, req))
      case (None, Some(creds), _) = error(Credentials specified
   without explicit host)
      case (Some(host), _, req) = execute(host, req)
      case (_, _, req) =
        //log.info(%s %s, req.getMethod, req.getURI)
        client.execute(req)
    }
    /** Execute full request-response handler. */
    def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
    /** Execute request and handle response codes, response, and entity
   in block */
    def x [T](req: Request)(block: Handler.F[T]) = {
      val res = execute(req.host, req.creds, req.req)
      val ent = res.getEntity match {
        case null = None
        case ent = Some(ent)
      }
      try { block(res.getStatusLine.getStatusCode, res, ent) }
      finally { ent foreach (_.consumeContent) }
    }
    /** Apply Response Handler if reponse code returns true from chk. */
    def when[T](chk: Int = Boolean)(hand: Handler[T]) = x(hand.request)
   {
      case (code, res, ent) if chk(code) = hand.block(code, res, ent)
      case (code, _, Some(ent)) = throw StatusCode(code,
   EntityUtils.toString(ent, UTF_8))
      case (code, _, _)         = throw StatusCode(code, [no entity])
    }
    /** Apply a custom block in addition to predefined 

[Lift] Re: Box and bind

2009-09-08 Thread José María

I adapted the code but not the error, Producto is Product in Spanish.



On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind  
 argument related thing, probably because you have a precedence  
 problem... try:

 producto.map(product =
    bind(product, xhtml,
         url_enlace - (/product/ + product.id.toString),
        )
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over  
 producto. I presume either producto is coming from somewhere else (and  
 val product is being shadowed inside the map) or that you pasted not  
 exactly what you're compiling.

 -Ross

 On Sep 8, 2009, at 3:25 PM, José María wrote:



  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

  If you want only certain bind positions empty, do the same thing
  inside the bind:

  bind(proudct, ns,
        field - productBox.map(p = Text(p.field.toString)).openOr
  (NodeSeq.Empty),
        ...)

  map is of course just one of the (simpler) operations you can do with
  a Box, there's more complicated stuff if you need other variants.

  -Ross

  On Sep 8, 2009, at 3:06 PM, José María wrote:

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box  
  and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread José María

OMG

So, as - begins with - then it has the precedence of the operator
-



On Sep 8, 7:52 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Precedence is determined by the first character of an operator.

 -

 Ross Mellgrendri...@gmail.com wrote:

 Because the compiler interpret your expression as you expect. Instead  
 of:

 url_enlace - (/product/ + product.id.toString)

 which is what you wanted, it got:

 (url_enlace - /product/) + product.id.toString)

 which it can do because it can take an arbitrary object:

 (url_enlace - /product/): ABindParam
 or (the other implicit -)
 (url_enlace - /product/): Tuple2[String, String]

 and convert them to strings. Of course, once it converts to string, it  
 won't fit in bind()'s argument list and so it gave you the could not  
 find overload error.

 Honestly I'm a bit fuzzy on Scala's operator precedence behavior, I  
 think if I recall you can't set precedence, it comes pre-set on all  
 the standard operators like + / -, etc.

 -Ross

 On Sep 8, 2009, at 3:42 PM, José María wrote:



  It worked when I put the () around the bind param

  and the question is ... why?

  On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
  So that doesn't seem to be a box-related thing so much as a bind
  argument related thing, probably because you have a precedence
  problem... try:

  producto.map(product =
     bind(product, xhtml,
          url_enlace - (/product/ + product.id.toString),
         )
  ).openOr(NodeSeq.Empty)

  Also, FYI, you have val product = Product.find(id), but then map over
  producto. I presume either producto is coming from somewhere else  
  (and
  val product is being shadowed inside the map) or that you pasted not
  exactly what you're compiling.

  -Ross

  On Sep 8, 2009, at 3:25 PM, José María wrote:

  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box
  [(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your  
  snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

  If you want only certain bind positions empty, do the same thing
  inside the bind:

  bind(proudct, ns,
        field - productBox.map(p = Text(p.field.toString)).openOr
  (NodeSeq.Empty),
        ...)

  map is of course just one of the (simpler) operations you can do  
  with
  a Box, there's more complicated stuff if you need other variants.

  -Ross

  On Sep 8, 2009, at 3:06 PM, José María wrote:

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box
  and it
  can be empty, how can I bind something that doesn't exists? You  
  have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread Ross Mellgren

So that doesn't seem to be a box-related thing so much as a bind  
argument related thing, probably because you have a precedence  
problem... try:

producto.map(product =
   bind(product, xhtml,
url_enlace - (/product/ + product.id.toString),
   )
).openOr(NodeSeq.Empty)

Also, FYI, you have val product = Product.find(id), but then map over  
producto. I presume either producto is coming from somewhere else (and  
val product is being shadowed inside the map) or that you pasted not  
exactly what you're compiling.

-Ross


On Sep 8, 2009, at 3:25 PM, José María wrote:


 That's my code:

val product = Product.find(id)


producto.map(product =
  bind(product, xhtml,
   url_enlace -- /product/ + product.id.toString ,
  )
   ).openOr(NodeSeq.Empty)
}

 and I get this error:

 [INFO] use java command with args in file forced : false
 /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/ 
 helloworld/
 snippet/Portada.scala:55: error: overloaded method value bind with
 alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
 scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
 =
 scala.xml.MetaData 
 ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq and
 (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
 scala.xml.NodeSeq cannot be applied to
 (java.lang.String 
 ,scala.xml.NodeSeq 
 ,java.lang.String 
 ,java.lang.String 
 ,net.liftweb.util.Helpers.BindParam 
 ,net.liftweb.util.Helpers.BindParam)
  bind(producto, xhtml,
  ^
 one error found



 What's wrong?



 On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
 Well it depends on precisely what you want. If you want your snippet
 to become empty if the product is not there, try:

 productBox.map(product = {
bind(product, ns, ...)

 }).openOr(NodeSeq.Empty)

 If you want only certain bind positions empty, do the same thing
 inside the bind:

 bind(proudct, ns,
   field - productBox.map(p = Text(p.field.toString)).openOr
 (NodeSeq.Empty),
   ...)

 map is of course just one of the (simpler) operations you can do with
 a Box, there's more complicated stuff if you need other variants.

 -Ross

 On Sep 8, 2009, at 3:06 PM, José María wrote:



 Hi.

 Boxes are giving me a hard time.

 Say you have a model of a Product.

 If I've a snippet that retrieves a Product from the DB:

 val product : Box[Product] = Product.find(2)

 And now I want to bind product with bind(),  product is a Box  
 and it
 can be empty, how can I bind something that doesn't exists? You have
 to return a NodeSeq in a snippet. What should my code must do?

 Best regards.


 


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



[Lift] Re: setting user-agent header with Databinder

2009-09-08 Thread Jack Widman
Sorry.  should have thought to tell everyone. I have been coding all day
with tunnel vision!
The : method adds a Map[String, String] of headers to the request object:
http://databinder.net/sxr/dispatch-http/0.5.2/main/Http.scala.html#10878

For user agent it would be something like
val req_with_agent = req : Map(User-Agent - my user agent value)

On Tue, Sep 8, 2009 at 5:17 PM, Randinn rand...@gmail.com wrote:


 What was the answer now that you have attained it?

 On Sep 9, 3:02 am, Jack Widman jack.wid...@gmail.com wrote:
  You are right. I will fine tune my determine which is a good question to
 ask
  mechanism :)
 
  On Tue, Sep 8, 2009 at 12:54 PM, Timothy Perrett timo...@getintheloop.eu
 wrote:
 
 
 
   IMHO, you'd probably get better traction with such questions in a
   wider audience on the main scala-user list over at EPFL...
 
   Cheers, Tim
 
   On 8 Sep 2009, at 17:26, Jack Widman wrote:
 
Right. I will try to keep to the topic :)
 
I actually found him and he quickly answered me.
 
On Tue, Sep 8, 2009 at 12:24 PM, David Pollak 
   feeder.of.the.be...@gmail.com
 wrote:
Jack,
 
I'm not sure where N8han (the author of Databinder) hangs out, but
it's not on the Lift list.  :-(
 
Sorry.
 
David
 
On Tue, Sep 8, 2009 at 8:58 AM, jack jack.wid...@gmail.com wrote:
 
Please forgive me for including so much code but I have an important
demo fast approaching and I'm kind of in a bind. I am using
Databinders Dispatch http library which is a wrapper around Javas
HttpClient library. I have included the Http class below. Does anyone
see how to set the user-agent header. Once again I apologize and
 would
be much obliged for any help.
 
import collection.Map
import collection.immutable.{Map = IMap}
import util.DynamicVariable
import java.io.
{InputStream,OutputStream,BufferedInputStream,BufferedOutputStream}
import java.net.URI
import java.util.zip.GZIPInputStream
 
import org.apache.http._
import org.apache.http.client._
import org.apache.http.impl.client.{DefaultHttpClient,
BasicCredentialsProvider}
import org.apache.http.client.methods._
import org.apache.http.client.entity.UrlEncodedFormEntity
import org.apache.http.client.utils.URLEncodedUtils
 
import org.apache.http.entity.StringEntity
import org.apache.http.message.BasicNameValuePair
import org.apache.http.protocol.HTTP.UTF_8
import org.apache.http.params.{HttpProtocolParams, BasicHttpParams}
import org.apache.http.util.EntityUtils
import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials,
Credentials}
 
case class StatusCode(code: Int, contents:String)
 extends Exception(Exceptional resoponse code:  + code + \n +
contents)
 
/** Http access point. Standard instances to be used by a single
thread. */
class Http {
 val credentials = new DynamicVariable[Option[(AuthScope,
Credentials)]](None)
 val client = new ConfiguredHttpClient
 
 def credentialsProvider = new BasicCredentialsProvider {
   override def getCredentials(scope: AuthScope) = null
 }
 
/**  /** Info Logger for this instance, default returns Connfiggy if
on classpath else console logger. */
 lazy val log: Logger = try {
   new Logger {
 val delegate = net.lag.logging.Logger.get
 def info(msg: String, items: Any*) { delegate.info(msg, items:
_*) }
   }
 } catch {
   case e: NoClassDefFoundError = new Logger {
 def info(msg: String, items: Any*) {
   println(INF: [console logger] dispatch:  + msg.format(items:
_*))
 }
   }
 }
 **/
 /** Execute method for the given host, with logging. */
 def execute(host: HttpHost, req: HttpUriRequest) = {
   //log.info(%s %s%s, req.getMethod, host, req.getURI)
   client.execute(host, req)
 }
 /** Execute for given optional parametrs, with logging. Creates
local scope for credentials. */
 val execute: (Option[HttpHost], Option[Credentials], HttpUriRequest)
= HttpResponse = {
   case (Some(host), Some(creds), req) =
 client.credentials.withValue(Some((new AuthScope
(host.getHostName, host.getPort), creds)))(execute(host, req))
   case (None, Some(creds), _) = error(Credentials specified
without explicit host)
   case (Some(host), _, req) = execute(host, req)
   case (_, _, req) =
 //log.info(%s %s, req.getMethod, req.getURI)
 client.execute(req)
 }
 /** Execute full request-response handler. */
 def x[T](hand: Handler[T]): T = x(hand.request)(hand.block)
 /** Execute request and handle response codes, response, and entity
in block */
 def x [T](req: Request)(block: Handler.F[T]) = {
   val res = execute(req.host, req.creds, req.req)
   val ent = res.getEntity match {
 case null = None
 case ent = Some(ent)
   }
   try { 

[Lift] Re: Some XML special chars rendered by lift, others not in 1.1-SNAPSHOT

2009-09-08 Thread David Pollak
Okay... I'll check in the change after Charles finishes the M5 build

On Tue, Sep 8, 2009 at 12:10 PM, jon jonhoff...@gmail.com wrote:


 Aha,

 It is a header problem.  If the charset is specified in the content-
 type IE will pick the right encoding.  I added the following to my
 Boot (I already had LiftRules.useXhtmlMimeType = false):

LiftRules.determineContentType = {
case _ = text/html; charset=utf-8
 }

 Maybe this should be the default?

 Thanks!

 On Sep 8, 2:45 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
  On Tue, Sep 8, 2009 at 10:37 AM, jon jonhoff...@gmail.com wrote:
 
   Ah, IE7 seems to be confused about the character encoding of the
   page.  When the encoding is set to Auto Select it chooses Western
   European (Windows) and the © displays as  ©.  If I turn off Auto
   Select and manually set to Unicode (UTF-8) it displays correctly.
 
  I wonder if this is a header issue... I'll put this on my to do list to
  investigate.
 
  Although, I bet Tim has something to say about it.
 
 
 
 
 
 
 
   I have LiftRules.early.append(makeUtf8) in Boot.  And the page
   includes ?xml version=1.0 encoding=UTF-8?
 
   Any ideas?
 
   Thanks,
 
   Jon
 
   On Sep 8, 9:26 am, David Pollak feeder.of.the.be...@gmail.com wrote:
On Mon, Sep 7, 2009 at 11:38 PM, jon jonhoff...@gmail.com wrote:
 
 Hi,
 
 I've noticed that some special char xml tags are being interpreted
 by
 lift rather than passing through to the browser.
 
 source code in my template:
 div
  amp;
  copy;
  quot;
  raquo;
  lt;
  gt;
 /div
 
 result from curlhttp://localhost:8080/
div
  amp;
  ©
  quot;
  »
  lt;
  gt;
/div
 
 The rendered characters are problematic in IE7.
 
Why?
 
  A fix or workaround
 would be much appreciated.
 
The raw XHTML is valid.  Lift is yielding non-ASCII characters, but
 they
   are
UTF-8 encoded and should be correctly rendered on all browsers.  I
 have
never seen a problem with IE6 or IE7 (I have not tested in IE8)
 
 Thanks,
 
 - Jon
 
--
Lift, the simply functional web frameworkhttp://liftweb.net
Beginning Scalahttp://www.apress.com/book/view/1430219890
Follow me:http://twitter.com/dpp
Git some:http://github.com/dpp
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 



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



[Lift] Re: Mapper subclasses

2009-09-08 Thread rstradling

I am trying to do what is mentioned below but am struggling with the
object side of things for my particular case.  This all relates back
to trying to auto-generate some classes that I posted back a while ago
on.  I would love to generate 1 file that has the trait and the object
in it that I then inherit from in my sub-class and object sub-class in
another file.

Autogenerated.scala
trait FC[MapperType : FC[MapperType]] extends Mapper[MapperType] {
   self: MapperType =
   object today extends MappedLong(this)
}

trait FCObj extends FC[MapperType] with LongKeyedMetaMapper[FC
[MapperType]] {
  override def fieldOrder = List(today)
}

In UserClass.scala
class FC_Wrapper extends LongKeyedMapper[FC_Wrapper] with IdPK with FC
[Wrapper] {
   def getSingleton = FCObj_Wrapper
   // define methods
}

object FCObj_Wrapper extends FCObj {
  // define auxiliary functionality

}

I know that the FCObj and FCObj_Wrapper is not correct syntax wise.
But the basic idea is that I want to have my autogeneration generate
the boilerplate code for me in a separate file.  This boilerplate
would ideally include the class and object related stuff.  Then in a
file that won't be stomped upon the next time I run the generator I
inherit from these objects.  I hope this makes sense.

I admit to not totally understanding the templated/generic programming
that is happening.




On Sep 3, 1:33 pm, glenn gl...@exmbly.com wrote:
 Isn't this really a matter of type casting, and asInstanceOf is just
 Scala's
 way of doing this. It's always best if you don't have to downcast your
 objects, but sometimes its unavoidable.

 Glenn...

 On Sep 3, 10:29 am, glenn gl...@exmbly.com wrote:

  I'm not sure of what the exact problem is. I created an Address trait
  that
  I couple with a number of mapper classes.

  trait Address[OwnerType : KeyedMapper[Long, OwnerType]]{

    def owner = this.asInstanceOf[OwnerType]

  

  Where exactly does this construct break down?

  Glenn...

  On Sep 3, 7:55 am, Giuseppe Fogliazza g.foglia...@mcmspa.it wrote:

   jon suggested to me the way to avoid both explicit type parameter and
   asinstance of:
   trait Timestamp[MapperType : TimeStamp[MapperType]] extends Mapper
   [MapperType] {
  self:MapperType =
   object xdatetime extends MappedDateTime(this)

     // all sorts of utility functions for dealing with timestamps

   }

   Thanks jon I have improved model in my application with this approach.

   Giuseppe

   On 3 Set, 16:16, Giuseppe Fogliazza g.foglia...@mcmspa.it wrote:

As an alternative to asInstanceOf you could use explicit type
parameter in MappedField creation:
   self:MapperType =
object xdatetime extends MappedDateTime[MapperType](this)

On 3 Set, 09:19, Giuseppe Fogliazza g.foglia...@mcmspa.it wrote:

 Unfortunately you cannot escape from asInstanceOf . Forcing
self:MapperType the type of this will be TimeStamp with MapperType
 violating the constraint for the type of the first parameter of
 MappedDateTime :T : Mapper[T].

 Regards
 Giuseppe

 On 3 Set, 07:08, Naftoli Gugenheim naftoli...@gmail.com wrote:

  So I guess you can't escape the asInstanceOf. Can you successfully 
  give the trait aself-type of this: MapperType =, or declare it to 
  extend Mapper[MapperType], without running into problems elsewhere?

  -

  harryhhar...@gmail.com wrote:

  I've been handling this with traits, for example I have something 
  like
  so:

  trait Timestamp[MapperType : Mapper[MapperType]] {
    object xdatetime extends 
  MappedDateTime[MapperType](this.asInstanceOf
  [MapperType])

    // all sorts of utility functions for dealing with timestamps

  }

  Then I can do

  class Foo extends LongKeyedMapper[Foo] with IdPK with 
  Timestamp[Foo] {
    // additional fields that are Foo specific

  }

  I have quite a few traits similar to Timestamp at this point
  corresponding to various fields that appear in lots of different
  tables in my application.

  -harryh

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



[Lift] Re: setting user-agent header

2009-09-08 Thread Derek Chen-Becker
S.setHeader can be used in Lift to set a response header.

Derek

On Tue, Sep 8, 2009 at 9:02 AM, jack jack.wid...@gmail.com wrote:


 Has anyone used dispatch from databinder.net?  Its an http library in
 Scala.
 I do not know how to set the User-Agent header.
 


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



[Lift] Re: setting user-agent header

2009-09-08 Thread Jack Widman
Cool. Thanks. The useful things about Lift seem to never end.

On Tue, Sep 8, 2009 at 6:51 PM, Derek Chen-Becker dchenbec...@gmail.comwrote:

 S.setHeader can be used in Lift to set a response header.

 Derek


 On Tue, Sep 8, 2009 at 9:02 AM, jack jack.wid...@gmail.com wrote:


 Has anyone used dispatch from databinder.net?  Its an http library in
 Scala.
 I do not know how to set the User-Agent header.



 


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



[Lift] Retrieving the URL anchor

2009-09-08 Thread Xavi Ramirez

Hello,

I'm having trouble finding the URL anchor (e.g.
www.foo.com/test.html#this-is-the-url-anchor) while performing a URL
rewrite.  i looked through the HTTPRequest object, but I can't seem to
find it any where.

Any idea where it might be?

Thanks,
Xavi

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



[Lift] Re: Crazy idea for lift's mega proto user: admin panel.

2009-09-08 Thread g-man

Right -- not knowing personally as to core vs widget (that is up to
'management'), but I would also look to the web2py and django (even
Google app engine) frameworks for nice admin interface inspiration...

On Sep 7, 4:16 pm, DFectuoso santiago1...@gmail.com wrote:
 I was thinking about how wonderful it is to get a login/register/
 forgotPassword functionality with mega proto user and how it could
 become even better with a good tool for creating an admin section.

 I'm just adding the idea here so maybe if other people find value it
 could be considered for development(or probably it already is, i don't
 know).

 Adding an admin panel to mega proto user where the moderators/admins
 could change some options(like the way a user is validated, if gzip is
 enabled, etc) would be great for the end users of our apps, since it
 would be easier to change and maintain the site.

 Being a administrator at a Invision Power Board forum and having a
 couple of wordpress blogs, i see a lot of potential on this as a admin/
 dev tool! Listing some of the things that i can imagine in this panel
 are:

 -phpMyAdmin-type of DB admin(browse your data easily, remove/change/
 add stuff to it without having to create a CRUD for each thing)
 -execute queries
 -List the actor(and comet actors) with possibility to kill/reset them
 -Memory use analysis.
 -Statistics of use(hits, referrals, etc)
 -Options (any object/class/trait could have a val foo =
 adminPanel.option(category,optionName,description,defaultValue,
 otherValues[]) and be included in this place, of course the categories
 could create different menus.
 -User management(ban, authorize, give admin-rights).
 -Simple to-do list that all admins can edit
 -Log of errors/warnings/exceptions
 -Css editor
 -Easy-logo changer
 -File Manager(upload your images and stuff here)
 -String editor (you can change any default string from the
 megaprotouser forms and the index?)

 Also, a very polemic(and i think bad idea, but its common to see this
 in admin panels):
 -Installable plug-ins for this panel

 I know this seems like one step away from being a full blown CMS,
 forum, blog, etc. But if its extensible while we are building an app,
 it will be very useful for the different moments of development and
 use.

 Of course i don't expect any of this to be done right now, i
 understand there are a couple of integrations and bigger things going
 on but i really wanted to brainstorm on this with you guys!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] configuring web application

2009-09-08 Thread jack

Simple, but appropriate, I think, question.

I am using jetty on port 8080. How do configure my server so that when
people just type in my domain name, they get the index.html of my
application. Its been a few years since I did this.


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



[Lift] Re: configuring web application

2009-09-08 Thread Naftoli Gugenheim

-Djetty.port=80 I think.
Or set up a front end web server like nginx or apache that routes between 80 
and 8080.

-
jackjack.wid...@gmail.com wrote:


Simple, but appropriate, I think, question.

I am using jetty on port 8080. How do configure my server so that when
people just type in my domain name, they get the index.html of my
application. Its been a few years since I did this.




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



[Lift] Re: Retrieving the URL anchor

2009-09-08 Thread David Pollak
On Tue, Sep 8, 2009 at 6:55 PM, Xavi Ramirez xavi@gmail.com wrote:


 Hello,

 I'm having trouble finding the URL anchor (e.g.
 www.foo.com/test.html#this-is-the-url-anchor) while performing a URL
 rewrite.  i looked through the HTTPRequest object, but I can't seem to
 find it any where.

 Any idea where it might be?


It's not passed as part of the request to the server.  The stuff after the
hash is a client-side construct.


 Thanks,
 Xavi

 



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



[Lift] How do I hook up JS events to onsubmit on a lift-controlled form?

2009-09-08 Thread DMB

Hi, folks,

I'm moving one of my old ruby based apps over to Scala/Lift to learn
Lift better, and here's one thing I was not able to find how to do.

Some forms in the old app have onsubmit event on the form tag which
combines / pre-validates things in the form, puts the output into a
hidden field and wipes some of the fields prior to submitting.

I can't seem to find a way to hook up a JS event to a Lift form
defined like so:

lift:IndexView.show form=post

If I add onsubmit event to this tag, it simply gets ignored. How do I
do this in Lift?

Also, Ruby on Rails conveniently appends an integer value at the end
of script and CSS urls, which comes in handy when you want to maximize
caching but don't want to risk serving the old scripts and stylesheets
to the users. Is there a corresponding mechanism for this in Lift?

Thank you.

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



[Lift] Re: Lift WebServices

2009-09-08 Thread David Pollak
On Tue, Sep 8, 2009 at 4:19 PM, abruzzo java.peri...@gmail.com wrote:


 Whoops! Should have looked there. That fixed it. Thanks again for the
 help.


Sure thing.



 On Sep 8, 4:44 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
  You declared the LiftFilter twice in your web.xml file:
 
filter
  filter-nameLiftFilter/filter-name
  display-nameLift Filter/display-name
  descriptionThe Filter that intercepts lift calls/description
  filter-classnet.liftweb.http.LiftFilter/filter-class
/filter
 
  THis caused the filter to be loaded twice.
 
  Remove one of the filter declarations and you should be fine.
 
 
 
  On Tue, Sep 8, 2009 at 9:43 AM, abruzzo java.peri...@gmail.com wrote:
 
   I'm trying to set up a simple web service using Lift v1.0. I've
   scoured
   across many examples but because of changes in the api's, none of them
   compile. I finally found an example of a dispatcher tha compiles but
   in the
   sample as in others the dispatcher is added in the boot method of the
   Boot
   class as follows:
 
  LiftRules.dispatch.prepend(RestApi.dispatch)
 
   This compiles fine however, upon startup I get the following stack:
 
   ERROR - Failed to Boot
   java.lang.IllegalStateException: Cannot modify after boot.
  at
 net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:885)
  at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:892)
  at
 net.liftweb.http.RulesSeq$$anon$3.prepend(LiftRules.scala:872)
  at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:581)
  at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:572)
  at net.liftweb.http.LiftFilter.init(LiftServlet.scala:548)
  at
 org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
   97)
  at org.mortbay.component.AbstractLifeCycle.start
   (AbstractLifeCycle.java:50)
  at
   org.mortbay.jetty.servlet.ServletHandler.initialize
   (ServletHandler.java:653)
  at
 org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
  at
   org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
   1239)
  at
   org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
   517)
  at
   org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
   466)
  at
   org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart
   (Jetty6PluginWebAppContext.java:124)
  at org.mortbay.component.AbstractLifeCycle.start
   (AbstractLifeCycle.java:50)
  at
   org.mortbay.jetty.handler.HandlerCollection.doStart
   (HandlerCollection.java:152)
  at
   org.mortbay.jetty.handler.ContextHandlerCollection.doStart
   (ContextHandlerCollection.java:156)
  at org.mortbay.component.AbstractLifeCycle.start
   (AbstractLifeCycle.java:50)
  at
   org.mortbay.jetty.handler.HandlerCollection.doStart
   (HandlerCollection.java:152)
  at org.mortbay.component.AbstractLifeCycle.start
   (AbstractLifeCycle.java:50)
  at
   org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
   130)
  at org.mortbay.jetty.Server.doStart(Server.java:224)
  at org.mortbay.component.AbstractLifeCycle.start
   (AbstractLifeCycle.java:50)
  at
   org.mortbay.jetty.plugin.Jetty6PluginServer.start
   (Jetty6PluginServer.java:132)
  at
   org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty
   (AbstractJettyMojo.java:441)
  at
   org.mortbay.jetty.plugin.AbstractJettyMojo.execute
   (AbstractJettyMojo.java:383)
  at
   org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute
   (AbstractJettyRunMojo.java:210)
  at
   org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:
   184)
  at
   org.apache.maven.plugin.DefaultPluginManager.executeMojo
   (DefaultPluginManager.java:451)
  at
   org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
   (DefaultLifecycleExecutor.java:558)
  at
  
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal
   (DefaultLifecycleExecutor.java:512)
  at
   org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
   (DefaultLifecycleExecutor.java:482)
  at
 
  
 org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
   (DefaultLifecycleExecutor.java:330)
  at
   org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
   (DefaultLifecycleExecutor.java:291)
  at
   org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
   (DefaultLifecycleExecutor.java:142)
  at
 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
   

[Lift] Re: configuring web application

2009-09-08 Thread Naftoli Gugenheim

On whatever command line you use to launch jetty.

-
Jack Widmanjack.wid...@gmail.com wrote:

And (pardon the noobality of this question) Where do I put the
-Djetty.port=80?

On Tue, Sep 8, 2009 at 10:30 PM, Naftoli Gugenheim naftoli...@gmail.comwrote:

 -Djetty.port=80 I think.
 Or set up a front end web server like nginx or apache that routes between
 80 and 8080.

 -
 jackjack.wid...@gmail.com wrote:


 Simple, but appropriate, I think, question.

 I am using jetty on port 8080. How do configure my server so that when
 people just type in my domain name, they get the index.html of my
 application. Its been a few years since I did this.


 


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



[Lift] JsonHandler stops working

2009-09-08 Thread dave

Hi,

I am new to lift so I hope this is not an ignorant question/problem.
I am having a problem where my json handler stops working. I believe
it is timing out independent of the session.
If I have my browser open for a short while, the json functions stop
working but the ajax functions keep working. I have tried to track the
time and find more details but I have not found the exact timeout. I
believe it might be the 10 minute default timeout. It appears that the
json functions continue to work if they are periodically called.
Refreshing the page does not help. The json functions work again if I
delete the cookie (and thus, get a new session).

This problem also occurs at http://demo.liftweb.net/json_more (This is
the example I started with.)
In the demo app the server interaction on the json_more page stops
working but the server interaction from AJAX Samples still works.

I have tried changing LiftRules.enableLiftGC but this did not fix the
problem.
I have also tried the JsonHandler both as and not as a SessionVar.
I have looked at S.functionLifespan but I am not sure how a app can
use this. It seems to mostly be used internally when manipulating the
function list.

Is there a way I prevent my json handler from being garbage collected
or a way to touch it periodically so that it does not expire?

I am using liftweb-1.1m4 and jetty 6.1.20.

In the time I wrote this, I was able to reproduce the problem on
demo.liftweb.net.

Thanks,
Dave

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



[Lift] Re: JsonHandler stops working

2009-09-08 Thread David Pollak
This is a bug that was introduced a few months ago and fixed last week.
 It'll be fixed in M5 and the fix is available on SNAPSHOT.

On Tue, Sep 8, 2009 at 9:04 PM, dave dinosau...@gmail.com wrote:


 Hi,

 I am new to lift so I hope this is not an ignorant question/problem.
 I am having a problem where my json handler stops working. I believe
 it is timing out independent of the session.
 If I have my browser open for a short while, the json functions stop
 working but the ajax functions keep working. I have tried to track the
 time and find more details but I have not found the exact timeout. I
 believe it might be the 10 minute default timeout. It appears that the
 json functions continue to work if they are periodically called.
 Refreshing the page does not help. The json functions work again if I
 delete the cookie (and thus, get a new session).

 This problem also occurs at http://demo.liftweb.net/json_more (This is
 the example I started with.)
 In the demo app the server interaction on the json_more page stops
 working but the server interaction from AJAX Samples still works.

 I have tried changing LiftRules.enableLiftGC but this did not fix the
 problem.
 I have also tried the JsonHandler both as and not as a SessionVar.
 I have looked at S.functionLifespan but I am not sure how a app can
 use this. It seems to mostly be used internally when manipulating the
 function list.

 Is there a way I prevent my json handler from being garbage collected
 or a way to touch it periodically so that it does not expire?

 I am using liftweb-1.1m4 and jetty 6.1.20.

 In the time I wrote this, I was able to reproduce the problem on
 demo.liftweb.net.

 Thanks,
 Dave

 



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