The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2014-10-12

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:00 asarch joined #mojo
00:21 Mso150 joined #mojo
00:41 D4RK-PH0ENiX joined #mojo
00:42 D4RK-PH0ENiX joined #mojo
00:42 d4rkie_ joined #mojo
01:29 klapperl_ joined #mojo
01:58 doublelel joined #mojo
02:10 memowe_ joined #mojo
02:10 sh4|2 joined #mojo
02:13 D4RK-PH0ENiX joined #mojo
02:47 Adura joined #mojo
02:51 noganex_ joined #mojo
03:03 cpan_mojo Mojo-Pg 0.06 by Sebastian Riedel - http://metacpan.org/release/SRI/Mojo-Pg-0.06
03:09 sujithm_ joined #mojo
03:41 basic6_ joined #mojo
03:50 KCL joined #mojo
04:38 jberger I don't recall your name, but your FEZ is familiar :-P
05:28 jamesaxl joined #mojo
05:47 doublelel joined #mojo
06:41 preaction joined #mojo
07:04 _eugen joined #mojo
07:13 Vandal joined #mojo
07:30 irq joined #mojo
07:54 preaction joined #mojo
08:14 oetiker joined #mojo
08:17 D4RK-PH0ENiX joined #mojo
08:31 dod joined #mojo
08:55 basiliscos joined #mojo
08:56 marcus bowties++
08:58 berov joined #mojo
08:59 D4RK-PH0ENiX joined #mojo
09:03 sujithm joined #mojo
09:04 dotan joined #mojo
09:40 denis_boyun joined #mojo
10:03 sujithm joined #mojo
10:05 berov1 joined #mojo
10:15 Jonis wait, pg is up to 0.06
10:15 Jonis moving fast :D
10:39 basiliscos joined #mojo
10:54 irq_ joined #mojo
11:04 sh4 joined #mojo
11:06 basic6 joined #mojo
11:09 basiliscos joined #mojo
11:18 noganex joined #mojo
11:26 franzkafka joined #mojo
11:27 franzkafka Hi all. I have a form_for section all set up. The thing is, my form elements are in divs (e.g., <div class="form-group">), and I was wondering if there's a more Mojo way of doing <divs> vs having the HTML in there
11:27 franzkafka haha
11:28 franzkafka I like the way my form looks now using form_for, but the HTML mixed in there bothers me :D
11:29 franzkafka Call me silly, but I guess I want Mojolicious to replace all the HTML
11:31 go|dfish franzkafka: http://mojolicio.us/perldoc/Mojolicious/Plugin/TagHelpers#tag
11:32 go|dfish and 't' is an alias for 'tag'
11:33 franzkafka Excellent, there actually is. Thank you!
11:34 franzkafka That helps with my submit button as well, which is of type <button> not <input type="submit">
11:34 franzkafka er mer gawd this is sexy
11:37 franzkafka Before I go writing 100 of these, is this the correct syntax: %=t div, class => 'form-group' => begin
11:42 go|dfish franzkafka: div would need to be quoted in that case, 'div'
11:42 basiliscos joined #mojo
11:43 go|dfish the "fat-comma" => quotes the left-hand side
11:53 jberger franzkafka: I'm the one weep overuses the tag helpers
11:54 franzkafka go|dfish: excellent, thank you.
11:55 franzkafka I think I have successfully made this page nearly unreadable for the HTML folks
11:55 franzkafka haha
11:55 jberger I don't always do it, but sometimes my templates look like this:
11:56 jberger https://github.com/jberger/Galileo/blob/master/lib/Galileo/files/templates/admin/users.html.ep
11:56 franzkafka jberger, haha, that is awesome
11:57 franzkafka jberger, actually, I seriously think it looks better without the HTML tags.
11:58 jberger I blame it on coming from LaTeX, which has a lot of line oriented markup
11:58 jberger or rather directive oriented
11:59 jberger either way, not tagged
12:02 d4rkie joined #mojo
12:57 woz joined #mojo
13:02 lipizzan joined #mojo
13:08 * genio is no fan of tag helpers.  HTML it up
13:11 franzkafka joined #mojo
13:12 disputin joined #mojo
13:12 franzkafka I was watching the mojocast on placeholders. At about 2 minutes into the video I went to a different site (Mojolicious::Controller documentation), and that video continued to play until the end.
13:13 jberger tempire: moar mojocasts!
13:14 franzkafka yeah, I agree with that. The mojocasts are awesome, though a bit outdated (but what can one say in something so rapidly changing?).
13:46 franzkafka does this: my $user = $self->schema->resultset('User')->create({}); not return the DBIx::Class::ResultSet object?
13:56 ribasushi joined #mojo
14:01 disputin joined #mojo
14:02 purl joined #mojo
14:04 batman franzkafka: it returns the created row
14:05 franzkafka yeah, I'm just doing something wrong then
14:08 franzkafka I got it working, I just don't get why it works
14:08 franzkafka I had to restart morbo for the issue I was talking about in here
14:14 * sri wonders if sub DESTROY { my $self = shift; $self->dbh->rollback if $self->dbh->{BegunWork}; } is a stupid thing to do
14:16 franzkafka Hey, is there any variable that I can use which contains the port morbo/hypnotoad is running on?
14:16 franzkafka Basically, I am sending out an activation email, and I am trying to construct the 'http://domain.tld:port/' part
14:16 batman sri: hm... that is complicated, since the $dbh could be shared, right..?
14:17 batman franzkafka: $c->url_for("whatever")->to_abs;
14:17 batman you might want to remove userinfo() if you're using basic auth
14:17 sri batman: no, that is not the problem at all
14:18 franzkafka batman: Awesome, that is exactly what I was looking for. Thanks!
14:18 batman sri: what is the problem then?
14:18 purl the problem then is just getting users to use it.
14:19 franzkafka batman: I'm just generating a random token using Mojolicious::Plugin::Util::RandomString
14:19 sri that BegunWork is undocumented, that maybe the dbh doesn't have AutoCommit set... and and and
14:21 batman oh. could you set $db->{begin_work} inside Pg::Database if begin() is called? it won't give any guaranty, but i guess it's better than nothing if the user actually use $db and not the $dbh
14:21 batman or sub begin { .... $self->{work_has_begun}++ } # something like this
14:21 batman $self->{inside_txn}++
14:24 batman iirc, begin() turns off AutoCommit
14:25 sri no it doesn't
14:26 sri some advice from soeone who knows DBI would be nice
14:29 batman https://metacpan.org/pod/DBI#begin_work
14:29 batman Enable transactions (by turning AutoCommit off) until the next call to commit or rollback. After the next commit or rollback, AutoCommit will automatically be turned on again
14:30 sri this is now actually counter productive
14:30 sri please stop trying to help me
14:30 sri i know you're wrong, i've tested it
14:31 * batman is confused about the documentation for begin_work()
14:33 genio sri: The problem I see with that is that you're relying on BegunWork, which you probably shouldn't do.  Trying to clean up DBI mess on DESTROY sounds just all kinds of buggy to me
14:34 batman i'm even more confused after reading the doc here: https://metacpan.org/pod/DBD::Pg#begin_work
14:34 genio Well, I guess I shouldn't be so negative.  You're only focused on one driver, Pg, I presume, so at least you're not trying to deal with all of the possible cases
14:35 sri the problem is that RaiseError is the default, and if an error happens in a transaction it may leave the current scope, destroying the Mojo::Pg::Database wrapper, resulting in the dbh being enqueued for reuse... and the next user might get a dbh with half finished transaction
14:37 batman how about doing eval { $dbh->rollback } unless $dbh->{AutoCommit} inside _dequeue() ?
14:37 sri if i destroy the dbh somehow, it seems postgres would rollback automatically
14:37 sri batman: PLEASE SHUT UP!
14:37 sri seriously, it doesn't work that way
14:38 * sri is a little on the edge... since he's been fighting with all this undocumented stuff for a few hours...
14:42 franzkafka I don't see anywhere in the documentation where I can bind hypnotoad to an IP address or change the server name. Unfortunately, the url create by url_for contains http://127.0.0.1 :D
14:44 franzkafka I found it, but not sure why it's under the Cookbook rather than Mojo::Server::Hypnotoad documentation
14:51 sri it appears i have reached the dark side of DBI, where a dbh can be in an unknown state
14:52 genio sri: I think at this point, you've moved past all of my previous work of dealing with the DBI devil.  I can only suggest talking to the authors of DBD::Pg or DBI. :/
14:52 sri it appears postgres rolls back the transaction on disconnect
14:53 sri so, the RaiseError problem might be fixable by checking for $dbh->err before queueing the dbh for reuse
14:53 sri batman: sorry for the yelling
14:54 sri i know you're just trying to help
14:56 sri it's really shitty that local $dbh->{RaiseError} = 0; ... $dbh->rollback if $sth->err; is the best you can do for properly handling transactions
14:58 sri appears the only way to have a higher level api would be $db->begin(sub {...}) with commit on success and rollback on failure :S
14:58 sri similar to how DBIx::Connector does it
15:02 genio https://metacpan.org/source/TURNSTEP/DBD-Pg-3.4.2/dbdimp.c#L532  #poking into the XS makes me think it's safe to call rollback in the DESTROY
15:12 stryx` joined #mojo
15:13 genio oh well.  off to replace upper and lower ball joints.  greasy time!
15:15 mst sri: you might want to look at how DBIC does it
15:16 mst sri: we have a rather richer transaction API which theory didn't bother copying
15:16 mst sri: notably the txn scope guard stuff
15:16 sujithm joined #mojo
15:16 mst sri: which I suspect may be closer to what you're trying to achieve than the ->txn interface in DBIx::Connector
15:16 sri ah, i guess a scope guard would work
15:17 mst we could never get theory to understand why that API was useful
15:17 mst still can't work out why
15:17 mst btw, that (and the insane driver system) is why DBIC never switched to using DBIx::Connector
15:18 sri i see, you have $guard->commit and rollback in the DESTROY
15:20 sri quite elegant actually
15:24 go|dfish joined #mojo
15:33 mst I'm interested to see what you come up with, given I'd quite like an async ORM one day
15:34 mst oh. you may also wish to talk to tom in #io-async - I'm fairly sure he built one already at work
15:34 mst tm604 when he's on IIRC
15:36 zivester joined #mojo
15:38 D4RK-PH0ENiX joined #mojo
15:40 batman sri: it's fine. at least you got me to shut up.
15:41 batman the only thing i'm left with is that the documentation should be updated -- or i simply don't get it
15:42 sri i'm changing how transactions work with a scope guard
15:43 batman excellent! looking forward to merging the changes into Mojo::mysql :)
15:43 sri this part of DBI is really annoying though
15:44 * sri is not amused
15:44 batman i never tried to fully get DBI. something must have gone wrong along the way of the api design :/
15:45 mst sri: the interaction of transactions, exceptions and async is hateful in the general case, I think
15:45 mst and DBI wasn't designed with it in mind
15:47 sri i think it's the different combinations of AutoCommit and RaiseError that really trip me up... if i had to deal with different database behaviour on top of that i think i would have had a heart attack already
15:47 mst there's a reason my Vienna talk about DBIC development was called "Database Haters Anonymous"
15:47 sri ;p
15:47 bpmedley sri: I looked in the history and don’t see the example code that shows the problem?
15:48 sri bpmedley: hard to put into a oneliner
15:48 bpmedley sri: Do you have a Mojolicious::Light example that can be looked at?
15:48 sri but i'm almost certain it's unfixable the way i wanted it to work, transaction scope guards are better
15:49 mst batman's probably going to have more "fun" than you have ... especially once he discovers that DBD::mysql randomly reconnects under you, silently, but only if certain env vars are set
15:50 batman mst: yeah. it will be a blast...
15:50 mst hint: force-set mysql_auto_reconnect or whatever it's called to 0
15:50 mst there is no other path to sanity
15:50 * batman will do that now
15:50 batman can i quote you in the Changelog?
15:51 mst aye
15:51 mst the hilarious part is GATEWAY_INTERFACE or MOD_PERL being set turns it on
15:51 mst which results in code that works perfectly during testing and then fails in production
15:51 batman makes perfect sense :)
15:52 mst that combined with Rose::DB trusting $dbh->{Active} rather than testing it properly like DBIC does resulted in a system deadlocking itself once
15:52 mst took me a couple days to trace that down
15:54 punter joined #mojo
15:54 sri holy shit... silent reconnect... that is crazy
15:54 punter Shouldn't https://metacpan.org/release/Mojo-mysql show Thorsen's new module?
15:55 mst sri: silent reconnect but it only defaults to on with those env vars set
15:55 mst kinda becomes crazyception at that point
15:58 sri looking into your scope guard implementation... it appears i will prolly discover some more edge cases over the next few months
15:59 mst DBIC kinda specialises in discovering edge cases
16:11 batman i don't think metacpan handle two modules with the same name...
16:11 batman maybe it's case-insensitive?
16:12 denis_boyun joined #mojo
16:12 sri ok, this works quite well so far https://github.com/kraih/mojo-pg/commit/494c2d554cdc4cc1e9515a0ff56f3ee8fd188e74
16:14 denis_boyun_ joined #mojo
16:16 punter joined #mojo
16:16 batman mst: https://github.com/jhthorsen/mojo-mysql/commit/0e7300a0b210e6ec54073a210a114123fe0140c8 :)
16:16 sri it should work pretty nice async as well, you just put a $tx->commit in your last delay step
16:17 sri $tx will be kept alive until then, or cleaned up along the way and rollback automatically
16:17 batman sri: does it matter if you call begin_work() many times?
16:17 sri depends on the database i believe
16:18 batman ok.
16:18 mst I *think* if I remember correctly that DBI will no-op it if you call it repeatedly
16:18 mst however, "why would you do that?" applies
16:19 batman it's not that i want to do that, it's just that complex database handling might call begin_work() multiple times on the same $dbh...
16:19 cpan_mojo Mojo-mysql 0.02 by Jan Henning Thorsen - http://metacpan.org/release/JHTHORSEN/Mojo-mysql-0.02
16:21 mst batman: this is why you should have some sort of intelligent transaction management system and use it religiously :)
16:21 sri "DBD::Pg::db begin_work failed: Already in a transaction"
16:21 sri <3 DBD::Pg
16:21 batman :)
16:21 mst ah yes
16:21 mst actually, a customer broke some of my code that way
16:22 mst changed $dbh->{AutoCommit} = 0 to $dbh->begin_work inside a library
16:22 mst and I was relying on doing some stuff first in the same transaction
16:22 mst of course, this code only existed in the first place because his locking system didn't actually ever lock anything
16:26 franzkafka stupid question: why would one want to use mojo::pg instead of dbix::class?
16:26 franzkafka Or are they not mutually exclusive?
16:28 denis_boyun joined #mojo
16:30 sri one is an orm, the other makes raw sql a little more bearable (and allows async queries)
16:31 franzkafka yeah, I just can't think of any reason not to use an orm
16:31 sri (for most people, i actually enjoy using raw sql)
16:31 batman franzkafka: non-blocking
16:31 purl non-blocking is portable enough for me.
16:31 franzkafka async queries I guess
16:31 franzkafka that's a good reason
16:31 sri some folks enjoy using sql
16:32 franzkafka crazy folks :)
16:32 batman sri: i have no idea how to give you credit enough. maybe something like this? https://github.com/jhthorsen/mojo-mysql/commit/82b02c771a76936e7f9d172ba7376a09dd16b3a1
16:32 sri batman: no need really
16:33 sri just don't give me credit
16:33 batman ok. so it's fine that the code is the same?
16:33 sri yea
16:34 batman i will remove the references then, so you don't have to have anything to do with mysql ;)
16:36 batman sri: btw... i'm almost done with building a new convos server. when is it ok that we do the swap?
16:36 batman can we do it tomorrow morning?
16:37 batman it require some downtime when i'm copying the database over to the new server
16:39 sri of course, thanks for the warning
16:39 stryx` joined #mojo
16:40 dod joined #mojo
16:40 batman cool. me and marcus are working together these days, so i will make him update the dns
16:41 sri mst++ # scope guards are really a nice way to deal with this
16:42 sri the DBIx::Connector way would not have worked at all for async queries
16:45 ribasushi ash++ # actual idea and initial implementation
17:02 Mso150 joined #mojo
17:14 jamesaxl joined #mojo
17:38 cpan_mojo Mojolicious-Plugin-LinkEmbedder 0.08 by Jan Henning Thorsen - http://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-LinkEmbedder-0.08
17:40 disputin joined #mojo
18:12 preaction joined #mojo
18:16 KCL_ joined #mojo
18:48 cpan_mojo Mojolicious-Plugin-LinkEmbedder 0.09 by Jan Henning Thorsen - http://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-LinkEmbedder-0.09
18:52 batman sri: closed https://github.com/Nordaaker/convos/issues/207 now :)
18:52 sri \o/
18:52 batman require refresh of assets
18:52 batman please re-open if i'm wrong
18:53 batman github sucks on open graph :P
18:53 batman the title could be better...
18:54 batman i will probably hack linkembedder to select <title> for github pages...
18:59 batman https://twitter.com/jhthorsen/status/521373793227661312
19:02 Mso150 joined #mojo
19:43 Mso150 joined #mojo
20:06 batman sri: I released a tweet fix also.
20:06 batman Refresh required.
20:10 batman new convos server in... http://timer.thorsen.pm/1413144587/36000
20:23 basiliscos joined #mojo
20:24 tempire ORMs are the devil
20:25 mst Embedding SQL in code is the devil
20:25 cfedde somewhere under the covers we will always find the SQL.
20:29 sri fight!
20:30 berov1 mst: I usually hide the SQL in nicely named methods :)
20:30 berov1 or variables
20:30 purl well, variables is a pretty common concept
20:30 mst berov1: I was just making the absurdity of tempire's statement clear
20:51 marcus I fought the devil, and the devil won.
20:58 snap_ joined #mojo
21:01 sri which reminds me that maybe we should formalize the model layer in mojolicious a little
21:02 sri perhaps make helpers easier accessible
21:03 * sri wonders which mojolicious apps on github might be the most beautiful
21:03 cfedde as long as it does not make ignoring a db based model harder.
21:04 sri not at all
21:04 sri anything we choose will have to make this example from the docs cleaner http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#Model
21:08 cfedde outstanding.
21:10 cfedde Most of what I've used Mojo for in the last year has been business logic middleware for javascript front ends.
21:21 berov sri:"perhaps make helpers easier accessible" ? like how ? aren't they  esay enough?
21:21 berov easy*
21:22 berov I have a $c->user helper for example which always returns the current user
21:45 sivoais joined #mojo
22:06 asarch joined #mojo
22:11 Mso150 joined #mojo
22:11 cpan_mojo Mojo-Pg 0.07 by Sebastian Riedel - http://metacpan.org/release/SRI/Mojo-Pg-0.07
22:18 sri interesting new perl 5.22 feature http://code.activestate.com/lists/perl5-porters/213102/
22:20 preaction yeah, i like the look of that
22:43 nicomen would it not make more sense to use my \@a = ref?
22:45 preaction \my @ref already exists though, and i believe FC addresses that potential syntax
23:04 panzana` joined #mojo
23:34 ilbot2 joined #mojo
23:34 Topic for #mojo is now 🐯 hear me roar | http://mojolicio.us | http://irclog.perlgeek.de/mojo/today
23:36 genio then there are paging options:  ?po.PageSize=25&po.CurrentPage=2
23:42 genio parameters will be ignored unless /parameters/ precedes them.    to get a list of custom reports, I GET foo.com/Documents/api/documents/customreports/parameters/?...
23:45 ilbot2 joined #mojo
23:45 Topic for #mojo is now 🐯 hear me roar | http://mojolicio.us | http://irclog.perlgeek.de/mojo/today
23:48 sri eww
23:52 genio indeed.  it gets worse with their signing method used for authentication/authorization

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary