Re: [Lift] method call from out of nowhere
It is called outside from an Actor, everytime a new item is created. thanks. Where is joinOtherOrders()called within your code? alex On Sun, Nov 29, 2009 at 7:24 AM, Hannes hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hey Lifters, I've some really strange things going on here. Please consider this method definition. I've put alot of print debug statements between other statements. There's a while-loop that only starts, when the given list (orders) is not empty. It stops when done is set to true. So far, so good. Than, have a look at the Lift output. I put in a comment, pointing out where the program runs into the while loop. What really shocks me, are these print statements : before done=false after done=true i += 1 outside while INFO - Service request (GET) / took 121 Milliseconds start of joinAll! The loop ends with outside while and than the method gets called again immediately! But who calls it? I don't Any ideas? thanks. method definition -- def joinOtherOrders: Unit = { def joinAll(orders: List[LimitOrder]) = { println(start of joinAll!) var done = false var i = 0 while (!orders.isEmpty !done) { println(i= + i + , + orders.isEmpty= + orders.isEmpty + , + done= + done) if (this.lots.is http://this.lots.is == orders(i).lots.is http://lots.is){ println(case-1) println(this= + this + , orders(i)= + orders(i)) this.open(orders(i)) done = true } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-2) println(this= + this + , orders(i)= + orders(i)) orders(i).reduceLots(this.lots.is http://this.lots.is) val newOrder = orders(i).cloneWith(this.lots.is http://this.lots.is) newOrder.save this.open(newOrder) println(before done= + done) done = true println(after done= + done) } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-3) println(this= + this + , orders(i)= + orders(i)) this.reduceLots(orders(i).lots.is http://lots.is) val newOrder = this.cloneWith(orders(i).lots.is http://lots.is) newOrder.save newOrder.open(orders(i)) } i += 1 println(i += 1) } println(outside while) } def findLimitOrdersById: List[LimitOrder] = this.findCandidates.map(x = LimitOrderMetaObj.findAll( By(LimitOrderMetaObj.id, x)).head) joinAll(findLimitOrdersById) } -- Lift Output --- [INFO] Started Jetty Server [INFO] Starting scanner at interval of 5 seconds. INFO - Service request (GET) /comet_request/54834680365/y7kybsmuyv1g took 64 Milliseconds INFO - Service request (GET) /comet_request/85319966940/y7kybsmuyv1g took 23 Milliseconds INFO - Service request (GET) /favicon.ico took 86 Milliseconds INFO - Service request (GET) /comet_request/41521581405/y7kybsmuyv1g took 48 Milliseconds INFO - Service request (GET) /comet_request/93176242746/y7kybsmuyv1g took 7 Milliseconds INFO - Service request (GET) /favicon.ico took 38 Milliseconds INFO - Service request (GET) /favicon.ico took 5 Milliseconds INFO - Service request (GET) / took 551 Milliseconds INFO - Service request (GET) /comet_request/81361316835/y7kybsmuyv1g took 9 Milliseconds INFO - Service request (GET) /favicon.ico took 16 Milliseconds INFO - Service request (GET) / took 61 Milliseconds INFO - Service request (GET) /comet_request/76898140873/y7kybsmuyv1g took 30 Milliseconds INFO - Service request (GET) /comet_request/e8jesgmo10oq/cometAjax.js took 14 Milliseconds INFO - Service request (GET) / took 354 Milliseconds INFO - Service request (GET) / took 734 Milliseconds INFO - Service request (GET) / took 484 Milliseconds INFO - Service request (GET) /images/ajax-loader.gif took 7 Milliseconds INFO - Service request
Re: [Lift] Re: method call from out of nowhere
Hi Marius, the method is called from an Actor, everytime a new order is created. I did override def afterCreate in my LimitOrder MetaObject. thanks. In your code in what conditions joinOtherOrders gets called ? Br's, Marius On Nov 29, 6:18 pm, Hannes hannes.flo...@gmx.li wrote: Hi Tim, Hannes, Firstly, I really, really wouldn't write your code like that... Things of note: - two defs inside defs... you usually wouldnt do this without a good reason (like SHtml.submit(whatever _)) The two defs only make sence together, that's why I put them together in one def. I think that's encapsulation... - dont use while loops. period. you have a List[T], use foreach if you have a unit operation Yeah, that's true. But the problem is, that my logic requires to stop the iteration at some point. How I gonna do that with a foreach construct? def joinAll(orders: List[LimitOrder]): Unit = orders.foreach(order = { // your logic here }) You should look to remove a lot of that boiler plate... its looks very javaish and mutable. Generally speaking, scala programmers avoid mutable state like one would avoid bubonic plague. Your totally right! Its mutable, cause its changing the state of my objects. But that's necessary at this point. Before worrying about the errors, id change your code, then take another look... its almost certainly this bad organisation causing the issues. I agree with you, that this is not the most beautiful code I every saw, but I believe that the things you mentioned are not interfering with the problem I'm facing. At least not because of a while-loop and some inner local defs. Cheers, Tim thanks. On 29 Nov 2009, at 15:24, Hannes wrote: Hey Lifters, I've some really strange things going on here. Please consider this method definition. I've put alot of print debug statements between other statements. There's a while-loop that only starts, when the given list (orders) is not empty. It stops when done is set to true. So far, so good. Than, have a look at the Lift output. I put in a comment, pointing out where the program runs into the while loop. What really shocks me, are these print statements : before done=false after done=true i += 1 outside while INFO - Service request (GET) / took 121 Milliseconds start of joinAll! The loop ends with outside while and than the method gets called again immediately! But who calls it? I don't Any ideas? thanks. method definition -- def joinOtherOrders: Unit = { def joinAll(orders: List[LimitOrder]) = { println(start of joinAll!) var done = false var i = 0 while (!orders.isEmpty !done) { println(i= + i + , + orders.isEmpty= + orders.isEmpty + , + done= + done) if (this.lots.is == orders(i).lots.is){ println(case-1) println(this= + this + , orders(i)= + orders(i)) this.open(orders(i)) done = true } if (this.lots.is orders(i).lots.is){ println(case-2) println(this= + this + , orders(i)= + orders(i)) orders(i).reduceLots(this.lots.is) val newOrder = orders(i).cloneWith(this.lots.is) newOrder.save this.open(newOrder) println(before done= + done) done = true println(after done= + done) } if (this.lots.is orders(i).lots.is){ println(case-3) println(this= + this + , orders(i)= + orders(i)) this.reduceLots(orders(i).lots.is) val newOrder = this.cloneWith(orders(i).lots.is) newOrder.save newOrder.open(orders(i))
Re: [Lift] Re: method call from out of nowhere
Timothy Perrett schrieb: The two defs only make sence together, that's why I put them together in one def. I think that's encapsulation... - dont use while loops. period. you have a List[T], use foreach if you have a unit operation If you want encapsulation, because they only make sense together, stick them in a trait - something about this inner def for your use case feels very wrong. Yeah, that's true. But the problem is, that my logic requires to stop the iteration at some point. How I gonna do that with a foreach construct? This is where I think you should evaluate your thinking. stoping iteration is a java way of working... in scala i would typically filter the list before iterating on it: orders.filter(predicate).foreach(order = { ... }) That seems to be a lot neater - my point was more go look at the other method options on List[T] rather than the code i show here is the defacto way for your use case. OK, I'm going to figure out, how to transform the while-loop into a foreach I agree with you, that this is not the most beautiful code I every saw, but I believe that the things you mentioned are not interfering with the problem I'm facing. At least not because of a while-loop and some inner local defs. Are you calling this code in a try, catch, finally block by any chance? In gets called from an Actor, everytime a new LimitOrder is created. Tim -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] method call from out of nowhere
Hi David, In my LimitOrder Meta Object, I did: override def afterCreate to inform an Actor, everytime a new Order is created. The Actor than calls the joinOtherOrders method. # I think I understand it now. Cause I'm creating new orders inside the loop at some point. But still I don' t really know, why it gets called after the old scope of joinOtherOrders ends... thanks. On Sun, Nov 29, 2009 at 7:24 AM, Hannes hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hey Lifters, How is joinOtherOrders being invoked? I've some really strange things going on here. Please consider this method definition. I've put alot of print debug statements between other statements. There's a while-loop that only starts, when the given list (orders) is not empty. It stops when done is set to true. So far, so good. Than, have a look at the Lift output. I put in a comment, pointing out where the program runs into the while loop. What really shocks me, are these print statements : before done=false after done=true i += 1 outside while INFO - Service request (GET) / took 121 Milliseconds start of joinAll! The loop ends with outside while and than the method gets called again immediately! But who calls it? I don't Any ideas? thanks. method definition -- def joinOtherOrders: Unit = { def joinAll(orders: List[LimitOrder]) = { println(start of joinAll!) var done = false var i = 0 while (!orders.isEmpty !done) { println(i= + i + , + orders.isEmpty= + orders.isEmpty + , + done= + done) if (this.lots.is http://this.lots.is == orders(i).lots.is http://lots.is){ println(case-1) println(this= + this + , orders(i)= + orders(i)) this.open(orders(i)) done = true } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-2) println(this= + this + , orders(i)= + orders(i)) orders(i).reduceLots(this.lots.is http://this.lots.is) val newOrder = orders(i).cloneWith(this.lots.is http://this.lots.is) newOrder.save this.open(newOrder) println(before done= + done) done = true println(after done= + done) } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-3) println(this= + this + , orders(i)= + orders(i)) this.reduceLots(orders(i).lots.is http://lots.is) val newOrder = this.cloneWith(orders(i).lots.is http://lots.is) newOrder.save newOrder.open(orders(i)) } i += 1 println(i += 1) } println(outside while) } def findLimitOrdersById: List[LimitOrder] = this.findCandidates.map(x = LimitOrderMetaObj.findAll( By(LimitOrderMetaObj.id, x)).head) joinAll(findLimitOrdersById) } -- Lift Output --- [INFO] Started Jetty Server [INFO] Starting scanner at interval of 5 seconds. INFO - Service request (GET) /comet_request/54834680365/y7kybsmuyv1g took 64 Milliseconds INFO - Service request (GET) /comet_request/85319966940/y7kybsmuyv1g took 23 Milliseconds INFO - Service request (GET) /favicon.ico took 86 Milliseconds INFO - Service request (GET) /comet_request/41521581405/y7kybsmuyv1g took 48 Milliseconds INFO - Service request (GET) /comet_request/93176242746/y7kybsmuyv1g took 7 Milliseconds INFO - Service request (GET) /favicon.ico took 38 Milliseconds INFO - Service request (GET) /favicon.ico took 5 Milliseconds INFO - Service request (GET) / took 551 Milliseconds INFO - Service request (GET) /comet_request/81361316835/y7kybsmuyv1g took 9 Milliseconds INFO - Service request (GET) /favicon.ico took 16 Milliseconds INFO - Service request (GET) / took 61 Milliseconds INFO - Service request (GET) /comet_request/76898140873/y7kybsmuyv1g took 30 Milliseconds INFO - Service request (GET) /comet_request/e8jesgmo10oq/cometAjax.js took 14
Re: [Lift] method call from out of nowhere
ok, I'll do that. thanks. Or you can get stack trace information from Thread. I have a utility function getCaller that does a getStackTrace and then looks at the proper element of the array. (second, third? I forget) On Mon, Nov 30, 2009 at 12:30 AM, Alex Boisvert alex.boisv...@gmail.com wrote: An easy way to determine who's calling is simply to print the call stack by adding the following line in your method, (new Exception).printStackTrace -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] radio button problem
hai again.. i try to bind the data from the db in the radio button but have an error like this: 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,net.liftweb.util.Helpers.TheBindableBindParam [object i.Slot_Time],(String, net.liftweb.http.SHtml.ChoiceHolder [String]),net.liftweb.util.Helpers.TheBindableBindParam[object i.staff_id],net.liftweb.util.Helpers.TheBindParam) this is my code: app.flatMap ({ i = bind(app,xhtml, time - i.Slot_Time, slot - SHtml.radio(Map( - i.id).keys.toList,Empty,ae=_), ae - i.staff_id, remark - SHtml.text(remark,remark=_,name- remark), ) }) -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: radio button problem
Do something like: val radios = SHtml.radio(List(business, technical), Full (preference.preference_selection), s = whatever.field(s)) bind(form, xhtml, options_one - radios.apply(0), options_two - radios.apply(1), save - SHtml.submit(Submit, submit _) ) Cheers, Tim On Nov 30, 9:29 am, mr najmi mnajm...@gmail.com wrote: hai again.. i try to bind the data from the db in the radio button but have an error like this: 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,net.liftweb.util.Helpers.TheBindableBin dParam [object i.Slot_Time],(String, net.liftweb.http.SHtml.ChoiceHolder [String]),net.liftweb.util.Helpers.TheBindableBindParam[object i.staff_id],net.liftweb.util.Helpers.TheBindParam) this is my code: app.flatMap ({ i = bind(app,xhtml, time - i.Slot_Time, slot - SHtml.radio(Map( - i.id).keys.toList,Empty,ae=_), ae - i.staff_id, remark - SHtml.text(remark,remark=_,name- remark), ) }) -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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 and LDAP
Right now there are no plans to implement this, certainly not before 2.0 (this is the first time anyone has asked for it) - if you need it specifically, it probably wouldn't be too difficult to implement within your own application. Cheers, Tim On Nov 30, 7:41 am, Xuefeng Wu ben...@gmail.com wrote: Such ashttp://code.google.com/p/rubycas-client/This CAS client library is designed to work easily with Rails. I need a CAS SSO library with Rails. Thanks. On Sat, Nov 28, 2009 at 7:55 PM, Timothy Perrett timo...@getintheloop.euwrote: What kind of integration do you want? Cheers, Tim On 28 Nov 2009, at 03:20, Xuefeng Wu wrote: Did anyone try to integrate with SSO? On Sat, Nov 28, 2009 at 12:37 AM, Marcin Jurczuk mjurc...@gmail.com wrote: That is amazing :) Probably I will need to bind to AD in near future, so this module is like fallen from heavens :) On 27 Lis, 15:11, TylerWeir tyler.w...@gmail.com wrote: http://jgoday.wordpress.com/2009/11/27/lift-ldap/ One of the requisites to start using Lift at my work, was to use LDAP authentification. So i wrote a little module lift-ldap for that and a sample app, it was damn simple! http://github.com/jgoday/lift-ldaphttp://github.com/jgoday/sample_lif... -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Scala中文社区: http://groups.google.com/group/scalacn -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Scala中文社区: http://groups.google.com/group/scalacn -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: newbie question about record
That depends on the semantic of your backend does it not? What backend are you talking to? Can you provide more information? Cheers, Tim On Nov 30, 2:58 am, Jarod Liu liuyuan...@gmail.com wrote: how to setup table/column names of a record entity.(like override dbTableName field in mapper) -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: vscaladoc broken?
Tim, The scala-tools maven site honors the package link defs. Did you do scaladoc generation as part site build or as part of scala:doc? I am assuming you did the later. And quite likely the configuration for the jvmArgs (-DpackageLinkDefs in particular) isn't getting propagated from report plugin to build plugin. Please confirm if this is the case. Either way, please raise a ticket. I'll take a look tomorrow or day after. Cheers, Indrajit On Nov 30, 4:34 am, Timothy Perrett timo...@getintheloop.eu wrote: Guys, Since IRC did the refactor on the vscaladoc package link defs, it appears that you can no longer click through classes that are not in that package. For example, clicking through to Box from any package other than lift-common does nothing from a usability perspective, I think this could be problematic for newbies as thats how a lot of people learn by hoping through class to class... if its fundamentally broken, we have a problem. IRC, can you fix this please? Cheers, Tim -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: vscaladoc broken?
Hey :-) Yeah I did a mvn scala:doc - what should one run instead? mvn site? Cheers, Tim On 30 Nov 2009, at 13:16, Indrajit Raychaudhuri wrote: Tim, The scala-tools maven site honors the package link defs. Did you do scaladoc generation as part site build or as part of scala:doc? I am assuming you did the later. And quite likely the configuration for the jvmArgs (-DpackageLinkDefs in particular) isn't getting propagated from report plugin to build plugin. Please confirm if this is the case. Either way, please raise a ticket. I'll take a look tomorrow or day after. Cheers, Indrajit On Nov 30, 4:34 am, Timothy Perrett timo...@getintheloop.eu wrote: Guys, Since IRC did the refactor on the vscaladoc package link defs, it appears that you can no longer click through classes that are not in that package. For example, clicking through to Box from any package other than lift-common does nothing from a usability perspective, I think this could be problematic for newbies as thats how a lot of people learn by hoping through class to class... if its fundamentally broken, we have a problem. IRC, can you fix this please? Cheers, Tim -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Feedback on wizard code
On Sun, Nov 29, 2009 at 3:57 PM, Timothy Perrett timo...@getintheloop.euwrote: David, So I took a close look at the lift-wizard code with a view to do what we discussed on the committers call. From that, I have the following feedback and questions: - Wizard.scala, L192... You have hardcoded html tables; IMHO, these need to go, ASAP! The code looks through a list of places for the template and only returns the hard-coded XML if *a template is not found anywhere else*. The template is automatically included in the archetype. But, I am absolutely unwilling to have wizard code that doesn't work because the developer didn't include a template. One way or another, a graceful degradation will happen. This will not change. Id suggest replacing them with a CSS div from blueprint or similar. I do however see that you can override this using wizard-all.html in templates-hidden... pretty cool, but not obvious - shall i document this more in the comments? Feel free to document the process for selecting a template as well as the bind points in the template. - There is a lot of code in Wizard.scala; it would be easier to navigate if it were broken into different files - the whole thing needs a lot more commenting. Im happy to add this if you want...? It's possible to move StringField and IntField to another file. The rest of the stuff is part of the single Wizard trait and it's be difficult/impossible to break this into multiple files without losing protection scopes. - Mapper appears to be a hard dependency It's not a hard dependency. You are not *required* to use a JDBC transaction. if you want a persistable wizard as it relies on the mapper transaction block... It is possible to do the common use case of explicitly using DB's transations. While DB is part of mapper, it's conceptually a vendor of JDBC connections and is used by the JDBC stuff in Record as well. Wizard stuff is run within the scope of an HTTP request and any transaction stuff you have as part of that HTTP request will surround the execution of the Wizard's finish block. could this be made more generic so the persistence mech could be JPA etc? Is it possible to do a Mapper transaction using the JTA module? - In order to load the wizard dynamically from some serialised form (xml, json or whatever) would I be right in saying that its a matter of creating a subtype that overrides the following declarations: + Wizard.screens + Wizard#Screen.screenFields + Wizard#Screen#Field.validate Yep. What do you think? Cheers, Tim -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: vscaladoc broken?
Short answer: Use mvn site for a couple of days to have the package link defs work, but ideally mvn scala:doc should be consistent. I'll fix that, give me a day or two please. Long answer: mvn site picks up plugin settings from reporting section and mvn scala:doc picks up plugin settings from build section. The trick (jvmArg -DpackageLinkDefs) is done in the maven-scala-plugin configuration in the reporting section. Per Maven's documentation build plugin settings (and thus config) should be picked up from their corresponding settings in reporting section (odd, but true). Strangely, that's happening for all the config elements except for jvmArgs/. So I'll go ahead and duplicate jvmArgs/ section in both places:report plugin and build plugin. Pain: Next up, you, or somebody else who is regularly doing mvn scala:doc locally (and want to stay offline) would find that with mvn site (or mvn scala:doc when the fix is in) you end up having the click thru to different package classes land up somewhere in http://scala-tools.org/mvnsites-snapshots/ instead of local filesystem. This is because, by default vscaladoc.links.liftweb.baseurl is set to http://scala-tools.org/mvnsites-snapshots/liftweb. Adjust this using -Dvscaladoc.links.liftweb.baseurl=local_lift_base during mvn site to circumvent that. Cheers, IRC On 30/11/09 7:00 PM, Timothy Perrett wrote: Hey :-) Yeah I did a mvn scala:doc - what should one run instead? mvn site? Cheers, Tim On 30 Nov 2009, at 13:16, Indrajit Raychaudhuri wrote: Tim, The scala-tools maven site honors the package link defs. Did you do scaladoc generation as part site build or as part of scala:doc? I am assuming you did the later. And quite likely the configuration for the jvmArgs (-DpackageLinkDefs in particular) isn't getting propagated from report plugin to build plugin. Please confirm if this is the case. Either way, please raise a ticket. I'll take a look tomorrow or day after. Cheers, Indrajit On Nov 30, 4:34 am, Timothy Perretttimo...@getintheloop.eu wrote: Guys, Since IRC did the refactor on the vscaladoc package link defs, it appears that you can no longer click through classes that are not in that package. For example, clicking through to Box from any package other than lift-common does nothing from a usability perspective, I think this could be problematic for newbies as thats how a lot of people learn by hoping through class to class... if its fundamentally broken, we have a problem. IRC, can you fix this please? Cheers, Tim -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: A sensible AJAX approach
David, Thanks a bunch. Your solution is one I was trying to implement but wasn't quite sure how until you showed me that I can create an AnonFunc using Shtml.ajaxCall. It certainly does simplify things. One of the issues that stymied me - and still does, frankly - is how the ajaxCall wraps the edit function with the correct parameter for the callback to work. I updated the code in http://github.com/glennSilverman/treeview and refactored it into a MetaMegaTreeItem trait to easily add these features to any Mapper object. Maybe some Lift committer might find the ideas involved here usefull enough to include something similar in a future release of Lift. Glenn . On Nov 24, 5:53 pm, David Pollak feeder.of.the.be...@gmail.com wrote: Glenn, The issue is that you were creating call-back functions during an API call (rather than as part of Lift's HTML/Ajax/Comet pipeline). In general, I think this is very bad design. I'd strongly recommend using the Ajax/Json call facilities built into Lift. You get a pile of things for free including securing calls (you don't need to keep a lot of state client-side). So, your code looks like: def buildTree(in:NodeSeq):NodeSeq = { val func = AnonFunc( SHtml.ajaxCall(JsRaw(this.id), (id: String) = SetHtml(role_edit, Role.find(id).map(edit) openOr NodeSeq.Empty))._2 ) TreeView(tree, JsObj((persist, location), (toggle, func)), loadTree, loadNode) } Also, you might want to look at S.hostAndPort for calculating the current server. Also, think about using the map() call rather than pattern matching on Full/_. Also, there's no need to register API calls in SiteMap I'll update your app and push code tohttp://github.com/dpp/treeview Thanks, David On Tue, Nov 24, 2009 at 8:02 AM, glenn gl...@exmbly.com wrote: David, The statement that all functions are bound to the current state in the scope that the function was created may be true for functions submitted via SHtml, but doesn't seem to hold true for those from LiftResponse, otherwise, the edit function in my example would work for editing, just as it does for creating. In any case, I'm still at a loss on how to fix this. Glenn On Nov 20, 5:40 pm, glenn gl...@exmbly.com wrote: David, I was able to put together a simplified application to demo the problem. It's just a basic lift archetype with a Role.scala added to the mapper package that contains all the relevant code. Here is the link to the application: http://github.com/glennSilverman/treeview If you run it as-is, you can add new roles to the db but you can't edit them. Glenn On Nov 20, 10:28 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Nov 20, 2009 at 10:14 AM, glenn gl...@exmbly.com wrote: David, That's what I thought. All I needed to do was create the Mapper.toForm like so: item.toForm(Full(Save), { _.save }) and the item would be saved on submit. But it doesn't work in my case. Please put together a complete runnable example of it not working for you and we'll debug it. Glenn On Nov 20, 10:05 am, David Pollak feeder.of.the.be...@gmail.com wrote: Glenn, All functions are bound to the current state in the scope that the function was created. There's no need to do weird RequestVar things with Hidden fields or anything else. If you've got a function passed to SHtml.text, submit, etc. that function closes over its local scope: it captures all the variables it refers to. So: def mySnippet = { val myInstance = MyTable.find(whatever) SHtml.ajaxCheckbox(..., bool = {myInstance.boolField(bool).save; Noop}) } In the above code, you've captured the instance in the val myInstance... that's kept around for the lifespan of the function that you passed to ajaxCheckbox. Thanks, David On Fri, Nov 20, 2009 at 9:45 AM, glenn gl...@exmbly.com wrote: I've been following this thread as lately I'm having difficulty with an ajax-submitted request in my app. Here's the scenario (There's no simple way to describe this, so bear with me): I create a JQuery tree of my data (Mapper object with just an item name and a parent Mapper object as it's fields) as follows: def buildTree(in:NodeSeq):NodeSeq = { object MyJqLoad { def apply(content: JsExp) = new JsExp with JQueryRight with JQueryLeft { def toJsCmd = JqId(json_result).toJsCmd + .load( + content.toJsCmd + JsRaw(+this.id) + ) } } val host = http://; + S.hostName val link = host + :8080 + S.contextPath + /api/json/ + dbTableName.toLowerCase + / val func = AnonFunc( MyJqLoad(link)) TreeView(tree, JsObj((persist, location), (toggle, func)),
[Lift] Re: How to get the servlet context
Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett timo...@getintheloop.eu wrote: Here's a nugget of information for you that will help (as I do something similar to what you want in one of my applications): val protectionDomain: ProtectionDomain = classOf[bootstrap.liftweb.Boot].getProtectionDomain() val location: URL = protectionDomain.getCodeSource().getLocation() Print the value of location, and that will get you headed in the right direction ;-) Moreover, if your using jetty, if there is a work directory next to where the war file is, jetty will automatically expand the war into that work folder... if not, it makes a temp directory in the relevant OS temp directory (/var/tmp on *nix OS) Godspeed. Tim. On 27 Nov 2009, at 21:49, Heiko Seeberger wrote: Job, This directory is managed by the servlet container and as far as I know there is little you can do to configure the location. If you use Tomcat you are able to specify CATALINA_BASE and it will be somewhere beneath that directory, I believe it is work/Catalina/localhost/WABAPP-NAME. Regarding serving images from there: Depending on the configuration of the servlet container WARs are not unpacked, hence there is no standard way to bring these images into your webapp. I think you will not be able to have the servlet container serve these images directly. But it should be easy to write a ServletFilter or something that will do it for you. Heiko 2009/11/27 jhonig al...@xs4all.nl Heiko, In the meantime, I found that solution as well... I tried it, and the default seems to be a work directory in target. I guess I can set another value for the attribute if I manage to convince jetty to do that for me. What I forgot to mention is that the directory is to contain images that are to be served by jetty... So it means the directory should be logically under webapp, but not in the war (of course). If I use a link from inside the war to some regular file system location, I'll probably run into the same problem as before. Any idea how to do this? Job H. On Nov 27, 6:56 pm, Heiko Seeberger heiko.seeber...@googlemail.com wrote: File tempdir = (File) config.getServletContext().getAttribute(javax.servlet.context.tempdir) 2009/11/27 jhonig al...@xs4all.nl Dear Heiko, According to the Servlet spec each webapp has got a private temporary directory. I cannot remember exactly how to get this, maybe
[Lift] Re: How to get the servlet context
Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett timo...@getintheloop.eu wrote: Here's a nugget of information for you that will help (as I do something similar to what you want in one of my applications): val protectionDomain: ProtectionDomain = classOf[bootstrap.liftweb.Boot].getProtectionDomain() val location: URL = protectionDomain.getCodeSource().getLocation() Print the value of location, and that will get you headed in the right direction ;-) Moreover, if your using jetty, if there is a work directory next to where the war file is, jetty will automatically expand the war into that work folder... if not, it makes a temp directory in the relevant OS temp directory (/var/tmp on *nix OS) Godspeed. Tim. On 27 Nov 2009, at 21:49, Heiko Seeberger wrote: Job, This directory is managed by the servlet container and as far as I know there is little you can do to configure the location. If you use Tomcat you are able to specify CATALINA_BASE and it will be somewhere beneath that directory, I believe it is work/Catalina/localhost/WABAPP-NAME. Regarding serving images from there: Depending on the configuration of the servlet container WARs are not unpacked, hence there is no standard way to bring these images into your webapp. I think you will not be able to have the servlet container serve these images directly. But it should be easy to write a ServletFilter or something that will do it for you. Heiko 2009/11/27 jhonig al...@xs4all.nl Heiko, In the meantime, I found that solution as well... I tried it, and the default seems to be a work directory in target. I guess I can set another value for the attribute if I manage to convince jetty to do that for me. What I forgot to mention is that the directory is to contain images that are to be served by jetty... So it means the directory should be logically under webapp, but not in
Re: [Lift] How to get the servlet context
All this is brittle, at least special! Please use the temp dir the servlet context will offer you. Tomcat and Jetty offer one. Heiko On Monday, November 30, 2009, jhonig al...@xs4all.nl wrote: Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett timo...@getintheloop.eu wrote: Here's a nugget of information for you that will help (as I do something similar to what you want in one of my applications): val protectionDomain: ProtectionDomain = classOf[bootstrap.liftweb.Boot].getProtectionDomain() val location: URL = protectionDomain.getCodeSource().getLocation() Print the value of location, and that will get you headed in the right direction ;-) Moreover, if your using jetty, if there is a work directory next to where the war file is, jetty will automatically expand the war into that work folder... if not, it makes a temp directory in the relevant OS temp directory (/var/tmp on *nix OS) Godspeed. Tim. On 27 Nov 2009, at 21:49, Heiko Seeberger wrote: Job, -- Heiko Seeberger My job: weiglewilczek.com My blog: heikoseeberger.name Follow me: twitter.com/hseeberger OSGi on Scala: scalamodules.org Lift, the simply functional web framework: liftweb.net -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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 to get the servlet context
Ahh so you want direct links to those files. Still you can do something else. Point your URI's from your page to a specific uri such as /myapp/serve/myimage.jpg. You intercept requests to myapp :: serve :: _ using a DispatchPF. The dispatch PF knows about your folder location (presumably from a config file) and reads myimage.jpg from that path on the file system. Hence you can read the File and send it to the client. I think you can use Lift's StreamResponse or you can build your own LiftResponse that returns a file using proper Content-Type. Another approach would be to use a reverse proxy server in front of your Lift application (this is a common production deployment model that server static content from frontend server not app servers), your Lift application could simply write files in the document-root folder hence would be seen by the proxy server and served to the client. I used in the past both options with no problem at all for use cases not so different than yours. Brs, Marius On Nov 30, 11:36 pm, jhonig al...@xs4all.nl wrote: Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett timo...@getintheloop.eu wrote: Here's a nugget of information for you that will help (as I do something similar to what you want in one of my applications): val protectionDomain: ProtectionDomain = classOf[bootstrap.liftweb.Boot].getProtectionDomain() val location: URL = protectionDomain.getCodeSource().getLocation() Print the value of location, and that will get you headed in the right direction ;-) Moreover, if your using jetty, if there is a work directory next to where the war file is, jetty will automatically expand the war into that work folder... if not, it makes a temp directory in the relevant OS temp directory (/var/tmp on *nix OS) Godspeed. Tim. On 27 Nov 2009, at 21:49, Heiko Seeberger wrote: Job, This directory is managed by the servlet container and as far as
[Lift] Re: newbie question about record
I think there is a general interest for a non-trivial Record example. Maybe kill two birds with one stone and connect to a NoSQL store. On Nov 30, 5:26 am, Timothy Perrett timo...@getintheloop.eu wrote: That depends on the semantic of your backend does it not? What backend are you talking to? Can you provide more information? Cheers, Tim On Nov 30, 2:58 am, Jarod Liu liuyuan...@gmail.com wrote: how to setup table/column names of a record entity.(like override dbTableName field in mapper) -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: How to get the servlet context
Storing files inside the exploded WAR file is a tremendously bad idea. I don't think we should be helping a user do something that is going to continue to cause him pain. If he needs to upload images, etc. and then subsequently present them to the user, it's two tables in the RDBMS and a single stateless dispatch. All in all 40 lines of code and no pain. On Mon, Nov 30, 2009 at 2:08 PM, Marius marius.dan...@gmail.com wrote: Ahh so you want direct links to those files. Still you can do something else. Point your URI's from your page to a specific uri such as /myapp/serve/myimage.jpg. You intercept requests to myapp :: serve :: _ using a DispatchPF. The dispatch PF knows about your folder location (presumably from a config file) and reads myimage.jpg from that path on the file system. Hence you can read the File and send it to the client. I think you can use Lift's StreamResponse or you can build your own LiftResponse that returns a file using proper Content-Type. Another approach would be to use a reverse proxy server in front of your Lift application (this is a common production deployment model that server static content from frontend server not app servers), your Lift application could simply write files in the document-root folder hence would be seen by the proxy server and served to the client. I used in the past both options with no problem at all for use cases not so different than yours. Brs, Marius On Nov 30, 11:36 pm, jhonig al...@xs4all.nl wrote: Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett timo...@getintheloop.eu wrote: Here's a nugget of information for you that will help (as I do something similar to what you want in one of my applications): val protectionDomain: ProtectionDomain = classOf[bootstrap.liftweb.Boot].getProtectionDomain() val location: URL =
Re: [Lift] MetaMapper - Count with Group By?
On Fri, Nov 27, 2009 at 10:07 PM, Joern joern.bernha...@gmx.net wrote: Hi there, is it possible, to create a select statement like SELECT user_id, count(*) FROM table GROUP BY user_id with the MetaMapper? No. Sorry. You could do: DB.runQuery(SELECT user_id, count(*) FROM table GROUP BY user_id, Nil) I want to let users get statistical information about some tables like how many news did that guy / the top 5 posters write or how many news are in each category. Thanks, Joern -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: lift-json escaping bug
He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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 . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: lift-json escaping bug
If you file an issue on github I'll write up a patch for you tonight. -Ross On Nov 30, 2009, at 6:30 PM, harryh wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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 . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
Here's the complete list from http://json.org/: char: Any Unicode character except or \ or control-character. \ \\ \/ \b \f \n \r \t \u four-hex-digits - n On Nov 30, 6:30 pm, harryh har...@gmail.com wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField(id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: lift-json escaping bug
What I find particularly interesting is that the JSON spec lacks \', but gains \/, relative to the ECMA-262 (javascript) spec that JSON supposedly derives from. -Ross On Nov 30, 2009, at 6:34 PM, Nathan Folkman (Foursquare) wrote: Here's the complete list from http://json.org/: char: Any Unicode character except or \ or control-character. \ \\ \/ \b \f \n \r \t \u four-hex-digits - n On Nov 30, 6:30 pm, harryh har...@gmail.com wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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 . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Refactoring Round 2
On Fri, Nov 27, 2009 at 7:30 AM, Heiko Seeberger heiko.seeber...@googlemail.com wrote: Excellent proposal! +1 Heiko On Friday, November 27, 2009, Indrajit Raychaudhuri indraj...@gmail.com wrote: Folks, In continuation to the refactoring initiative and following up on the discussion that we had on the last committers call, here we have the next round of broad based project structure refactoring proposal. This is themed around the idea of splitting the build system into separate smaller 'projects' with clearly demarcated responsibilities between them. In the way, these projects can have independent life-cycles on their own without coming in the way of each other (but still continue to have a dependency hierarchy). Here are the set of projects to begin with: 1. framework (http://github.com/dpp/liftweb/tree/branch/framework): The regular Lift as we have today (minus lift-archetype, lift- examples, lift-misc). Thus we would have: framwork/pom.xml framwork/lift-base framwork/lift-persistence framwork/lift-modules 2. archetypes (http://github.com/dpp/liftweb/tree/branch/ archetypes): The lift-archetypes from Liftweb. archetypes/pom.xml archetypes/lift-archetype-blank archetypes/lift-archetype-basic archetypes/lift-archetype-jpa-blank-single archetypes/lift-archetype-jpa-blank archetypes/lift-archetype-jpa-basic 3. examples (http://github.com/dpp/liftweb/tree/branch/examples): The lift-archetypes from Liftweb. The big uptake for archetypes and examples is the reduction of build time for building full Lift. Individuals building Lift might not always be interested in building non ancillary packages like lift-archetypes and lift-examples. examples/pom.xml examples/example1 examples/example2 4. resources (http://github.com/dpp/liftweb/tree/branch/resources: 4a. project-parent: A pure POM based project to be canonically used by all Lift family of projects (liftweb, lift-archetype, lift-examples etc.). Lot of what has gone in liftweb/pom.xml should get moved here. Obviously, this would contain the most generic configuration that holds true for all projects of Lift (#1, #2, #3). 4b. site-skin: Lift specific site skin instead of relying on org.scala- tools.skins:scala-skin-simple 5. references (http://github.com/dpp/liftweb/tree/branch/ references): Lift documentations and presentations. These don't need to show up in the project hierarchy in the IDE. 6. installer (http://github.com/dpp/liftweb/tree/branch/installer): The usual lift-installer that is tucked inside lift-misc. Again, these are unnecessarily showing up in the project hierarchy in the IDE. I am floating the idea beforehand and would be keen to have input from committers, the pros and cons and any other general feedback before proceeding. Thoughts would be very welcome :) Cheers, Indrajit -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Heiko Seeberger My job: weiglewilczek.com My blog: heikoseeberger.name Follow me: twitter.com/hseeberger OSGi on Scala: scalamodules.org Lift, the simply functional web framework: liftweb.net -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: Broken 1.1-M7 jpa archetypes
On Fri, Nov 27, 2009 at 2:49 AM, Indrajit Raychaudhuri indraj...@gmail.comwrote: Fixed in snapshot repo :) The following command should give you a good project now. mvn archetype:generate -DarchetypeRepository=http://scala-tools.org/ repo-snapshots http://scala-tools.org/%0Arepo-snapshots-DremoteRepositories= http://scala-tools.org/repo- snapshots -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift- archetype-jpa-basic -DarchetypeVersion=1.1-SNAPSHOT - DgroupId=com.mypackage -DartifactId=myproject -Dversion=1.0-SNAPSHOT Thanks! Cheers, Indrajit On Nov 25, 3:23 am, David Pollak feeder.of.the.be...@gmail.com wrote: Yes. This is a known issue. Seehttp:// github.com/dpp/liftweb/issues#issue/161 On Tue, Nov 24, 2009 at 9:34 AM, Oscar Picasso oscarpica...@gmail.com wrote: It seems that 1.1-M7 jpa archetypes other than lift-archetype-jpa-basic are broken, both in snapshots and releases repositories. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: How to get the servlet context
Sometimes its an unavoidable fact that we need to store stuff on the file-system. Im not promoting inside the exploded war, but knowing your location and going from there can be a useful aid; its certainly something that i've done before with success. Cheers, Tim On 30 Nov 2009, at 22:30, David Pollak wrote: Storing files inside the exploded WAR file is a tremendously bad idea. I don't think we should be helping a user do something that is going to continue to cause him pain. If he needs to upload images, etc. and then subsequently present them to the user, it's two tables in the RDBMS and a single stateless dispatch. All in all 40 lines of code and no pain. On Mon, Nov 30, 2009 at 2:08 PM, Marius marius.dan...@gmail.com wrote: Ahh so you want direct links to those files. Still you can do something else. Point your URI's from your page to a specific uri such as /myapp/serve/myimage.jpg. You intercept requests to myapp :: serve :: _ using a DispatchPF. The dispatch PF knows about your folder location (presumably from a config file) and reads myimage.jpg from that path on the file system. Hence you can read the File and send it to the client. I think you can use Lift's StreamResponse or you can build your own LiftResponse that returns a file using proper Content-Type. Another approach would be to use a reverse proxy server in front of your Lift application (this is a common production deployment model that server static content from frontend server not app servers), your Lift application could simply write files in the document-root folder hence would be seen by the proxy server and served to the client. I used in the past both options with no problem at all for use cases not so different than yours. Brs, Marius On Nov 30, 11:36 pm, jhonig al...@xs4all.nl wrote: Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty, since I still don't know how to tell jetty to serve contents that is not under the webapp directory. Probably have to do something with the site map which I don't fully understand. Guess my main problem is that I don't have any experience in this field (jetty/lift) and thought it wouldn't be to difficult to port my website to lift and enhance it a little on the fly. To be continued... Job Honig On Nov 28, 12:52 am, Timothy Perrett
Re: [Lift] How to redirect to a specify url when logged in successfully?
On Sun, Nov 29, 2009 at 12:17 AM, Neil.Lv anim...@gmail.com wrote: Hi all, I want to redirecto to a specify URL like this /all_users when logged in successfully via the default link, http://localhost:8080/user_mgt/login Is there a help method (i dont't find it) to configure it? When i logged in successfully via /user_mgt/login link and redirect to the /all_users link not the /index page. In your User object (singleton): override def loginFirst = If( loggedIn_? _, () = { import net.liftweb.http.{RedirectWithState, RedirectState} val uri = /all_users RedirectWithState( loginPageURL, RedirectState( ()={loginRedirect.set(uri)}) ) } ) Thanks for any help. Cheers, Neil -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: How to get the servlet context
On Mon, Nov 30, 2009 at 4:14 PM, Timothy Perrett timo...@getintheloop.euwrote: Sometimes its an unavoidable fact that we need to store stuff on the file-system. Im not promoting inside the exploded war, but knowing your location and going from there can be a useful aid; its certainly something that i've done before with success. I'm all for putting stuff in a well-know location in the filesystem... and defining that well known location in the props file. Messing around with trying to figure out where the app server has exploded your WAR file (if it even has which is not AFAIK guaranteed) and putting files in there is a failure waiting to happen. Cheers, Tim On 30 Nov 2009, at 22:30, David Pollak wrote: Storing files inside the exploded WAR file is a tremendously bad idea. I don't think we should be helping a user do something that is going to continue to cause him pain. If he needs to upload images, etc. and then subsequently present them to the user, it's two tables in the RDBMS and a single stateless dispatch. All in all 40 lines of code and no pain. On Mon, Nov 30, 2009 at 2:08 PM, Marius marius.dan...@gmail.com wrote: Ahh so you want direct links to those files. Still you can do something else. Point your URI's from your page to a specific uri such as /myapp/serve/myimage.jpg. You intercept requests to myapp :: serve :: _ using a DispatchPF. The dispatch PF knows about your folder location (presumably from a config file) and reads myimage.jpg from that path on the file system. Hence you can read the File and send it to the client. I think you can use Lift's StreamResponse or you can build your own LiftResponse that returns a file using proper Content-Type. Another approach would be to use a reverse proxy server in front of your Lift application (this is a common production deployment model that server static content from frontend server not app servers), your Lift application could simply write files in the document-root folder hence would be seen by the proxy server and served to the client. I used in the past both options with no problem at all for use cases not so different than yours. Brs, Marius On Nov 30, 11:36 pm, jhonig al...@xs4all.nl wrote: Marius, I tried to create a link from the webapp dir to another location with rw-access, but that was not allowed... My conclusion was that you can't have symbolic links to locations outside the war. My problem is that there are three different locations that could all be interpreted as a root for looking up resources. I've found nothing suggesting one over the other, and none of them works. I assume there are more variables involved that I don't even know of. Job On Nov 30, 10:27 pm, Marius marius.dan...@gmail.com wrote: Ok I may be missing something essential from all this thread but why not use a folder from the user's home directory? If your app runs say under jetty OS user should heve read/write rights to write on the home user file-system. Even if not (although I haven't encountered the case) those rights can be granted by an admin. So why do you need special container allocated locations to write files? Br's, Marius On Nov 30, 11:18 pm, jhonig al...@xs4all.nl wrote: Hi Tim, Jeppe, and others who have replied... I have spent a few more hours, but there are just too many variables and I haven't been able to figure them out. I logged the various locations (running under a standalone jetty, not mvn jetty:run, and got this: INFO - TEMP = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b INFO - REAL = /tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp INFO - URL = file:/tmp/Jetty_0_0_0_0_8080_tent. 0.1.SNAPSHOT.warvtra6b/webapp/WEB-INF/classes/ I tried to access images, both from the HTML served to my browser and from Scala snippets. I used the following paths: Images/testimage.jpg work/Images/testimage.jpg classes/work/Images/testimage.jpg WEB-INF/classes/work/Images/testimage.jpg. The latter path is what I see in my .war file... I have no special filters. I tried to add entries to my site map, but none of them worked. About to give up. Hope somebody will help me. Job H. On Nov 28, 3:14 pm, jhonig al...@xs4all.nl wrote: Dear Tim and Heiko, I tested a few things under mvn jetty:run...: getRealPath gives me ./src/main/webapp the temp attribute is set to ./target/work and the location is ./target/classes While the war contains classes/work which is again different... I didn't manage to get jetty to serve contents from any other directory than the first one. Didn't try to run it on the standalone jetty,
Re: [Lift] Re: Beef with LiftRules.explicitlyParsedSuffixes
On Fri, Nov 27, 2009 at 1:52 PM, Marius marius.dan...@gmail.com wrote: For a default behavior this is a reasonable approach. But from a framework perspective this is a little limiting. In order to be more extensible I think we should allow users to plug in their own splitting functions (say a LiftRules RulesSeq of functions) and essentially determine what is suffix and what is not based on potentially some more complex rules. But that's just me ... Okay, please open a ticket and make it happen. Br's, Marius On Nov 27, 10:04 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: By the way Microsoft uses some really long suffixes, e.g., MS Access Developer Extension Deployment Wizard files, and Pocket PC emulator. -Original Message- From: David Pollak feeder.of.the.be...@gmail.com Sent: Wednesday, November 25, 2009 10:34 AM To: liftweb@googlegroups.com Subject: Re: [Lift] Beef with LiftRules.explicitlyParsedSuffixes I'm not overly keen on the whitelist stuff. Someone's going to get cranky about it. I'm open to either adding a whole lot more to the white list or saying that everything n characters (e.g., 5) is a suffix unless it's on a blacklist -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Multipage wizards
On Wed, Nov 25, 2009 at 12:30 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: David Pollak feeder.of.the.be...@gmail.com writes: Folks, I've completed the first pass at multi-page input Wizards in Lift. You can see an example at: http://demo.liftweb.net/wiz Great news! [...] The building of HTML forms from the given field type is based on the type (currently, there's support for String and Int, but more to come) and it's based on plugable functions, so you can build date pickers that are localized, etc. What needs to be done: - The naming (including the names that the various parts of the wizard bind to) need a good going-over - Support for many different input types (not just Int and String) - Feedback I've been thinking about this for a while and haven't really reached anything concrete yet, but it overlaps enough with the wizard stuff that I might just throw it out here now: I think that form handling in Lift is too cumbersome. I.e. all the building blocks are there to create great forms, but it takes too much boilerplate code to achieve a nice result. I know forms are not sexy in the ways Comet Ajax support is, but for many applications (ours included :-) it's where the major interactions with the user happens, so a good UX is essential. Here's my (ultimate) list of things that should be easy (for the developer) to do without too much fuzz: - Provide field level validations - including client side if possible - Provide form level validations - including client side - If the form contains Mapper fields, you should not have to respecify the validations - Render fields with proper markup (ie required fields should be indicated) - When a form is in error, retain values entered by the user - When a field is in error render it differently (ie red) with field specific error - Provide field level help (inline, popup etc) - Provide form level help - All fields and text should support i18n (ie both labels, text and for numeric and e.g date entries) I haven't looked closely at the wizard code yet, but it seems like it does provide some of these benefits. Some possible ideas: - Could be nice if the wizard code could be extended to generic forms. Wizards would just be a special case, with a sequence of forms and prev/next buttons etc. - I would very much like to see validations lifted to a higher level so that the same validation rule can be used for Mapper (and Record), forms wizards. - Fields should be able to emit client side validations and code - Maybe we could introduce generic form fields (ie Number, Date etc) and they could be reused by the Mapper/Record fields. In this way, they would all share the same presentation logic (ie i18n formatting for display/editing, datepickers, more advanced dialogs etc) - Much more Thoughts? Yeah this all sounds good. I'm trying to unify most of the pieces of single form inputs, validation, mapper, record and wizard. It's generally slow going. We'll soon be needing much of this in our app, so I'm willing to participate in this if there's any interest. /Jeppe -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: Lift and LDAP
Thank you for your reply and I will try. On Mon, Nov 30, 2009 at 6:25 PM, Timothy Perrett timo...@getintheloop.euwrote: Right now there are no plans to implement this, certainly not before 2.0 (this is the first time anyone has asked for it) - if you need it specifically, it probably wouldn't be too difficult to implement within your own application. Cheers, Tim On Nov 30, 7:41 am, Xuefeng Wu ben...@gmail.com wrote: Such ashttp://code.google.com/p/rubycas-client/This CAS client library is designed to work easily with Rails. I need a CAS SSO library with Rails. Thanks. On Sat, Nov 28, 2009 at 7:55 PM, Timothy Perrett timo...@getintheloop.euwrote: What kind of integration do you want? Cheers, Tim On 28 Nov 2009, at 03:20, Xuefeng Wu wrote: Did anyone try to integrate with SSO? On Sat, Nov 28, 2009 at 12:37 AM, Marcin Jurczuk mjurc...@gmail.com wrote: That is amazing :) Probably I will need to bind to AD in near future, so this module is like fallen from heavens :) On 27 Lis, 15:11, TylerWeir tyler.w...@gmail.com wrote: http://jgoday.wordpress.com/2009/11/27/lift-ldap/ One of the requisites to start using Lift at my work, was to use LDAP authentification. So i wrote a little module lift-ldap for that and a sample app, it was damn simple! http://github.com/jgoday/lift-ldaphttp://github.com/jgoday/sample_lif. .. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Scala中文社区: http://groups.google.com/group/scalacn -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Scala中文社区: http://groups.google.com/group/scalacn -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Scala中文社区: http://groups.google.com/group/scalacn -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
Done: http://github.com/dpp/liftweb/issues/#issue/214 On Nov 30, 6:33 pm, Ross Mellgren dri...@gmail.com wrote: If you file an issue on github I'll write up a patch for you tonight. -Ross On Nov 30, 2009, at 6:30 PM, harryh wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] IN Query Param
I have some slow code: val users:List[User] = Tag.findAll(By(Tag.tagType,this), OrderBy (Tag.created_at, Descending), MaxRows(100), PreCache(Tag.user)).map (_.user.obj.open_!) That I turned into faster ugly code: val users:List[User] = User.findAll(BySql(WHERE id IN (SELECT TOP 100 user from Tag where tagType = ? ORDER BY created_at DESC ), IHaveValidatedThisSQL(trevoraustin,2009-11-30), this.id)) That I want to turn into faster nicer code: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows (100))) But I get the error: no implicit argument matching parameter type (Product with net.liftweb.mapper.QueryParam[_ : com.udorse.lift.model.Tag]) = net.liftweb.mapper.QueryParam[com.udorse.lift.model.Tag] was found. If I try just: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending))) Without the MaxRows it compiles fine. Is there a limit on the QueryParams I can use with In? Am I doing something else wrong? -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: IN Query Param
Never mind, it just needed a type hint: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows[Tag] (100))) On Nov 30, 9:17 pm, Trevor Austin traus...@gmail.com wrote: I have some slow code: val users:List[User] = Tag.findAll(By(Tag.tagType,this), OrderBy (Tag.created_at, Descending), MaxRows(100), PreCache(Tag.user)).map (_.user.obj.open_!) That I turned into faster ugly code: val users:List[User] = User.findAll(BySql(WHERE id IN (SELECT TOP 100 user from Tag where tagType = ? ORDER BY created_at DESC ), IHaveValidatedThisSQL(trevoraustin,2009-11-30), this.id)) That I want to turn into faster nicer code: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows (100))) But I get the error: no implicit argument matching parameter type (Product with net.liftweb.mapper.QueryParam[_ : com.udorse.lift.model.Tag]) = net.liftweb.mapper.QueryParam[com.udorse.lift.model.Tag] was found. If I try just: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending))) Without the MaxRows it compiles fine. Is there a limit on the QueryParams I can use with In? Am I doing something else wrong? -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: IN Query Param
On Mon, Nov 30, 2009 at 6:25 PM, Trevor Austin traus...@gmail.com wrote: Never mind, it just needed a type hint: Sometimes the type inferencer gets it right and sometimes it needs some extra help. val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows[Tag] (100))) On Nov 30, 9:17 pm, Trevor Austin traus...@gmail.com wrote: I have some slow code: val users:List[User] = Tag.findAll(By(Tag.tagType,this), OrderBy (Tag.created_at, Descending), MaxRows(100), PreCache(Tag.user)).map (_.user.obj.open_!) That I turned into faster ugly code: val users:List[User] = User.findAll(BySql(WHERE id IN (SELECT TOP 100 user from Tag where tagType = ? ORDER BY created_at DESC ), IHaveValidatedThisSQL(trevoraustin,2009-11-30), this.id)) That I want to turn into faster nicer code: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending), MaxRows (100))) But I get the error: no implicit argument matching parameter type (Product with net.liftweb.mapper.QueryParam[_ : com.udorse.lift.model.Tag]) = net.liftweb.mapper.QueryParam[com.udorse.lift.model.Tag] was found. If I try just: val users:List[User] = User.findAll(In(User.id, Tag.user, By (Tag.tagType, this), OrderBy(Tag.created_at, Descending))) Without the MaxRows it compiles fine. Is there a limit on the QueryParams I can use with In? Am I doing something else wrong? -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] Re: lift-json escaping bug
On review board: http://reviewboard.liftweb.net/r/131/ I did run across another infelicity when writing the test -- apparently JsonParser crashes when given a scalar value, as opposed to an array or object: scala parse(\foobar\) net.liftweb.json.JsonParser$ParseException: unexpected null Near: foobar at net.liftweb.json.JsonParser$Parser.fail(JsonParser.scala:166) at net.liftweb.json.JsonParser$ValStack.peek(JsonParser.scala:153) at net.liftweb.json.JsonParser$.newValue$1(JsonParser.scala:110) at net.liftweb.json.JsonParser$.parse0(JsonParser.scala:125) at net.liftweb.json.JsonParser$.parse(JsonParser.s... I'm not sure if it should work, but even if it shouldn't support that the error case should probably give a better message. Joni/et al? -Ross On Nov 30, 2009, at 8:33 PM, harryh wrote: Done: http://github.com/dpp/liftweb/issues/#issue/214 On Nov 30, 6:33 pm, Ross Mellgren dri...@gmail.com wrote: If you file an issue on github I'll write up a patch for you tonight. -Ross On Nov 30, 2009, at 6:30 PM, harryh wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] **URGENT** Archetypes broken
Folks, Somehow somebody broke the basic archetype. This is not acceptable. Here's what I typed and here's what happened: d...@sevenof9:~/tmp$ cat /home/dpp/bin/new_lift #!/bin/sh mvn archetype:create -U -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=1.1-SNAPSHOT \ -DremoteRepositories=http://scala-tools.org/repo-snapshots \ -DgroupId=$1 -DartifactId=$2 d...@sevenof9:~/tmp$ new_lift com.liftcode imagine [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] org.apache.maven.plugins: checking for updates from central [INFO] org.codehaus.mojo: checking for updates from central [INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central [INFO] [INFO] Building Maven Default Project [INFO]task-segment: [archetype:create] (aggregator-style) [INFO] [INFO] Setting property: classpath.resource.loader.class = 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on = 'false'. [INFO] Setting property: resource.loader = 'classpath'. [INFO] Setting property: resource.manager.logwhenfound = 'false'. [INFO] [archetype:create {execution: default-cli}] [WARNING] This goal is deprecated. Please use mvn archetype:generate instead [INFO] Defaulting package to group ID: com.liftcode [INFO] We are using command line specified remote repositories: http://scala-tools.org/repo-snapshots [INFO] snapshot net.liftweb:lift-archetype-basic:1.1-SNAPSHOT: checking for updates from id0 Downloading: http://scala-tools.org/repo-snapshots/net/liftweb/lift-archetype-basic/1.1-SNAPSHOT/lift-archetype-basic-1.1-SNAPSHOT.jar [INFO] [INFO] Using following parameters for creating OldArchetype: lift-archetype-basic:1.1-SNAPSHOT [INFO] [INFO] Parameter: groupId, Value: com.liftcode [INFO] Parameter: packageName, Value: com.liftcode [INFO] Parameter: package, Value: com.liftcode [INFO] Parameter: artifactId, Value: imagine [INFO] Parameter: basedir, Value: /home/dpp/tmp [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error creating from archetype Embedded error: The META-INF/maven/archetype.xml descriptor cannot be found. [INFO] [INFO] For more information, run Maven with the -e switch [INFO] [INFO] Total time: 5 seconds [INFO] Finished at: Mon Nov 30 19:48:19 PST 2009 [INFO] Final Memory: 16M/170M [INFO] d...@sevenof9:~/tmp$ We are supposed to be stabilizing the archetypes and making sure they are tested as part of the build process. It is absolutely unacceptable (can I be any more blunt than this?) that the archetypes do not work. Whoever broke them, please do whatever you have to do to get them fixed ASAP. David -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] **URGENT** Archetypes broken
On Mon, Nov 30, 2009 at 8:25 PM, Ross Mellgren dri...@gmail.com wrote: It looks like they work to me. I'm using this: r...@hugo:~$ mklift lift-archetype-basic test-brokenarchetypes4 + mklift lift-archetype-basic test-brokenarchetypes4 + test 2 -lt 2 + mvn archetype:generate -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic -DarchetypeVersion=1.1-SNAPSHOT -DarchetypeRepository=http://www.scala-tools.org/repo-snapshots-DgroupId=test -DartifactId=test-brokenarchetypes4 -Dversion=1.0-SNAPSHOT [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] [INFO] Building Maven Default Project [INFO]task-segment: [archetype:generate] (aggregator-style) [INFO] [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class = 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on = 'false'. [INFO] Setting property: resource.loader = 'classpath'. [INFO] Setting property: resource.manager.logwhenfound = 'false'. [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] Archetype defined by properties [INFO] snapshot net.liftweb:lift-archetype-basic:1.1-SNAPSHOT: checking for updates from lift-archetype-basic-repo Confirm properties configuration: groupId: test artifactId: test-brokenarchetypes4 version: 1.0-SNAPSHOT package: test Y: : [WARNING] PT Don't override file /Users/rmm/test-brokenarchetypes4/pom.xml [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 4 seconds [INFO] Finished at: Mon Nov 30 23:22:36 EST 2009 [INFO] Final Memory: 13M/80M [INFO] I note you're using archetype:create? The wiki says archetype:generate; I don't know what archetype:create does, though it looks like an old (and deprecated) name for archetype:generate. archetype:create was working up through last week. There were no **BREAKING CHANGES** notifications. archetype:generate forces me to answer questions (the whole point of having a script is so I can type the script name and have it work.) Sorry for being grumpy about this, but I don't like things changing/breaking without some form of warning. -Ross On Nov 30, 2009, at 10:51 PM, David Pollak wrote: Folks, Somehow somebody broke the basic archetype. This is not acceptable. Here's what I typed and here's what happened: d...@sevenof9:~/tmp$ cat /home/dpp/bin/new_lift #!/bin/sh mvn archetype:create -U -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=1.1-SNAPSHOT \ -DremoteRepositories=http://scala-tools.org/repo-snapshots \ -DgroupId=$1 -DartifactId=$2 d...@sevenof9:~/tmp$ new_lift com.liftcode imagine [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] org.apache.maven.plugins: checking for updates from central [INFO] org.codehaus.mojo: checking for updates from central [INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central [INFO] [INFO] Building Maven Default Project [INFO]task-segment: [archetype:create] (aggregator-style) [INFO] [INFO] Setting property: classpath.resource.loader.class = 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on = 'false'. [INFO] Setting property: resource.loader = 'classpath'. [INFO] Setting property: resource.manager.logwhenfound = 'false'. [INFO] [archetype:create {execution: default-cli}] [WARNING] This goal is deprecated. Please use mvn archetype:generate instead [INFO] Defaulting package to group ID: com.liftcode [INFO] We are using command line specified remote repositories: http://scala-tools.org/repo-snapshots [INFO] snapshot net.liftweb:lift-archetype-basic:1.1-SNAPSHOT: checking for updates from id0 Downloading: http://scala-tools.org/repo-snapshots/net/liftweb/lift-archetype-basic/1.1-SNAPSHOT/lift-archetype-basic-1.1-SNAPSHOT.jar [INFO] [INFO] Using following parameters for creating OldArchetype: lift-archetype-basic:1.1-SNAPSHOT [INFO] [INFO] Parameter: groupId, Value: com.liftcode [INFO] Parameter:
Re: [Lift] how to fill dropdown list with data in the database
if you have: val books: List[Book] = ... def chosenBook(in: Book): Unit = { ... this method will be called when the form is processed } SHtml.selectObj[Book](books.map(b = (b, b.name.is)), Empty, chosenBook _) Hope this helps. On Thu, Nov 19, 2009 at 7:55 PM, mr najmi mnajm...@gmail.com wrote: can anyone show me how to fill the dropdown list with the data in the database.i want the simplest one,because i didn`t undestand the example given in the web and book.. let say we have one table that is book i want one dropdown that will be fill with the data from this book thank you for your time -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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-json escaping bug
Hi, This is from JSON RFC (http://www.ietf.org/rfc/rfc4627.txt): A JSON text is a serialized object or array. I checked with another parser (http://www.jsonlint.com) and it fails too when given just JSON value: syntax error, unexpected TNUMBER, expecting '{' or '[' at line 1 So perhaps a better error message is a proper fix here? Cheers Joni On 1 joulu, 05:22, Ross Mellgren dri...@gmail.com wrote: On review board:http://reviewboard.liftweb.net/r/131/ I did run across another infelicity when writing the test -- apparently JsonParser crashes when given a scalar value, as opposed to an array or object: scala parse(\foobar\) net.liftweb.json.JsonParser$ParseException: unexpected null Near: foobar at net.liftweb.json.JsonParser$Parser.fail(JsonParser.scala:166) at net.liftweb.json.JsonParser$ValStack.peek(JsonParser.scala:153) at net.liftweb.json.JsonParser$.newValue$1(JsonParser.scala:110) at net.liftweb.json.JsonParser$.parse0(JsonParser.scala:125) at net.liftweb.json.JsonParser$.parse(JsonParser.s... I'm not sure if it should work, but even if it shouldn't support that the error case should probably give a better message. Joni/et al? -Ross On Nov 30, 2009, at 8:33 PM, harryh wrote: Done: http://github.com/dpp/liftweb/issues/#issue/214 On Nov 30, 6:33 pm, Ross Mellgren dri...@gmail.com wrote: If you file an issue on github I'll write up a patch for you tonight. -Ross On Nov 30, 2009, at 6:30 PM, harryh wrote: Yes, what Ross said. Further, taking a look at JsonParser.scala the bug appears to be on line ~202 where there are a couple of missing escape sequences: \/ as well as \f. -harryh On Nov 30, 6:20 pm, Ross Mellgren dri...@gmail.com wrote: He's double escaping so that scala's string interpretation will put a raw \ in there, so that it's an escaped forward slash (\/) to the JSON parson, as I understand it. The output should be either invalid escape or forward slash, but not backslash unless the input was \\. -Ross On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote: Harry, I think you're double-escaping the slash. This works: scala import net.liftweb.json._ scala val s1 = { \id\: \America/New_York\ } s1: java.lang.String = { id: America/New_York } scala JsonParser.parse(s1) res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America/New_York Peter Robinett On Nov 30, 2:16 pm, harryh har...@gmail.com wrote: scala import net.liftweb.json._ scala val s2 = { \id\: \America\\/New_York\ } s2: java.lang.String = { id: America\/New_York } scala JsonParser.parse(s2) res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField (id,JString (America\New_York It should be America/New_York but for some reason getting a \ instead of a / -harryh -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en . -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] **URGENT** Archetypes broken
On 01/12/09 10:58 AM, David Pollak wrote: On Mon, Nov 30, 2009 at 8:25 PM, Ross Mellgren dri...@gmail.com mailto:dri...@gmail.com wrote: It looks like they work to me. I'm using this: ... snip/ ... I note you're using archetype:create? The wiki says archetype:generate; I don't know what archetype:create does, though it looks like an old (and deprecated) name for archetype:generate. archetype:create was working up through last week. There were no **BREAKING CHANGES** notifications. archetype:generate forces me to answer questions (the whole point of having a script is so I can type the script name and have it work.) Sorry for being grumpy about this, but I don't like things changing/breaking without some form of warning. Mea maxima culpa! This should have occurred to me that although deprecated, somebody still might have been using archetype:create. The jpa related archetypes had moved to the new archetype format quite sometime back. That made me assume the usage of archetype:generate pretty much 'given'. In hindsight, I think that was a bad assumption! Nonetheless, very sorry for this inconvenience. And even more, sorry for the oversight in not sending out the **BREAKING CHANGES** email. I'll take care of this later in the day. - Indrajit -Ross On Nov 30, 2009, at 10:51 PM, David Pollak wrote: Folks, Somehow somebody broke the basic archetype. This is not acceptable. Here's what I typed and here's what happened: d...@sevenof9:~/tmp$ cat /home/dpp/bin/new_lift #!/bin/sh mvn archetype:create -U -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=1.1-SNAPSHOT \ -DremoteRepositories=http://scala-tools.org/repo-snapshots \ -DgroupId=$1 -DartifactId=$2 d...@sevenof9:~/tmp$ new_lift com.liftcode imagine [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] org.apache.maven.plugins: checking for updates from central [INFO] org.codehaus.mojo: checking for updates from central [INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central [INFO] [INFO] Building Maven Default Project [INFO]task-segment: [archetype:create] (aggregator-style) [INFO] [INFO] Setting property: classpath.resource.loader.class = 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on = 'false'. [INFO] Setting property: resource.loader = 'classpath'. [INFO] Setting property: resource.manager.logwhenfound = 'false'. [INFO] [archetype:create {execution: default-cli}] [WARNING] This goal is deprecated. Please use mvn archetype:generate instead [INFO] Defaulting package to group ID: com.liftcode [INFO] We are using command line specified remote repositories: http://scala-tools.org/repo-snapshots [INFO] snapshot net.liftweb:lift-archetype-basic:1.1-SNAPSHOT: checking for updates from id0 Downloading: http://scala-tools.org/repo-snapshots/net/liftweb/lift-archetype-basic/1.1-SNAPSHOT/lift-archetype-basic-1.1-SNAPSHOT.jar [INFO] [INFO] Using following parameters for creating OldArchetype: lift-archetype-basic:1.1-SNAPSHOT [INFO] [INFO] Parameter: groupId, Value: com.liftcode [INFO] Parameter: packageName, Value: com.liftcode [INFO] Parameter: package, Value: com.liftcode [INFO] Parameter: artifactId, Value: imagine [INFO] Parameter: basedir, Value: /home/dpp/tmp [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error creating from archetype Embedded error: The META-INF/maven/archetype.xml descriptor cannot be found. [INFO] [INFO] For more information, run Maven with the -e switch [INFO] [INFO] Total time: 5 seconds [INFO] Finished at: Mon Nov 30 19:48:19 PST
Re: [Lift] **URGENT** Archetypes broken
On 01/12/09 11:30 AM, Ross Mellgren wrote: On Dec 1, 2009, at 12:28 AM, David Pollak wrote: On Mon, Nov 30, 2009 at 8:25 PM, Ross Mellgren dri...@gmail.com mailto:dri...@gmail.com wrote: archetype:create was working up through last week. There were no **BREAKING CHANGES** notifications. archetype:generate forces me to answer questions (the whole point of having a script is so I can type the script name and have it work.) Add -DinteractiveMode to your archetype:generate and it'll assume -Dversion=1.0-SNAPSHOT and the default package name and not prompt you for confirmation. Alternately, set interactiveMode permanently to false in settings.xml (http://maven.apache.org/settings.html#Simple_Values) -Ross -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.
Re: [Lift] method call from out of nowhere
Hi David, On Mon, Nov 30, 2009 at 12:11 AM, Hannes hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi David, In my LimitOrder Meta Object, I did: override def afterCreate to inform an Actor, everytime a new Order is created. The Actor than calls the joinOtherOrders method. # I think I understand it now. Cause I'm creating new orders inside the loop at some point. But still I don' t really know, why it gets called after the old scope of joinOtherOrders ends... Sounds to me like it's all in your application's logic. As others have pointed out, Thread.dumpStack will let you figure out where things are being called. I think the biggest problem is, that its necessary in my logic to inform the Actor, everytime a new order is created. This while-loop is an exception to this rule. I don't think that it would be a good idea, to change the behavior of how the Actor responds to messages, just to fix this case, or? Or is there any chance to tell a new order NOT to inform the Actor, even when its defined in def afterCreate ? Also, you might want to use recursion and pattern matching to replace your while loop (which is O(n^2) btw): def dealWithList(in: List[Something]): Unit = in match { case Nil = () // nothing left to do case x :: _ if x.condition1 = x.doThing1 case x :: _ if x.condition2 = x.doThing2 case x :: xs if x.condition3 = x.doThing3 ; dealWithList(xs) case _ :: xs = dealWithList(xs) } I thought about pattern matching as well, but in my first implementation, I just wanted to get it running and change it afterwards. Something else: I think recursion is slower than a while-loop as long as its not tail recursive, or? thanks. You have the same semantics of a while loop with the ability to break out, but the code is about your logic rather than about looping. thanks. On Sun, Nov 29, 2009 at 7:24 AM, Hannes hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hey Lifters, How is joinOtherOrders being invoked? I've some really strange things going on here. Please consider this method definition. I've put alot of print debug statements between other statements. There's a while-loop that only starts, when the given list (orders) is not empty. It stops when done is set to true. So far, so good. Than, have a look at the Lift output. I put in a comment, pointing out where the program runs into the while loop. What really shocks me, are these print statements : before done=false after done=true i += 1 outside while INFO - Service request (GET) / took 121 Milliseconds start of joinAll! The loop ends with outside while and than the method gets called again immediately! But who calls it? I don't Any ideas? thanks. method definition -- def joinOtherOrders: Unit = { def joinAll(orders: List[LimitOrder]) = { println(start of joinAll!) var done = false var i = 0 while (!orders.isEmpty !done) { println(i= + i + , + orders.isEmpty= + orders.isEmpty + , + done= + done) if (this.lots.is http://this.lots.is == orders(i).lots.is http://lots.is){ println(case-1) println(this= + this + , orders(i)= + orders(i)) this.open(orders(i)) done = true } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-2) println(this= + this + , orders(i)= + orders(i)) orders(i).reduceLots(this.lots.is http://this.lots.is) val newOrder = orders(i).cloneWith(this.lots.is http://this.lots.is) newOrder.save this.open(newOrder) println(before done= + done) done = true println(after done= + done) } if (this.lots.is http://this.lots.is orders(i).lots.is http://lots.is){ println(case-3) println(this= + this + , orders(i)= + orders(i)) this.reduceLots(orders(i).lots.is http://lots.is) val newOrder =
Re: [Lift] Multipage wizards
David Pollak feeder.of.the.be...@gmail.com writes: [...] Thoughts? Yeah this all sounds good. I'm trying to unify most of the pieces of single form inputs, validation, mapper, record and wizard. It's generally slow going. Good news (about the unification :-) Let me know if there's anything I can do to speed up the process /Jeppe -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: Image upload and serving example
This sounds like a good wiki subject. Wiki gardeners ? Br's, Marius On Dec 1, 7:26 am, David Pollak feeder.of.the.be...@gmail.com wrote: Folks, Lately there's been a bunch of chatter on the list about image upload and figuring out how to put the image files in the right place to serve them again. I've written a simple example of image uploading, storing the image in the RDBMS and then serving the image. You can find the code at:http://github.com/dpp/imagine/ The file upload snippet is very simple: class DoUpload { private def saveFile(fp: FileParamHolder): Unit = { fp.file match { case null = case x if x.length == 0 = case x = val blob = ImageBlob.create.image(x).saveMe ImageInfo.create.name (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe S.notice(Thanks for the upload) S.redirectTo(/) } } def render(in: NodeSeq): NodeSeq = bind(upload, in, file - SHtml.fileUpload(saveFile _)) } If the blob is uploaded, it's put in a row in ImageBlob and an ImageInfo row is created to store the name and mime type. There are two different rows so that one doesn't have to pull the whole blob back when you're checking for the upload date. Serving the image is similarly concise: def serveImage: LiftRules.DispatchPF = { case req @ Req(images :: _ :: Nil, _, GetRequest) if findFromRequest(req).isDefined = () = { val info = findFromRequest(req).open_! // open is valid here because we just tested in the guard // Test for expiration req.testFor304(info.date, Expires - toInternetDate(millis + 30.days)) or // load the blob and return it info.blob.obj.map(blob = InMemoryResponse(blob.image, List((Last-Modified, toInternetDate(info.date.is)), (Expires, toInternetDate(millis + 30.days)), (Content-Type, info.mimeType.is)), Nil, 200)) } } If the request matches /images/xxx where xxx is a name in the ImageInfo table, check to see if we can return a 304 (not modified). If not, we pull the blob from the database and return it. I hope this helps folks who are looking to manage and serve images. Thanks, David -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Surf the harmonics -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.