Logs for the RingoJS IRC channel,
as logged by ringostarr.
2010-05-09
[00:02] <earl> hannesw: cool
[04:58] <oravecz> i prob should wade in to the code but I just wanted to know if there were any REST hooks built in yet?
[13:24] <olegp> hey, quick question about the hiberante store module: is there some way to get the id of the storable after it's saved?
[13:27] <robi42> storable._id
[13:31] <olegp> yeah, thats what I was thinking, but I get an exception because keys is null
[13:31] <olegp> key I mean, inside getId
[13:32] <olegp> Im running outside a transaction, dont if thats a problem
[13:33] <robi42> could you paste some code on ringojs.pastebin.com, please?
[13:34] <olegp> sure, one sec
[13:40] <olegp> http://ringojs.pastebin.com/vL79SaQn
[13:40] <olegp> theres some bootstrap code in there you can ignore, just loads the mysql driver jar
[13:43] <robi42> thanks, having a look
[14:03] <robi42> hm, the basic thing is that hibernate generates ids in the background and at that point it's not available, so to speak
[14:06] <olegp> are they available after a flush?
[14:09] <robi42> as soon as you fetch a storable back from storage you get an id
[14:10] <olegp> its been a while since I used Hibernate directly, since I switched to JPA, which uses Hibernate under the hood
[14:10] <olegp> but Im pretty certain the ids were instantly available ...
[14:10] <olegp> http://forum.springsource.org/showthread.php?t=64943
[14:12] <olegp> anyhow, thanks for your help :)
[14:12] <robi42> sure, jpa does the job there in the background. investigating :)
[14:12] <olegp> will try to work around this somehow or try and see if I can call flush somehow
[14:12] <robi42> do you need the id at that point?
[14:13] <olegp> yeah, for two reasons: need to be able to link up objects together
[14:13] <olegp> also, want to do a redirect to /accounts/{id}
[14:15] <robi42> i see, possible workaround: `obj.save(); obj = Obj.all()[0]; obj._id`
[14:16] <olegp> yup, that worked for me as well
[14:16] <robi42> but i'm fixing that anyway :)
[14:16] <olegp> but then the whole lot needs to be wrapped up in a transaction, so a race condition doesnt occur
[14:16] <robi42> transaction handling is taken care of under the hood
[14:17] <robi42> no need to really worry about when using the storage api
[14:26] <olegp> ok, nice, wasnt too clear on that
[14:28] <robi42> btw, i think i just found a way to get the id directly after calling save() on a storable
[14:28] <olegp> nice, how?
[14:29] <robi42> will let you know as soon as it's available in git repo (basically, hibernate session's able to figure it out)
[14:29] <olegp> ok :)
[14:47] <robi42> olegp, available from github now :)
[14:47] <olegp> awesome, thanks!
[14:47] <robi42> np
[14:48] <robi42> btw, if you run on ringo master/"head" you can simply `ringo-admin install -f`
[14:48] <robi42> thanks for your feedback/input
[14:54] <olegp> awesome, that all works
[14:54] <robi42> great :)
[15:59] <robi42> oberhamsi, you around?
[15:59] <oberhamsi> robi42, yup, hello
[16:00] <robi42> just discovered httpclient's not using ringo's base64 module yet
[16:00] <robi42> for basic auth
[16:00] <oberhamsi> right!
[16:00] <robi42> fixed that, shall i push to my fork?
[16:01] <robi42> or maybe even directly to mainline? :)
[16:01] <oberhamsi> sure please... push to my fork .. you mean push to mainline?
[16:01] <oberhamsi> well if it works :)
[16:01] <robi42> it does, so i'll go ahead, ok?
[16:01] <oberhamsi> yes, thanks
[16:01] <robi42> np
[16:03] <robi42> done :)
[16:04] <robi42> btw oberhamsi, would it be hard to make redirects work with httpclient?
[16:05] <oberhamsi> no not hard
[16:05] <robi42> would be cool :)
[16:05] <oberhamsi> jetty has a thingy that does that, or we do it ourselves.. i need to look at that again :)
[16:05] <robi42> ok, great
[16:08] <oberhamsi> robi42, how would you name the REST methods?
[16:09] <robi42> for put and delete reqs?
[16:09] <oberhamsi> ah delete(), that's why i didn't do it
[16:09] <robi42> i'd go for del() then :)
[16:10] <robi42> (and put(), of course)
[16:12] <oberhamsi> alright, lets see if i manage that for 0.5 :)
[16:12] <robi42> would be awesome :)
[16:16] <robi42> olegp, just in case: you can define jars to be added to classpath of an app at startup via config.js (no need to do it "manually"), see for example: http://github.com/robi42/ringolog/blob/hibernate/app/config.js#L32-L36
[16:34] <olegp> nice, I'm just too lazy to specify all of them individually, so just have that code to load all of the jars in the dir in main
[16:34] <olegp> that being said, theres only one jar in there at the moment :)
[16:35] <robi42> :)
[16:38] <oberhamsi> not sure if i should hook httpclient_test into test/all. its slow and breaks if port 8080 already in use. hm
[16:53] <robi42> maybe use some rather "exotic" port for it? imho, including it in test suite by default would be preferable.
[16:54] <robi42> btw, thumbs up for the rest convenience functions :)
[21:44] <oravecz> can anyone explain this JS syntax to me? Is it a Rhino-ism? var {Binary, ByteArray, ByteString} = require('binary');
[21:44] <oravecz> (I'm talking about the use of curly-braces on the left side of the statement...
[21:45] <robi42> oravecz, https://developer.mozilla.org/en/New_in_JavaScript_1.7#Destructuring_assignment_(Merge_into_own_page.2fsection)
[21:48] <oravecz> thx for the link, those examples use square brackets, while the code in ringo uses curly braces...any difference there?
[21:50] <robi42> well, basically a module scope is represented as a js object so we can use destructuring assignment this way there then
[21:50] <oravecz> ok, i think I see this, thx for the info
[21:50] <robi42> you're welcome
[21:51] <robi42> ad your question regarding serving restful apis with ringo: there's a simple example in storage demo app: http://github.com/ringo/ringojs/blob/master/apps/storage/main.js#L48-L60
[21:53] <oravecz> thx again answerman :D
[21:54] <robi42> hehe
[22:58] <oravecz> so, in the storage demo app, in main.js I see the exports of index, edit and remove
[22:58] <oravecz> but, I don't see where the HTTP_METHOD is used to decide which of these functions to invoke
[23:00] <oravecz> OK, I see in the skins, the edit and remove are just links using the GET method
[23:02] <robi42> you can check on the req object passed to an action which http method's being used and handle it accordingly
[23:03] <robi42> req.is[Get|Post|Put|Delete|Head]
[23:03] <robi42> there's also req.isXhr, btw
[23:27] <oravecz> cool, thx