Hopbot log for 2007-07-13 - Helma IRC channel: #helma on irc.freenode.net

2007-07-13:

[17:30] <baalwww> i'm having a b.p.-raising problem with javascript... I have 3 radio buttons with onclick="submit()" that work fine...until I add a submit button to the form, at which point they no longer will fire
[17:31] <midnightmonster> should be onclick="this.form.submit()"
[17:31] <baalwww> yes, actually either works, but when the submit button is also present, neither form works
[17:32] <midnightmonster> link?
[17:32] <baalwww> it's not up, i'll pastebin it?
[17:32] <midnightmonster> ok
[17:34] <baalwww> http://pastebin.ca/618004
[17:34] <baalwww> the version I pasted, the radio buttons won't fire. If the submit button is removed from the bottom, they do.
[17:35] <midnightmonster> ah :-)
[17:35] <midnightmonster> b/c you named the submit button submit
[17:35] <midnightmonster> now form.submit == the submit button, which isn't a function
[17:36] <baalwww> ahhhhhhhhhhhhhh :)
[17:36] <midnightmonster> just don't give it a name at all--it doesn't need one
[17:36] <baalwww> thank you!
[17:36] <midnightmonster> you're welcome
[17:39] <baalwww> Ok...back to the grind...I thought I had two weeks on this deal and found out after 6 days that it's one week :( Thanks again
[17:39] <midnightmonster> good luck
[17:40] <midnightmonster> "I love deadlines. I like the whooshing sound they make as they fly by."
[17:41] <baalwww> hahahaha...this one I lose the pay if I do
[19:58] <midnightmonster> technomancy, are you technomancy.us?
[20:02] <midnightmonster> zumbrunn (or anyone who knows), can you explain the deal with StringBuffers? e.g., res.push/pop[Buffer]... why would I need/want to do that, and where would I get another string buffer from to push? and what does push, which takes no arguments, apparently, do?
[20:12] <typicaljoe> hello
[20:12] <midnightmonster> hi
[20:12] <midnightmonster> I think I'm the only live one here atm
[20:13] <typicaljoe> how are you? just trying Helma for the first time
[20:13] <typicaljoe> very impressed
[20:13] <midnightmonster> likewise. I'm trying to build my first non-tutorial app.
[20:13] <midnightmonster> what enviroment did/do you use before?
[20:14] <typicaljoe> ColdFusion mainly, I've looked at Python and Django but I prefer to code Javascript
[20:14] <typicaljoe> yourself?
[20:14] <midnightmonster> PHP.
[20:15] <typicaljoe> how does it compare?
[20:17] <typicaljoe> have you been connecting to a database? I just got this error: Sorry, data source jg is not defined for this application. but I'm not sure where to go from there. I thought both mysql and my jg datasource were setup
[20:18] <midnightmonster> PHP and JavaScript are worlds apart, but I'm very familiar with both (PHP has memory management like a modern language but only about the expressive power of C, less in some ways--JavaScript is much more powerful though often slower). PHP scripts run like CGI scripts--there's no framework, you just get the request parameters in some hashes and a gazillion built-in top-level functions with inconsistent naming and calling c
[20:18] <midnightmonster> yeah, I've been using h2.
[20:18] <midnightmonster> instead of mysql
[20:19] <midnightmonster> in my application directory I have a file db.properties which contains:
[20:19] <midnightmonster> myDataSource.url = jdbc:h2:c:/sites/papercrown.org/h2/addressbook/address
[20:19] <midnightmonster> myDataSource.driver = org.h2.Driver
[20:19] <midnightmonster> myDataSource.user = helma
[20:19] <midnightmonster> myDataSource.password = password
[20:21] <midnightmonster> if you want to call your data source jg, the lines would look something like:
[20:21] <midnightmonster> jg.url = jdbc:mysql:whatever
[20:21] <midnightmonster> jg.driver = whatever
[20:21] <midnightmonster> ...
[20:22] <typicaljoe> yeah, I have the lines setup and it even appears in the SQL shell list, but when I select it and hit ok it shows that error. looking at the log files
[20:22] <typicaljoe> so what is the number one cool thing for helma for you?
[20:24] <midnightmonster> it's javascript running on java, so I get to use one of the best languages out there (if you can overlook a couple large stupidities) which I have to be writing anyway for the client side and I get access (through Java) to libraries for practically any fool thing I might want to do
[20:25] <typicaljoe> ahh, found the problem. needed to restart helma as I added the mysql driver, now getting validation problems for the password
[20:26] <midnightmonster> the framework helma provides with the skins and the ORM will probably take me a few apps to really grock and use well
[20:26] <midnightmonster> (progress!)
[20:26] <typicaljoe> very cool, yeah that as an advantage. the main thing for me is that I've been writing enough javascript that I'm starting to "think" in it, so every other language is a translation to try and write
[20:27] <zumbrunn> midnightmonster, regarding the res.push, res.pop thing....
[20:28] <midnightmonster> joe, just before you came in I asked: "can you explain the deal with StringBuffers? e.g., res.push/pop[Buffer]... why would I need/want to do that, and where would I get another string buffer from to push? and what does push, which takes no arguments, apparently, do?"
[20:28] <zumbrunn> The theory is that the performance is better that way, as opposed to string concatenation
[20:29] <zumbrunn> basically, with res.pop you get what was written to the response buffer since the last res.push
[20:30] <midnightmonster> ok. but why wouldn't I just write to one buffer the whole time?
[20:31] <midnightmonster> and does that mean if I want to build a large string I should do: res.push; while(whatever){ res.write(something); }; myStr = res.pop(); ?
[20:32] <zumbrunn> the method is sometimes used to speed up string concatenation in cases where ouy do not yet want to write anything to the response buffer
[20:32] <zumbrunn> that's the theory, yes
[20:32] <midnightmonster> ok. PHP has something similar, but buffers are nested instead of queued
[20:33] <midnightmonster> (or stacked, rather)
[20:33] <zumbrunn> I'm not doing that in my code and have not checked myself whether that's really true
[20:34] <midnightmonster> based on my recent experience playing with alternate methods of doing the anagram IO, it doesn't seem like it would represent much of an improvement.
[20:37] <midnightmonster> when I push a new buffer, does the previous one get sent or do they all hang out on the stack until I'm done?
[20:40] <zumbrunn> midnightmonster, what are these "couple large stupidities" in javascript in your opinion?
[20:41] <midnightmonster> scoping and making a new object based on another one not being a built-in single command.
[20:42] <midnightmonster> scoping esp wrt variables not declared with var falling through into the global scope.
[20:42] <midnightmonster> but beyond that it would be nice to have lexical scope and not only function scope
[20:44] <zumbrunn> my biggest annoyance is that you can't add methods to the built in prototypes without that they get enumerated in for/in loops
[20:45] <midnightmonster> oh, right--that too
[20:45] <zumbrunn> fortunately that's already fixed in Helma
[20:45] <midnightmonster> yes, so I have heard but not found the documentation for or actually understood how to do yet. can you tell me about how to do that while we're at it?>
[20:46] <zumbrunn> http://helma.zumbrunn.net/reference/Object.html#dontEnum
[20:46] <midnightmonster> that's easy enough. thatnks
[20:56] <midnightmonster> so if I define Array.prototype.coolness = function(){ whatever; }; then I do Array.prototype.dontEnum('coolness') and it works how I want?
[20:59] <typicaljoe> so...if I set up a mapping for a table called JOE to /JOE then what can I run at /JOE/shell that might be interesting or useful?
[21:00] <midnightmonster> also, in language annoyances, it would be nice if there were any way at all to store and manipulate data in less advanced structures for memory usage and speed, e.g., efficient bitwise operations or an array that was sort-of efficient.
[21:03] <midnightmonster> (joe, I haven't tried the shell yet, so I don't know)
[21:17] <midnightmonster> btw, fwiw h2 is a pure-java db that can run in-JVM with helma for ludicrous speed (theoretically), and it has a really fantastic web console of its own built-in.
[21:20] <typicaljoe> so, anyone know of a case of using Helma in a high traffic environment?
[21:20] <midnightmonster> antville runs a few thousand blogs, iirc
[21:23] <midnightmonster> I'm proxying helma through apache 2.2, and it looks like I can add very comprehensive caching pretty easily by just turning it on in Apache and making sure I set cache control headers properly from my helma app. that should be more than enough, e.g., to survive a Digging
[21:29] <typicaljoe> so I'm a little confused about the .hac files. other than libraries (wrapping up your code) is there any reason to write code in a .js file instead of using the .hac that is linked to your action?
[21:35] <midnightmonster> whatever/myAction.hac contains code that will be run when /whatever/myAction is requested no matter which http method is used. if you want a different function for different http methods, you can write functions named myAction_get and myAction_post etc. in whatever/anyname.js
[21:36] <midnightmonster> also if you have some functions that several of whatever's actions will need, they should be in a .js file in whatever/
[21:38] <midnightmonster> on the one hand, the .hac style makes for informative directory listings. on the other, conflating get and post isn't so great. this is something I'd like to see improved about helma
[21:42] <midnightmonster> make sense?
[21:42] <typicaljoe> alright, sorry for all the questions, but I think I'm starting to get it. in the type.properties file in the root directory in the welcome app (follow?) it says _extends = Guide;...so basiclly that is how it nows to run the guide files when someone hits /into
[21:42] <typicaljoe> yeah, I think it is starting to
[21:43] <typicaljoe> thanks so much for your help, great to have someone to chat with as I dig through this
[21:43] <midnightmonster> yeah, that's right re: Guide
[21:46] <midnightmonster> I think this channel is actually the first time I've ever used IRC. you should join the helma users mailing list too if you haven't yet
[22:35] <zumbrunn> midnightmonster, regarding dontEnum ...yes, that's how it is intended to work
[22:40] <midnightmonster> cool. I need a shorter handle
[22:44] <midnightmonster> would it work to read, e.g., an image from disk into a string, set the content-type of the response, and write the string to the response output?
[22:45] <zumbrunn> yes
[22:45] <midnightmonster> that's the sort of thing I'd expect to be able to do, but I didn't know if javascript's internal double-byte representation of strings would create a problem
[22:45] <midnightmonster> (double-byte characters, I mean)
[22:46] <midnightmonster> still work if I read from disk, store in a db blob, and retrieve and write to output from there?
[22:47] <zumbrunn> cant' find the example code I was looking for...
[22:49] <zumbrunn> if I remember right, you read it into a byte array and then write it using res.writeBinary
[22:51] <midnightmonster> at which step? and is that a Java byte array?
[22:51] <midnightmonster> (ok, I see it is a java.ByteArray)
[22:51] <zumbrunn> not really what I was looking for... but it might help:
[22:51] <zumbrunn> http://helma.zumbrunn.net/reference/jala/ImageFilter.html
[22:55] <midnightmonster> ok, so there's a lot more built-in image handling stuff than I realized. that's cool. for this purpose, though, I was really just using image as an example for arbitrary binary data. e.g., could also be a pdf or a word file or whatever
[22:59] <zumbrunn> midnightmonster: yes, this should work with any binary data
[22:59] <typicaljoe> so here is a question, if I wanted to run a standard query against a datasource (say a select) and do something with the results, what would I do?
[22:59] <zumbrunn> you just need to set res.contentType accordingly
[22:59] <rjb_> hello
[22:59] * rjb_ is new user starting to play around w/hemla
[22:59] <zumbrunn> hi rjb_
[22:59] <zumbrunn> welcome :-)
[22:59] <typicaljoe> hi rjb
[23:00] <midnightmonster> zumbrunn's the expert, typicaljoe and I are also newbies
[23:00] <rjb_> well i found the 1.6rc doesn't work with java1.4
[23:00] <zumbrunn> it should
[23:01] <zumbrunn> (does for me, I believe)
[23:01] <zumbrunn> what's the problem?
[23:01] <rjb_> on linux - amd64, blackdown jdk (in case that makes a difference)
[23:02] <zumbrunn> I'm running it with java 1.4 under freebsd
[23:02] <rjb_> it starts, but on connecting w/browser all i get on the page is a ClassNotFound exception (i think)
[23:03] <zumbrunn> hmm
[23:03] <rjb_> sorry i didn't put down what exactly it didn't find, just switched to 1.5 stable
[23:03] <zumbrunn> :-)
[23:03] <zumbrunn> or :-(
[23:03] <zumbrunn> depending on how you look at it
[23:04] <rjb_> there is no fully working jdk v. > 1.4 for linux-amd64, afaik
[23:05] <rjb_> oh and the reference on helma.org probably applies to the current 1.6, doesn't it?
[23:06] <zumbrunn> it probably would be good if you post about that on the mailing list
[23:06] <zumbrunn> which reference?
[23:06] <zumbrunn> oh...
[23:06] <zumbrunn> yes
[23:06] <rjb_> cause i tried to use helma.Database
[23:06] <zumbrunn> (it should)
[23:06] <rjb_> and my 1.5 doesn't have the methods described there
[23:07] <zumbrunn> yes, that changed
[23:07] <rjb_> (i was trying to use a fulltext index query on my MySQL table)
[23:07] <zumbrunn> (there where no docs for that at the time of the 1.5 release)
[23:08] <rjb_> (cause i was totally unable to figure out how to start w. the lucene search module)
[23:08] <zumbrunn> if you need to dig in there, you would have to look at the source code of the helma.Database.js that is included in the 1.5 release
[23:09] <rjb_> well getDBConnection() solved that problem
[23:10] <zumbrunn> yes...
[23:10] <rjb_> anyway i think an example of how to put lucene to work in helma would be most useful
[23:10] <zumbrunn> the new helma.Database module is intended to replace the built in direct db support, though
[23:11] <midnightmonster> howzat?
[23:12] <zumbrunn> getDBConnection works, but it's the old way of doing it
[23:12] <zumbrunn> helma.Database is supposed to be the "new" way
[23:12] <midnightmonster> ok, gotcha.
[23:12] <midnightmonster> i haven't gone there yet
[23:13] <rjb_> but there is no getInstance() in the 1.5 v. of the module
[23:13] <zumbrunn> yes, my statement is more true for 1.6
[23:14] <midnightmonster> oh, hey... re: java on amd64, I just remembered my server is amd64, and it works peachy there
[23:15] <rjb_> btw i'm used to calling mysql_real_escape_string() on query data in php, to avoid sql injection and other breakage
[23:16] <rjb_> what would be the kosher way to take care of that issue here?
[23:17] <zumbrunn> don't know
[23:17] <midnightmonster> while he's wondering that, does helma.Database really have no prepared statements?
[23:17] <zumbrunn> rjb_: ask that on the mailing list
[23:18] <zumbrunn> prepared statements?
[23:18] <rjb_> say i'm building a query like "SELECT * FROM T WHERE Q LIKE '"+req.data.q+"'"
[23:19] <rjb_> i need to at least remove apostrophes form req.data.q
[23:19] <zumbrunn> I know what you meant..
[23:19] <rjb_> that's the sort of issue i'm talking about
[23:19] <zumbrunn> just don't know if there is something for this in the libraries
[23:19] <rjb_> ok
[23:20] <zumbrunn> (I work mostly with the embedded XML db)
[23:20] <midnightmonster> z, I was thinking of doing just that, but the tutorial was all about db hookups, so I didn't really know how
[23:21] <midnightmonster> prepared statements go something like this. they're the better way of doing what rjb and most PHP users do with string concatenation:
[23:21] <midnightmonster> s = db.prepareStatement("select * from t where q like ?");
[23:21] <midnightmonster> s.bindParam(1,req.data.q);
[23:21] <midnightmonster> s.execute();
[23:23] <midnightmonster> (PHP's PDO lib supports prepared statements in several very nice ways, and looking around at other frameworks I've been surprised to find that it compares very favorably to much of what's out there.)
[23:23] <rjb_> for that i need to reach into jdbc, right?
[23:24] <midnightmonster> rjb, it seems that way. I'm coming from PHP, too, though, and all I did was translate PHP syntax to javascript syntax above
[23:25] <midnightmonster> e.g., with PDO it's $s = $db->prepareStatement(...);
[23:25] <rjb_> cause no such thing seems to be directly available in helma javascript
[23:25] <midnightmonster> jdbc seems to offer similar functionality, but I don't know how to use it yet
[23:25] <midnightmonster> rjb, you can add a method to the String prototype to escape '
[23:26] <midnightmonster> does mysql still use \' instead of '' to escape ' ?
[23:26] <rjb_> sure i can but it's just one of a number of things you need to watch out for
[23:26] <zumbrunn> you will definitely get the right advice with that stuff on the mailing list
[23:27] <zumbrunn> we just need to get more of the right people in here on the IRC channel
[23:27] <midnightmonster> JavaScript and Java are unicode aware, so I think most of the issues that exist with PHP and escaping aren't an issue here
[23:28] * zumbrunn goes to catch some sleep since he can't be of any help anyway
[23:28] <rjb_> actually this depends on the settings of the mysql server, afaik
[23:29] <midnightmonster> which 'this'?
[23:29] <midnightmonster> \' vs '', or charset concerns?
[23:34] <_rjb> damn,
[23:34] <_rjb> system crash on my laptop
[23:37] <midnightmonster> rjb, fwiw, my amd 64 server uses java-1.4.2-gcj-compat-devel on fedora core 6 and runs helma 1.6 fine
[23:37] <_rjb> gcj, hmm
[23:38] <midnightmonster> (although I haven't actually updated helma to the latest release candidate, so I guess there might still be a problem)
[23:38] <midnightmonster> yeah--unknown to me, gcj can run jars too
[23:38] <_rjb> (oh and the answer was charset concerns)
[23:40] <midnightmonster> I think that may be the sort of thing jdbc drivers actually can sort out since Java and JavaScript both do unicode and the jdbc driver would be able to tell the db's settings
[23:41] <midnightmonster> (whereas PHP just stores strings as byte arrays)
[23:41] <midnightmonster> would be nice to test, though
[23:43] <_rjb> ok, getting late
[23:44] <_rjb> g'nite, c.u. again sometime
[23:44] <midnightmonster> nite
[23:57] <typicaljoe> this is fun

 

 

In the channel now:

Logs by date: