I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning exercise
have taken on the translation of an existing rails project into a lift
application.
There are two things I have run into that I'm hoping the more
experienced members of the list can give me a hand with:
1) Is there a trait in lift that creates and manages an equivalent of
the createdAt and updatedAt fields that rails provides? I'm thinking
something along the lines of IdPK, but have been unable to find
anything.
2) I've been following the wiki article on setting up One-to-Many
relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
to-many-relationships) and am running into a difference in behaviour.
Following the example, if I look at anAuthor.books, I get back a List
of Book objects, however when I look at aBook.author, I get back a
Long with the ID of the Author. I would expect aBook.author to return
an Author object. I've copied and pasted the example in the wiki, to
make sure that it wasn't my implementation.
Other than that, so far, it's gone extremely well and I was able to
get something up and running very quickly which really is a testament
to the design of the framework.
Thanks.
Cheers,
Achint
Hi,
I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning exercise
have taken on the translation of an existing rails project into a lift
application.
There are two things I have run into that I'm hoping the more
experienced members of the list can give me a hand with:
1) Is there a trait in lift that creates and manages an equivalent of
the createdAt and updatedAt fields that rails provides? I'm thinking
something along the lines of IdPK, but have been unable to find
anything.
2) I've been following the wiki article on setting up One-to-Many
relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
to-many-relationships) and am running into a difference in behaviour.
Following the example, if I look at anAuthor.books, I get back a List
of Book objects, however when I look at aBook.author, I get back a
Long with the ID of the Author. I would expect aBook.author to return
an Author object. I've copied and pasted the example in the wiki, to
make sure that it wasn't my implementation.
Other than that, so far, it's gone extremely well and I was able to
get something up and running very quickly which really is a testament
to the design of the framework.
Thanks.
Cheers,
Achint
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
> Hi,
>
> I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning exercise
> have taken on the translation of an existing rails project into a lift
> application.
>
> There are two things I have run into that I'm hoping the more
> experienced members of the list can give me a hand with:
>
> 1) Is there a trait in lift that creates and manages an equivalent of
> the createdAt and updatedAt fields that rails provides? I'm thinking
> something along the lines of IdPK, but have been unable to find
> anything.
>
> 2) I've been following the wiki article on setting up One-to-Many
> relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
> to-many-relationships) and am running into a difference in behaviour.
> Following the example, if I look at anAuthor.books, I get back a List
> of Book objects, however when I look at aBook.author, I get back a
> Long with the ID of the Author. I would expect aBook.author to return
> an Author object. I've copied and pasted the example in the wiki, to
> make sure that it wasn't my implementation.
>
You should be able to get the object by calling aBook.author.obj - this should return a Box[Author] so you could get it like this
aBook.author.obj match {
case Full(a) => a // do something with the autor
case Empty => // if the box is empty, handle it somehow
case _ => // should cover everyhting else, Failure etc
}
Hope it helps
> Other than that, so far, it's gone extremely well and I was able to
> get something up and running very quickly which really is a testament
> to the design of the framework.
>
> Thanks.
>
> Cheers,
> Achint
>
-------------------------------------
David Pollak<feeder.of...@gmail.com> wrote:
On Tue, Mar 2, 2010 at 11:56 AM, Achint Sandhu <achint...@gmail.com>wrote:
> Hi,
>
> I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning
> exercise
> have taken on the translation of an existing rails project into a lift
> application.
>
> There are two things I have run into that I'm hoping the more
> experienced members of the list can give me a hand with:
>
> 1) Is there a trait in lift that creates and manages an equivalent of
> the createdAt and updatedAt fields that rails provides? I'm thinking
> something along the lines of IdPK, but have been unable to find
> anything.
>
>
There's nothing right now. Feel encouraged to open a ticket at
https://liftweb.assembla.com/spaces/liftweb/tickets for a feature request.
> 2) I've been following the wiki article on setting up One-to-Many
> relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
> to-many-relationships<http://wiki.github.com/dpp/liftweb/how-to-work-with-one-%0Ato-many-relationships>)
> and am running into a difference in behaviour.
> Following the example, if I look at anAuthor.books, I get back a List
> of Book objects, however when I look at aBook.author, I get back a
> Long with the ID of the Author. I would expect aBook.author to return
> an Author object. I've copied and pasted the example in the wiki, to
> make sure that it wasn't my implementation.
>
>
> Other than that, so far, it's gone extremely well and I was able to
> get something up and running very quickly which really is a testament
> to the design of the framework.
>
> Thanks.
>
> Cheers,
> Achint
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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
--
Thank You.
Cheers,
Achint
On Mar 2, 3:36 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> You can assign the ticket to me because I have code for such fields that I can contribute.
>
> -------------------------------------
>
> David Pollak<feeder.of.the.be...@gmail.com> wrote:
>
> On Tue, Mar 2, 2010 at 11:56 AM, Achint Sandhu <achint.san...@gmail.com>wrote:
>
>
>
>
>
> > Hi,
>
> > I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning
> > exercise
> > have taken on the translation of an existing rails project into a lift
> > application.
>
> > There are two things I have run into that I'm hoping the more
> > experienced members of the list can give me a hand with:
>
> > 1) Is there a trait in lift that creates and manages an equivalent of
> > the createdAt and updatedAt fields that rails provides? I'm thinking
> > something along the lines of IdPK, but have been unable to find
> > anything.
>
> There's nothing right now. Feel encouraged to open a ticket athttps://liftweb.assembla.com/spaces/liftweb/ticketsfor a feature request.
>
>
>
>
>
> > 2) I've been following the wiki article on setting up One-to-Many
> > relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
> > to-many-relationships<http://wiki.github.com/dpp/liftweb/how-to-work-with-one-%0Ato-many-re...>)
> > and am running into a difference in behaviour.
> > Following the example, if I look at anAuthor.books, I get back a List
> > of Book objects, however when I look at aBook.author, I get back a
> > Long with the ID of the Author. I would expect aBook.author to return
> > an Author object. I've copied and pasted the example in the wiki, to
> > make sure that it wasn't my implementation.
>
> > Other than that, so far, it's gone extremely well and I was able to
> > get something up and running very quickly which really is a testament
> > to the design of the framework.
>
> > Thanks.
>
> > Cheers,
> > Achint
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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
Thank You.
Cheers,
Achint
On Mar 2, 3:36 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> You can assign the ticket to me because I have code for such fields that I can contribute.
>
> -------------------------------------
>
> David Pollak<feeder.of.the.be...@gmail.com> wrote:
>
> On Tue, Mar 2, 2010 at 11:56 AM, Achint Sandhu <achint.san...@gmail.com>wrote:
>
>
>
>
>
> > Hi,
>
> > I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning
> > exercise
> > have taken on the translation of an existing rails project into a lift
> > application.
>
> > There are two things I have run into that I'm hoping the more
> > experienced members of the list can give me a hand with:
>
> > 1) Is there a trait in lift that creates and manages an equivalent of
> > the createdAt and updatedAt fields that rails provides? I'm thinking
> > something along the lines of IdPK, but have been unable to find
> > anything.
>
> There's nothing right now. Feel encouraged to open a ticket athttps://liftweb.assembla.com/spaces/liftweb/ticketsfor a feature request.
>
>
>
>
>
> > 2) I've been following the wiki article on setting up One-to-Many
> > relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
> > to-many-relationships<http://wiki.github.com/dpp/liftweb/how-to-work-with-one-%0Ato-many-re...>)
> > and am running into a difference in behaviour.
> > Following the example, if I look at anAuthor.books, I get back a List
> > of Book objects, however when I look at aBook.author, I get back a
> > Long with the ID of the Author. I would expect aBook.author to return
> > an Author object. I've copied and pasted the example in the wiki, to
> > make sure that it wasn't my implementation.
>
> > Other than that, so far, it's gone extremely well and I was able to
> > get something up and running very quickly which really is a testament
> > to the design of the framework.
>
> > Thanks.
>
> > Cheers,
> > Achint
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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
Is there any reason why aBook.author would not simply return a Box
instead of requiring aBook.author.obj to get the Box ?
I'm sure there is a really good reason for this and I'm just trying to
get an understanding of the underlying reasoning.
Thanks.
Cheers,
Achint
-------------------------------------
Hi,
Is there any reason why aBook.author would not simply return a Box
instead of requiring aBook.author.obj to get the Box ?
I'll wait for the official implementation so as not to get into an
IP / copyright issues.
Thanks again for posting.
Cheers,
Achint
On Mar 2, 8:32 pm, Jonathan Hoffman <jonhoff...@gmail.com> wrote:
> I'm sure you've got this covered, but I've also had this requirement and used something like this:http://gist.github.com/320200
>
> On Mar 2, 2010, at 4:01 PM, Achint Sandhu wrote:
>
>
>
> > Ticket created -
> >https://liftweb.assembla.com/spaces/liftweb/tickets/390-request-for-t...
>
> > Thank You.
>
> > Cheers,
> > Achint
>
> > On Mar 2, 3:36 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> >> You can assign the ticket to me because I have code for such fields that I can contribute.
>
> >> -------------------------------------
>
> >> David Pollak<feeder.of.the.be...@gmail.com> wrote:
>
> >> On Tue, Mar 2, 2010 at 11:56 AM, Achint Sandhu <achint.san...@gmail.com>wrote:
>
> >>> Hi,
>
> >>> I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning
> >>> exercise
> >>> have taken on the translation of an existing rails project into a lift
> >>> application.
>
> >>> There are two things I have run into that I'm hoping the more
> >>> experienced members of the list can give me a hand with:
>
> >>> 1) Is there a trait in lift that creates and manages an equivalent of
> >>> the createdAt and updatedAt fields that rails provides? I'm thinking
> >>> something along the lines of IdPK, but have been unable to find
> >>> anything.
>
> >> There's nothing right now. Feel encouraged to open a ticket athttps://liftweb.assembla.com/spaces/liftweb/ticketsfora feature request.
On Mar 2, 8:19 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> Yes, because, as in the database, essentially it's a MappedLong (for example), with support built on top of it (via trait mixins) to lookup and cache the referenced entity.
> Is there a problem with the .obj syntax?
>
> -------------------------------------
>
I've raised a ticket as requested:
http://www.assembla.com/spaces/liftweb/tickets/394-request-for-convenience-conversion-on-mappedlongforeignkey-fields
Cheers,
Achint
On Mar 2, 8:21 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> On Tue, Mar 2, 2010 at 5:09 PM, Achint Sandhu <achint.san...@gmail.com>wrote:
>
> > Hi,
>
> > Is there any reason why aBook.author would not simply return a Box
> > instead of requiring aBook.author.obj to get the Box ?
>
> For some background, seehttp://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-w...
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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 lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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
-------------------------------------
Achint Sandhu<achint...@gmail.com> wrote:
Hi,
I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning exercise
have taken on the translation of an existing rails project into a lift
application.
There are two things I have run into that I'm hoping the more
experienced members of the list can give me a hand with:
1) Is there a trait in lift that creates and manages an equivalent of
the createdAt and updatedAt fields that rails provides? I'm thinking
something along the lines of IdPK, but have been unable to find
anything.
2) I've been following the wiki article on setting up One-to-Many
relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one-
to-many-relationships) and am running into a difference in behaviour.
Following the example, if I look at anAuthor.books, I get back a List
of Book objects, however when I look at aBook.author, I get back a
Long with the ID of the Author. I would expect aBook.author to return
an Author object. I've copied and pasted the example in the wiki, to
make sure that it wasn't my implementation.
Other than that, so far, it's gone extremely well and I was able to
get something up and running very quickly which really is a testament
to the design of the framework.
Thanks.
Cheers,
Achint
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
I'll prefix this by saying that I'm new to this and not qualified to
comment, but I would expect the timestamp to always be DateTime.
That having been said, either syntax is fine.
Cheers,
Achint
On Mar 3, 3:27 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> Is a syntax like this okay (inside an Author mapper)?
> object created extends MappedDateTime(this) with CreatedTimestamp[Author]
> Although if we say that timestamps are always a date-time (not date only or time only) this could be shortened to
> object created extends CreatedTimestamp(this)
>
> -------------------------------------
>
I've run into a slight snag with my use of the current approach. I
suspect what I'm trying to do is silly. The interaction below is from
the lift console and I don't actually use open_! in my code.
---
scala> val b = Book.find(1).open_!
l: com......Book = com......Book={id=1,author=1}
scala> b.author
res3: b.author.type = 1
scala> b.author == 1
res4: Boolean = true
---
If for some reason a Book does not have an author (possible in my
applications case), b.author would return NULL and comparing b.author
== 1 returns Boolean = false
This approach works in the actual application, but the compiler
generates the following warning.
---
warning: comparing values of types Long and object b.author using `=='
will always yield false
---
In the specific application case I have, I have access to the
Author.id and want to check if the book is referring to the author
whose ID I have before I do something. I know that I could look up the
Author object and do the comparison, but the above seemed to be a
useful shortcut.
Is there a recommended (succinct) way of accomplishing the above ?
I'd like the thank everyone for the patience and help provided so far.
Cheers,
Achint
On Mar 2, 3:26 pm, Mads Hartmann Jensen <mads...@gmail.com> wrote:
Small update.
Changing the order of the comparison in my code
i.e. b.author == 1 instead of 1 == b.author
fixed the warning, but I'm still curious as to whether what I'm doing
is a good idea.
Thanks.
Cheers,
Achint