Logs for the RingoJS IRC channel,
as logged by ringostarr.
2010-05-07
[08:19] <emilis_info> http://ringojs.pastebin.com/YJqx23Sk
[09:47] <hannesw> good morning!
[09:47] <hannesw> i'm planning some major changes today
[09:48] <hannesw> move io.TextStream to use ringo/encoder instead of java.io.Reader/Writer
[09:49] <hannesw> this way we can implement in-memory streams on top of our binary module
[09:49] <hannesw> emilis_info what is that pastebin thing about you posted?
[09:51] <emilis_info> hi
[09:51] <emilis_info> sorry for being away
[09:51] <hannesw> hi
[09:51] <emilis_info> same code works differently inside module and console
[09:51] <emilis_info> doing require("modname") two times works differently
[09:51] <emilis_info> inside module you get the same object
[09:51] <hannesw> ah, so it's kind of a bug report?
[09:51] <emilis_info> I don't know
[09:51] <hannesw> yes, i know
[09:52] <emilis_info> I am not sure what the right behaviour should be
[09:52] <hannesw> shell enters a new context for each line
[09:52] <emilis_info> it is just that calling require("modname") two times inside module returns the same object
[09:52] <emilis_info> I'll need to work around this in my app ;-)
[09:52] <hannesw> this way you can reload modules from the shell, which is handy
[09:52] <emilis_info> yes
[09:52] <hannesw> why? are you working in the shell?
[09:53] <emilis_info> nope
[09:53] <emilis_info> but I am trying to build two objects from the same module
[09:53] <emilis_info> :)
[09:54] <hannesw> can you explain a bit more?
[09:54] <emilis_info> I have a module which is a wrapper for MySQL
[09:54] <emilis_info> I want to have two connections to different databases
[09:54] <hannesw> ok
[09:56] <hannesw> still see no problem :)
[09:56] <emilis_info> ah ok :)
[09:56] <emilis_info> so, when I create the second connection, the first one gets overwritten
[09:56] <emilis_info> my mysql module is here: http://bazaar.launchpad.net/~emilis-d/policyfeed/trunk/annotate/head%3A/modules/ctl/DB/MySQL.js
[09:57] <hannesw> well you'll need a function that creates connections
[09:57] <hannesw> then i don't see how one connection would overwrite the other
[10:00] <hannesw> argh, launchpad source view hurts my eyes :)
[10:00] <emilis_info> I have a function exports.connect() in the module that creates exports.last_connection. When I require() the module second time and call connect() second time, the first connection object gets overwritten
[10:00] <emilis_info> :)
[10:00] <emilis_info> I am going to move to github
[10:00] <hannesw> why do you need something like exports last_connection?
[10:00] <hannesw> well if you like it no problem :)
[10:01] <hannesw> it's a matter of taste
[10:01] <hannesw> well i think the exports.last_connection thing is bad
[10:01] <emilis_info> hmm
[10:02] <emilis_info> and where should I store it?
[10:02] <emilis_info> in the model code?
[10:02] <emilis_info> that's not good either
[10:02] <hannesw> you should store it as a var in whatever scope you need it
[10:02] <emilis_info> ok
[10:03] <emilis_info> I need to use the same module in two different scopes, what should I do?
[10:03] <hannesw> lexical scoping is the beauty of JS, and of Ringo in particular :)
[10:03] <emilis_info> or create as many scopes as I want using the same module
[10:03] <hannesw> what's the problem?
[10:04] <emilis_info> the problem is how I should write my code so that I can keep MySQL.js simple and be able to build multiple connections with it
[10:04] <hannesw> here's what i would do: export a connect() function that returns a connection
[10:04] <hannesw> and with that connection, you can access the database.
[10:04] <emilis_info> btw, I am a PHP "ninja", so I am still getting used to the beauty of JS
[10:05] <hannesw> ok, i'll write something up.
[10:06] <emilis_info> thank you :)
[10:06] <hannesw> the thing is that the close(), query() etc should be on the connection, not the exports.
[10:07] <emilis_info> ok
[10:07] <emilis_info> but what do I do then if I want to share the connection in separate modules?
[10:08] <hannesw> you just pass it from one module to the other
[10:08] <hannesw> or you do some kind of connection pooling
[10:11] <hannesw> so this is a simple blueprint for a connection factory function:
[10:11] <hannesw> http://ringojs.pastebin.com/maNMP6KH
[10:11] <hannesw> the connection methods like query() or close() have access to the privately scoped jdbcConnection variable
[10:12] <hannesw> also to the host, name, user, password arguments, so they can reconnect if necessary
[10:13] <emilis_info> thank you
[10:13] <hannesw> np
[10:14] <hannesw> that's what i meant with the beauty of lexical scoping
[10:14] <hannesw> i hope this pattern works for you
[10:14] <emilis_info> It will help me to rethink how I do things
[10:15] <hannesw> cool :)
[10:16] * oberhamsi put some storage thoughts on irc meet page. for further discussion :)
[10:16] <hannesw> ++++1 oberhamsi
[10:17] <hannesw> count + iterator are important
[10:17] <oberhamsi> yep, not sure how they might look like but i miss them :)
[10:17] <hannesw> and for berkeleystore, i think we should let users choose which properties to index, but allow multiple-property indexes
[10:17] <hannesw> are you using berkeleystore?
[10:17] <oberhamsi> yes, i wasn't sure about the need to set key because we index so much
[10:18] <hannesw> what do you mean by "set key"?
[10:18] <oberhamsi> i'm doing a stats gatherer with berkeley
[10:18] <hannesw> ah i see
[10:18] <oberhamsi> the primary key. new Page({_key: {$ref:
[10:18] <hannesw> well i think we should add sort/order functionality as well
[10:18] <hannesw> ok
[10:18] <emilis_info> what I want to build is require() on steroids, so that I could call like loadObject("DbConnectionA") and get preconfigured connection A; then loadObject("DbConnectionB") and get the preconfigured connection B. I've got this stuff working in PHP, but just copying it to JS does not work :-)
[10:19] <oberhamsi> if i understand correctly berkeley sorts on primary key internally?
[10:19] <hannesw> emilis_info (again) i don't see why that shouldn't be possible on ringo
[10:20] <hannesw> oberhamsi: yes
[10:20] <emilis_info> oh and I am not sure about the current state of SQL drivers in Ringo, but if you have suggestions on how I could adapt my module for use by other Ringo developers they would be welcome
[10:20] <hannesw> that's part of the btree storage
[10:20] <oberhamsi> ah it is the b+tree storage, very nice.
[10:20] <emilis_info> hannesw, me too, but I am learning how to do it
[10:21] <hannesw> emilis_info i think the preferred way to connect to relational databases will be to use a high level object/relational mapper such as hibernate
[10:21] <hannesw> have you checked out ringo-hibernate?
[10:21] <emilis_info> nope
[10:21] <emilis_info> not yet
[10:21] <hannesw> http://github.com/robi42/ringo-hibernate
[10:21] <hannesw> you probably should
[10:21] <hannesw> it takes all the burdon off you
[11:02] <hannesw> earl do you think include skin feature is ready to merge?
[11:02] <hannesw> or are there unsolved problems?
[11:21] <robi42> oberhamsi, there's some `query#orderBy` impl in ringo-hibernate (as an api proposal, so to speak) :)
[11:21] <robi42> see: http://github.com/robi42/ringo-hibernate/blob/master/test/all.js#L164-L187
[11:22] <oberhamsi> that *is* nice
[11:24] <robi42> maybe there's a nicer way api-wise, tho (always good to have more than one opinions)
[11:27] <oberhamsi> sure, i was thinking more bout berkeley.. how to leverage that primary keys are already sorted. if i can set primarykey that's already a big win
[11:27] <gmosx> g'morning
[11:27] <oberhamsi> didn't notice we don't have api for that :)
[11:27] <oberhamsi> .. for sort in general in mean
[11:29] <robi42> :) well, it's an exciting construction area, basically
[11:30] <robi42> bit off topic: http://github.com/cypher/html5-offlineapps
[11:30] <robi42> makes neat use of html5 local storage capabilities and so on
[11:31] <oberhamsi> yep :) how hard, robi42, do you think will implementing relations 1-* be for ringo-hibernate?
[11:32] <oberhamsi> ey, offline storage works on iDevices
[11:32] <oberhamsi> good
[11:32] <robi42> not so hard, actually. just need to roll up sleeves and get it done. :)
[11:32] <robi42> mainly not sure about js api for it
[11:33] <robi42> design-wise
[11:33] <oberhamsi> okay, sure.. just wondering .. i never touched hibernate :)
[11:34] <robi42> (any) input always very appreciated... ;)
[11:35] <oberhamsi> not sure 'bout that either. but i think there will be storage talk next ircmeet
[11:35] <robi42> think probably it could be best if i just come up with some proposal put on wiki page and then discuss?
[11:41] <robi42> btw, i like how grails' gorm does it (relation/collection api), see: http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20(GORM).html#5.2.1 Association in GORM (which is also built upon hibernate)
[11:42] <robi42> http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20(GORM).html#5.2.1%20Association%20in%20GORM
[11:58] <oberhamsi> so it would be {nose : {type: Nose}}
[11:58] <oberhamsi> i don't like the gorm much: hasMany special property and that i have to define the reverse (belongsTo) as well explicitly.. why is that?
[12:02] <robi42> well, one don't always wants to have bidirectional relations by default, no?
[12:08] <robi42> but we could further "simplify", of course (while still allowing for config if wanted)
[12:59] <hannesw> waddler i merged your googlestore enhancement
[12:59] <hannesw> although i also pretty much rewrite googlestore at the same time :)
[13:00] <waddler> hi, ok thanks :)
[13:00] <hannesw> but that was because i disliked my old code, not yours :)
[13:00] <hannesw> so thanks for the enhancements
[13:00] <waddler> there was that one regex matching that could've been simpler, didn't push the change
[13:01] <hannesw> I'm also interested in mering basic auth middleware
[13:01] <hannesw> but i'd like to do some modifications - should i just go with it?
[13:01] <waddler> should take the js-native base64 in use, not sure if I can get around to it this weekend though
[13:02] <waddler> sure if you have the time :)
[13:03] <robi42> (just in case: a "forked" version of waddler's auth middleware with native base64: http://github.com/robi42/ringolog/blob/master/auth.js :) )
[13:06] <robi42> btw, how about including desc/asc direction def. within first string argument to orderBy?
[13:07] <hannesw> robi42 looks good
[13:07] <hannesw> what do you mean by desc/asc thing?
[13:07] <hannesw> orderBy("name:desc")?
[13:07] <robi42> basically, yes
[13:08] <hannesw> don't know, i think it's simpler the way we have it
[13:08] <robi42> orderBy('name desc[ending]')
[13:08] <hannesw> ok
[13:08] <hannesw> makes more sense
[13:08] <robi42> and also allowing capital DESC[ENDING]
[13:11] <hannesw> related question: should we rename Storable.defineClass to defineEntity now?
[13:11] <robi42> sure, +1 :)
[13:11] <hannesw> ok, then let's do it :)
[13:12] <robi42> shall i? or do you have the time anyway?
[13:12] <hannesw> i do have the time :)
[13:12] <robi42> :)
[13:12] <hannesw> i can do it on ringo, you on ringo-hibernateß
[13:12] <robi42> ok
[13:13] <robi42> and let's not forget ringojs.org, ringowiki and so on :)
[13:18] <hannesw> still having doubts though...
[13:19] <oberhamsi> about entity? better then class :) did we have a brainstorm for that shed?
[13:19] <oberhamsi> defineModel...
[13:21] <robi42> we did some brainstorming/discussion, yep
[13:21] <hannesw> nah, forget it, let's just do it :)
[13:21] <robi42> :)
[13:22] <hannesw> testign locally, seems to work
[13:53] <hannesw> ok, pushing
[13:54] <hannesw> ringostarr beat me to it
[13:58] <robi42> :)
[13:58] <hannesw> already updated berkeleystore, ringowiki (master)
[13:59] <robi42> just pushed adapted ringo-hibernate, ringowiki (hibernate) and ringolog
[14:00] <hannesw> cool
[14:00] <hannesw> btw, have to look at ringolog
[14:00] <hannesw> are you planning to use this yourself?
[14:00] <robi42> probably
[14:00] <robi42> at least that's a motivator behind it :)
[14:00] <hannesw> cool
[14:01] <robi42> uses berkeleystore, btw
[14:01] <robi42> and depends on earl's skin-includes branch enhancements
[14:11] <robi42> btw, would be great to get berkeleystore range querying support for pagination in ringolog :)
[14:17] <robi42> (pagination as in ajaxy twitter-like "more" link, that is)
[14:50] <emilis_info> undefined + 0 === Nan
[14:50] <emilis_info> cool
[15:12] <robi42> just for the record: `>> require('ringo/unittest').assertTrue(typeof(undefined + 0) === 'number')`
[15:43] <earl> hannesw: from my perspective, the skin-include stuff is ready
[15:45] <earl> if you want to give it a quick look yourself, i'll be happy to quickly show you thru
[15:46] <earl> otherwise i'll just tidy it up and push it mainline
[15:47] <earl> http://github.com/earl/ringojs/compare/master...skins-include
[17:20] <hannesw> earl: thanks, i'd love to look at the code with you
[17:20] <hannesw> maybe later when the kids are sleeping
[17:28] <robi42> fyi: http://github.com/robi42/ringo-hibernate/commit/0e9c07d64422dae54bba86b4f4188dd4425a209c (earl: no implicit wrapping [yet] but still better than having to do it manually, i guess :) )
[18:18] <earl> robi42: absolutely, yes :)
[21:27] <robi42> hi hannesw, got a hibernate branch of ringolog now featuring that ajaxy twitter-like "more" pagination via range querying and stuff :)
[21:28] <hannesw> cool
[21:28] <hannesw> gotta refactor berkeleystore queries soon
[21:29] * robi42 looking forward to earl's skin-includes branch merging into mainline :)
[21:29] <hannesw> well, you could just do it, you know :)
[21:30] <robi42> query refactoring or merging? :)
[21:33] <hannesw> earl's skin work
[21:33] <hannesw> well of course you can also refactor berkeleystore queries if you're inclined to do so :)
[21:35] <robi42> :)
[21:50] <earl> ok, quick rundown of the external skin rendering changes
[21:50] <earl> i extracted the logic to resolve a skin name from extends into a helper function: resolveSkin
[21:51] <earl> the resource a skin was created from (if any) is passed along to the skin constructor
[21:51] <earl> and renderSubskin was adapted to try to resolve, load, and cache an external skin if no subskin for the given name could be found
[21:54] <earl> i feel confident enough that this should break things, so i'll just go ahead and merge it mainline
[21:55] <earl> another remark on how subskin rendering (i.e. <% render %>) is working after my changes:
[21:55] <earl> 1. the skinname is looked up in the current skin's subskins, if found: render
[21:55] <earl> 2. if not found, see if the skinname is a subskin in any parent skin of the current skin (i.e. traverse the <% extends %> chain), if found anywhere: render
[21:57] <earl> 3. if still not found, try to resolve against the current skin's resource. if the resulting resource exists: load, create a skin, cache as subskin with the resource name becoming the subskin name, render
[21:58] <earl> and if no internal, parent, or external subskin matching the name could be found, render just returns an empty string
[22:10] <earl> there you go :)
[22:13] <robi42> yay, thanks :)