Ringobot log - RingoJS IRC channel: #ringojs on irc.freenode.net

2010-08-11:

[1:31] <oravecz> it's pretty late in Europe, but anyone here?
[1:32] <oravecz> Or early, depending on your perspective...
[2:01] <maks> oravecz, I'm here if you still are logged in...
[2:59] <oravecz> i am...
[2:59] <oravecz> Do you have any knowledge regarding module loading and the shared property?
[3:03] <oravecz> By default, all modules are now shared, but I am experiencing a different behavior.
[4:09] <maks> sorry I thought it was the opposite, all modules are *not* shared, unless you set it specifically
[4:11] <maks> has it changed recently?
[5:23] <maks> hi hannes, would you have time for a quick question?
[6:24] <hannesw> maks sure!
[6:25] <hannesw> oravecz what's the strange behaviour you're getting with module loading?
[6:55] <maksweb> thanks Hannes I'm working on my first major ringo webapp - and I've got a work around for the problem now - but I noticed that in my middleware, the req object is the 'raw' jsgi one, not the enhanced one I get in action functions...
[6:58] <hannesw> maksweb you can enhance the request in middleware, if you want
[6:59] <hannesw> if you run the Request() function multiple times, it will only do the enhancement work once
[6:59] <maksweb> yep, thats what I ended up doing - good to know that its not inefficient if it happens over again
[6:59] <hannesw> of course it's not "pure JSGI" anymore, but that shouldn't be a problem
[7:01] <hannesw> well we check as first thing if request already has the "path" property
[7:01] <hannesw> http://github.com/ringo/ringojs/blob/master/modules/ringo/webapp/request.js#L23-26
[7:01] <maksweb> but woudl be good to document this somewhere? as it took me a while to figure out what was happening, since return identical when you do a toString() on them
[7:01] <hannesw> admittedly that's a bit of a hack - we probably should set some "x-ringo-enhanced" prop
[7:01] <hannesw> when you do a toString() on the request object?
[7:02] <maksweb> and could the enhancement change the toString() as well?
[7:02] <maksweb> sorry yes, the toString() of both the raw and enhanced objs is the same at the moment
[7:05] <maksweb> need to switch to my phone - hopefully my conn stays up..
[7:13] <maks> and yes, the way I figured out what was happening was by reading request.js, but I'd be happy to document this on the Wilona page
[7:14] <maks> err meant wiki page, silly autocomplete on my phone
[7:16] <hannesw> :)
[7:16] <hannesw> yes, many things need documentation.
[7:16] <hannesw> feel free to start wiki stub pages or sections!
[7:18] <maks> I'm actually very impressed how good the diva are already given how young ringo is compared to helma
[7:20] <maks> 1 big annoyance for me is lack of offline jsdocs, can I now get them if I pull your master off github?
[8:23] <hannesw> maks offline jsdocs are coming soon!
[8:23] <hannesw> you can now generate them yourself using ringo-doc command line tool
[8:24] <hannesw> they'll be bundled with next release
[8:24] <hannesw> (basically the only thing left for 0.6 is in fact clean up ringo-doc)
[9:31] <leetreveil> hi, just getting started with ringojs but i'm having a little problem
[9:32] <leetreveil> if I open a file with fs.open("somefile.x","rw");
[9:33] <leetreveil> then try to write to it I get 'cannot call method encode on undefined" error
[11:01] <leetreveil> anyone here?
[12:06] <oravecz> hi hannesw, the module loading problem I was experiencing wasn't in ringojs, but was in the portlet code I had written which creates a RhinoEngine and bootstraps ringojs similar to how the JsgiServlet code
[12:07] <oravecz> In the portlet world, it instantiates a separate servlet for each portlet, but I have made sure that only one RhinoEngine gets created.
[12:07] <oravecz> Given that fact, is there anything outside the RhinoEngine code that can affect the caching of modules that I can look at?
[12:17] <hannesw> oravecz compiled scripts are cached globally
[12:18] <hannesw> but evaluated modules are cached per engine
[12:18] <hannesw> so if you have multiple engines sharing some module directory, each module is only compiled once, but evaluated per engine
[12:18] <hannesw> most of that code is in src/org/ringojs/engine/ReloadableScript.java i think
[12:59] <oravecz> Perhaps I don't understand the difference between a module and a script...
[12:59] <oravecz> I only have one RhinoEngine
[13:00] <oravecz> I spent a good deal of time in ReloadableScript last night, but couldn't find my problem...
[13:57] <oravecz> hannesw, i posted some responses while you were out of chat, can u see them?
[14:12] <hannesw> oravecz yes
[14:12] <hannesw> now checking log if there's more
[14:15] <hannesw> oravecz compiled script is basically a java class implementing org.mozilla.javascript.Script
[14:15] <hannesw> and a module is that class evaluated on a module scope
[14:18] <oravecz> ok, thanks for the input. I'm not sure where that leaves me...
[14:20] <oravecz> I initialize my call to the JS side pretty much the same way that you do in JsgiServlet...
[14:20] <oravecz> engine.getContextFactory().enterContext();
[14:20] <oravecz> try {
[14:20] <oravecz> ...
[14:20] <oravecz> engine.invoke("portlet/portlet", "handleRequest", portlet, handlerName, request, response, envMap);
[14:20] <oravecz> ....
[14:20] <oravecz> } finally {
[14:20] <oravecz> Context.exit();
[14:20] <oravecz> }
[14:21] <oravecz> I make sure that engine is the same object each time
[14:21] <oravecz> Is there anything you might think of that can impact module caching if the engine is the same?
[14:21] <hannesw> oravecz so you get different module instances for the same module?
[14:23] <oravecz> I will have to check for that. I assumed so since they weren't caching.
[14:23] <oravecz> The way I know they aren't caching is by putting a log statement in config.js and seeing it on every request.
[14:24] <oravecz> I originally discovered the problem because I was using httpclient.js and running out of OS threads after just a few page loads
[14:31] <tschaub> hannesw: thanks for opening that rhino issue - any thoughts on what to do about partial time parsing?
[14:31] <tschaub> e.g. "T04:30:15Z"
[14:32] <hannesw> tschaub I've been experimenting with regular expressions
[14:32] <tschaub> firefox returns Jan 1, 1970 4:30Z
[14:32] <tschaub> rhino returns Jan 1, 1900 4:30Z
[14:32] <hannesw> /(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3})(?:(Z)|(?:(-|\+)(\d{2}):(\d{2})))?)?)?)?/
[14:32] <mcepl> tschaub: that's correct, what would you expect?
[14:33] <tschaub> mcepl: which one is correct?
[14:34] <mcepl> both :)
[14:34] <mcepl> when you haven't inserted a date (so you apparently don't care about a date part), engine is free to add anything.
[14:36] <tschaub> hannesw: looks about right
[14:36] <tschaub> this is all that is required for time only parsing fwiw http://github.com/tschaub/ringojs/commit/8b44fbc09486709d6d2618028ccd29b5988531f5
[14:36] <tschaub> hannesw: do you suspect that regex is faster than split?
[14:37] <tschaub> or easier to read?
[14:37] <tschaub> certainly more compact
[14:44] <leetreveil> hi, just getting started with ringojs but i'm having a little problem, if I open a file with fs.open("somefile.x","rw"); then try to write to it I get 'cannot call method encode on undefined" error
[14:57] <hannesw> tschaub i thought it would be easier to handle, and maybe faster
[14:57] <hannesw> leetreveil looks like a bug
[14:57] <hannesw> I'm not even sure "rw" is implemented
[14:58] <leetreveil> ah ok, so its better in that case to call fs.read() then fs.write()
[14:58] <leetreveil> instead of open, read, write