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

IRC log for #mojo, 2014-04-23

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

All times shown according to UTC.

Time Nick Message
00:05 punter is mojolicious 5.0 expected so soon?
00:16 sri hmmm... the todo list of the official mongodb driver for perl starts to read like a Mango feature list
00:28 spuelrich joined #mojo
00:52 punter joined #mojo
00:53 punter I need to use all my helpers from a Cron script. Is it possible to acquire a $c object outside of an actual web request?
01:01 d4rkie joined #mojo
01:01 tianon sri: hahaha, you should submit them a PR that adds something like "for these and more cool features, see Mango"
01:02 klapperl joined #mojo
01:04 ua joined #mojo
01:07 asarch joined #mojo
01:09 laouji joined #mojo
01:10 btyler joined #mojo
01:11 webart joined #mojo
01:12 webart http://stackoverflow.com/questions/23226330/testing-url-generation-with-testmojo  good SO question by zoul :)
01:19 sri webart: are you zoul?
01:20 webart no ;-)
01:21 sri ok, would have answered here otherwise
01:21 webart I do want to know the answer though :-D
01:21 webart but I'm just looking in the docs
01:25 webart tests are excellent in perl in general but I found it hard to get my own weird mojo tests to work until I remembered UserAgent
01:26 webart with tests you can change your web app 10 times a day ... and prove it isn't broken (even when it is)
01:27 webart :P
01:27 shmuel joined #mojo
01:31 yongbin_ joined #mojo
01:40 aggrolite joined #mojo
01:48 yongbin joined #mojo
01:53 genio joined #mojo
01:58 d4rkie_ joined #mojo
02:01 webart left #mojo
02:08 sri wonder what Mojo::EventEmitter would look like with promises and supplies
02:09 sri my $supply = $foo->on('bar'); my $promise = $foo->once('bar');
02:09 sri hmmm
02:10 sri or once would just be removed
02:11 sri $foo->on('bar')->tap(sub {...});
02:11 sri $foo->on('bar')->next(sub {...});
02:14 sri hmm
02:14 sri or more crazy
02:14 sri my $promise = $foo->on('bar')->next;
02:14 sri getting a promise from a supply
02:17 sri btw. the leak problem is a non-issue i believe now, since the invocant  would be captured too
02:18 sri $ua->aget('first.url')->then(sub { shift->aget('second.url') })->then(sub { say pop->res->body })
02:42 cooper joined #mojo
02:50 shmuel joined #mojo
03:13 laouji joined #mojo
03:20 russum joined #mojo
03:48 hlin_ joined #mojo
04:28 Vandal joined #mojo
04:33 batman sri: "could just do" -- do you mean the non-blocking/blocking part?
04:35 laouji joined #mojo
04:58 suy joined #mojo
04:58 d4rkie joined #mojo
05:03 denis_boyun joined #mojo
05:14 balazs joined #mojo
05:20 laouji joined #mojo
05:33 batman does it make sense that weaken $obj; $obj->{other_obj} = bless {}; $obj->{other_obj}->{cb} = sub { $obj }; will leak?
05:38 batman wow. it looks like that...
05:39 batman https://gist.github.com/jhthorsen/11203842 <-- wonder how i fix that
05:42 batman looks like i need to make a pointer back to $self instead of passing it directly in
05:47 davido_ joined #mojo
05:58 sugar__ joined #mojo
05:58 howitdo joined #mojo
05:58 dod joined #mojo
06:04 sugar joined #mojo
06:13 shmuel batman: when you are weakening $obj, I think that the object will immidiately destroyed
06:14 shmuel and then $obj->{two} will create a new hash. or something.
06:14 batman it does not look like that
06:14 shmuel and then you have a circular ref with that new hash and the sub.
06:15 shmuel try moving the weaken to the end.
06:16 sujithm joined #mojo
06:16 shmuel does the result change?
06:18 batman sorry. i changed the test-file. you're right about the original test.
06:19 shmuel do you still need explanation on what is going on?
06:20 shmuel but basically, you shouldn't directly hold / use a weakened ref.
06:20 batman not on that one.
06:20 shmuel they are for usage inside data structures and so.
06:29 batman https://gist.github.com/jhthorsen/11203842 # this works... it's so annoying that i can't make Mojo::Redis work :(
06:29 batman need to get to work now
06:29 batman *bbl*
06:31 batman https://github.com/marcusramberg/mojo-redis/blob/bug/on-message-leaking/t/theory.t # deleted the gist
06:31 dexteruk joined #mojo
06:31 dexteruk_ joined #mojo
06:39 cleverfox joined #mojo
06:41 cleverfox joined #mojo
06:43 sujithm_ joined #mojo
06:45 igorsutton joined #mojo
06:48 shmuel batman: I'll have to see the output of that... :-)
06:55 rawler joined #mojo
07:00 igorsutton joined #mojo
07:01 eseyman joined #mojo
07:36 hummeleBop joined #mojo
07:41 sujithm joined #mojo
07:41 laouji joined #mojo
07:47 marcus_ joined #mojo
07:55 trone joined #mojo
07:57 batman shmuel: curl https://raw.githubusercontent.com/marcusramberg/mojo-redis/bug/on-message-leaking/t/theory.t | perl -
07:57 batman not very hard to run, once you have the source code :) no funky deps
08:01 shmuel I get "no leakage".
08:31 batman Yeah. That's why I said "it works" :) but mojo-redis is still messed up :(
08:32 arthas joined #mojo
08:37 mire_ joined #mojo
08:39 laouji joined #mojo
08:42 laouji joined #mojo
08:48 edestler joined #mojo
08:49 basiliscos joined #mojo
08:59 fhelmber_ joined #mojo
09:16 batman mojo-redis doesn't seem to leak anymore and i have no idea why :(
09:16 batman going to try to change back to get a new leak
09:21 meshl joined #mojo
09:31 Jonneh joined #mojo
09:31 batman fail :(
09:45 batman cpan_mojo didn't notice about the new release... weird
09:55 sujithm joined #mojo
10:07 sugar_ joined #mojo
10:07 bbl joined #mojo
10:07 yongbin joined #mojo
10:14 yongbin joined #mojo
10:24 sujithm joined #mojo
10:24 d4rkie joined #mojo
10:28 yongbin joined #mojo
10:32 denis_boyun joined #mojo
10:37 d4rkie joined #mojo
10:42 mire_ joined #mojo
10:50 disputin joined #mojo
11:26 rem_lex joined #mojo
11:40 dod joined #mojo
11:48 Akron joined #mojo
11:57 edestler joined #mojo
11:57 neilhwatson joined #mojo
12:06 sujithm joined #mojo
12:16 dod joined #mojo
12:22 ver joined #mojo
12:34 mire_ joined #mojo
12:57 ver joined #mojo
13:03 dod joined #mojo
13:04 gryphon joined #mojo
13:13 dod joined #mojo
13:14 dahl joined #mojo
13:16 Negor How to add checks to validator in Controller?
13:18 Negor sub add_do { my $self = shift;  my $validate = $self->validation; $self->add_check({not_zero => sub {my ($name, $value) = @_; return ($value+0 > 0) ? 0 : 1}});
13:23 batman Negor: https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Adding-form-validation-checks
13:23 Negor thx
13:23 batman don't add checks in your controller. add it in your application.
13:23 batman either in startup() or like the doc says if you have a lite app
13:30 dod joined #mojo
13:37 hesco I have also been struggling with validation issues.  I finally sorted out how to $self->validation, but lost days (unsuccessfully) trying to sort out the jquery code on the browser side so that the { display: none; } divs would open back up without losing the user's data which had just failed server-side validation.  I gave that up for the moment, and yesterday afternoon implemented client-side data validation with the jquery.validate.js l
13:37 hesco ibrary.  However, if something passes client-side validation, but is rejected by the server-side checks, the form loses the data for every field managed by the client-side validation checks.  Are there any articles or documentation out there which discusses how to make mojo and jquery play nice in the realm of form data validation?
13:39 bluescreen joined #mojo
13:44 btyler joined #mojo
13:45 dod joined #mojo
13:48 bluescreen_ joined #mojo
13:51 asarch joined #mojo
14:01 batman hesco: sounds like the jquery plugin suck.
14:01 batman you should however focus on the server side.
14:01 batman client side give you zero security.
14:01 batman it's just convenient
14:02 hesco yes, true, understood.  But its left to me (for the first time ever, mounting the js learning curve these days) to also handle the UX as well, not just the data integrity.
14:02 batman sorry, but what about google "jquery form validation" and see if you can read reviews?
14:02 hesco I'm guessing I will disable client side validation whenever I work on hardening the server-side checks.
14:03 batman sorry = i don't have time to look at it
14:03 hesco understood
14:03 batman yes, that is a very good idea.
14:03 batman it's super confusing when both sides are buggy.
14:03 batman you should also write unit tests to validate the server side
14:03 hesco agreed
14:04 batman $t->post_ok('/register', form => {})->element_exists('form input[name="username"][class="field-with-error"]');
14:04 batman stuff like that ^
14:05 batman good luck :)
14:14 dod joined #mojo
14:20 sri tempire: considering you're the one who's going to teach non-blocking, i'd really like to hear your thoughts on promises
14:22 balazs joined #mojo
14:41 sh4 joined #mojo
14:48 skullbocks joined #mojo
14:50 Akron joined #mojo
14:54 sri http://pastie.org/9105180 # a timer example comparing the two styles
14:54 jim joined #mojo
14:55 sujithm joined #mojo
15:03 tempire sri: I haven't had the time yet to read through the backlog of all your promise comments, but it's on my list.
15:03 sri :(
15:03 irq joined #mojo
15:04 tempire Don't be sad. That's not a "I'll get around to it", it's a "IMTRYINGTODOALLTHETHINGSGIVEMEASECOND!!!1"
15:06 genio DOALLTHETHINGSFASTER!  :)
15:08 disputin joined #mojo
15:08 mire_ joined #mojo
15:11 tempire Cursory look:
15:11 sri http://pastie.org/9105228 # and an adaption of the mango example
15:11 sri oops
15:11 sri the mango methods need an ->a* prefix of course
15:12 davido joined #mojo
15:12 tempire Certainly the nicest promise implementation for Perl thus far
15:12 sri http://pastie.org/9105235 # something like that... hahaha ->aall
15:13 sri in my tests i see the need for a lot more weakening
15:13 sri since the invocant is usually not passed around anymore
15:14 tempire I don't understand why you couldn't detect whether the last parameter of a ->get is a subref or a promise, and not need multiple methods.
15:14 sri of course you can detect that, but then you have to create the promises yourself
15:15 sri my $promise = Mojo::Promise->new; $ua->get('some.url' => $promise); $promise->then(sub {...});
15:15 sri that's *a lot* of boilerplate
15:15 tempire yeah, understood
15:17 sri well, the method names are not much of an issue
15:17 sri can always go with a sensible theme like ->get() and ->get_later() or so
15:17 sri or even ->get() and ->get_now()
15:18 tempire I like the timer promises example
15:19 tempire I'm trying to put myself in the mindset I had before I understood ->begin
15:19 tempire because it seems so simple now
15:19 tempire I like ->all
15:20 dod joined #mojo
15:21 sri http://pastie.org/9105261 # there are more methods nobody has considered yet i believe
15:23 sri http://pastie.org/9105271 # also websockets
15:31 bluescreen joined #mojo
15:35 igorsutton joined #mojo
15:50 tempire Looks good. Except for the weaken, of course
15:53 io joined #mojo
15:54 io Hello!  Please answer!!              How to get POST data from $self  ??
15:57 tempire io: http://mojolicio.us/perldoc/Mojo/UserAgent#post
16:00 tusj joined #mojo
16:01 io tempire:  Thank YOU!!     sorry for the ambiguity.  On Mojolicious server in     post  "/foo"  => sub {$self = shift;   ....
16:07 beyondcreed joined #mojo
16:20 irq joined #mojo
16:23 sri i missed a problem though... ->timer already returns an id :S
16:23 meshl joined #mojo
16:24 arthas joined #mojo
16:35 Akron io: Probably http://mojolicio.us/perldoc/Mojolicious/Controller#req - if you post a form you have the data in ->param.
16:40 Theano joined #mojo
16:40 Theano Hi
16:40 purl que tal, Theano.
16:54 bluescreen joined #mojo
17:21 abra joined #mojo
17:30 dod joined #mojo
17:31 hesperaux_ joined #mojo
17:40 Theano left #mojo
17:51 sri promises are hard... lets go shopping
17:52 abhishekisnot joined #mojo
17:53 sri just stumbled over another problem
17:53 sri promises need to store the ioloop they belong to, since invocation of the callback needs to be delayed one tick
17:54 sri that in turn makes it impossible to use the promise itself as an identifier to things like timers
17:55 sri because you can't pass it around without leaking like crazy
17:59 sujithm joined #mojo
18:10 denis_boyun joined #mojo
18:22 trone joined #mojo
18:37 io Akron: Thanks for the advice!!  unfortunately I Dump all variables shown in http://mojolicio.us/perldoc/Mojolicious/Controller#req,   no one contains message body (((      I make POST http request from chrome console:  var xr=new XMLHttpRequest(); xr.open('POST', 'http://localhost:3000/hello'); xr.send(" HTTP_REQUEST_BODY !!!!")
18:39 io how to get body of HTTP request to my server in     post '/foo' => sub { ....  ?
18:40 denis_boyun_ joined #mojo
18:41 moritz io: with $self->req somehow
18:41 moritz io: probably $self->req->body or so
18:49 punter joined #mojo
18:56 io moritz: ))))) it is realy $self->req->body
18:57 io but if we do$ perl -MMojolicious::Lite -MData::Dumper -E ' any "*" => sub {say Dumper shift->req}; app->start' daemon
18:58 io and then  form browser console:  var xr=new XMLHttpRequest(); xr.open('POST', 'http://localhost:3000/hello'); xr.send(" HTTP_REQUEST_BODY !!!!")
19:00 io Mojo get HTTP OPTIONS reques,  not POST!!!  my be some one understand why? and how to send POST via XMLHTTPRequest  line $.post from JQuery
19:03 hesperaux joined #mojo
19:10 denis_boyun joined #mojo
19:15 irq joined #mojo
19:39 sri stevan has made some good examples for his Promises implementation https://metacpan.org/pod/Promises::Cookbook::ScalaFuturesComparison
19:42 maxhq joined #mojo
19:48 bluescreen joined #mojo
19:58 cooper joined #mojo
20:00 babl joined #mojo
20:02 babl joined #mojo
20:28 sri as much as i complain about the mongodb wire protocol... PostgreSQL is sooooo much worse https://metacpan.org/source/TEAM/Protocol-PostgreSQL-0.008/lib/Protocol/PostgreSQL.pm#L146
20:29 sri compare that to these few lines https://github.com/kraih/mango/blob/master/lib/Mango/Protocol.pm
20:35 DaniBunny joined #mojo
20:41 hesco I see from time to time, not in the logs, but on the console where I started my application, this warning/error:  "Use of uninitialized value $cb in method lookup at local/lib/perl5/Mojo/Reactor/Poll.pm line 109.
20:41 hesco Mojo::Reactor::EV: Read failed: Can't locate object method "" via package "Mojo::Reactor::EV" at local/lib/perl5/Mojo/Reactor/Poll.pm line 109."
20:42 hesco that is coming up from the mojo code, not from my code, or if it is from my code, I am not seeing enough of the stack to know where it is coming from.
20:43 hesco I see: local/lib/perl5/Mojo/Reactor/EV.pm with 444 permissions
20:44 hesco perl -wc says:  local/lib/perl5/Mojo/Reactor/EV.pm syntax OK
20:48 russum joined #mojo
20:48 batman hesco: try use Carp 'confess'; $SIG{__DIE__} = sub { confess $_[0] };
20:48 batman somewhere in the top of your app
20:49 batman i don't think that will help you, but you can try it out...
20:49 russum1 joined #mojo
20:49 hesco thanks batman, trying that now
20:49 batman it's not mojo core's fault...
20:49 batman either your code or a plugin. or a plugin used wrong.
20:50 batman something async set up wrong...
20:51 meshl joined #mojo
20:51 hesco ok, have added the confess code, setting up the signal handler in a BEGIN{} block.
20:52 batman it probably won't help you much though... it will probably just give you stack trace from mojo
20:53 hesco I have no idea what is triggering it, do not know how to reproduce the warning, so I will watch for a stack trace to get confessed in my work space and see where that leads.
20:53 sri could also be a platform specific timing issue, i've seen that error reported before, but nobody ever gave me code to replicate it
20:53 batman but it could also be that something is modifying $_ inside the async callback
20:54 batman like $ua->on(start => sub { $_ = undef }); # this will only work the first time
20:54 sri if you can't replicate it, then your chances of getting help are close to zero
20:54 hesco understood, same advice I offer others who report bugs to me.
20:54 batman :D
20:54 batman hesco++
20:57 sri stack trace really won't help you much
20:58 sri i know it's coming from here https://github.com/kraih/mojo/blob/master/lib/Mojo/Reactor/EV.pm#L52
20:59 sri so odds are there's an io watcher that has been destroyed, but libev signals readable/writable anyway
20:59 sri why that is... well... that's for you to find out
21:12 sugar__ joined #mojo
21:15 sujithm joined #mojo
21:16 tianon joined #mojo
21:16 tianon joined #mojo
21:18 tianon joined #mojo
21:21 tianon joined #mojo
21:22 maxhq joined #mojo
21:25 meshl joined #mojo
21:38 mire_ joined #mojo
21:48 sugar joined #mojo
22:13 batman https://t.co/eDvenSokrO
22:40 d4rkie joined #mojo
22:49 punter joined #mojo
22:50 punter I need to use a helper from inside a cron script. Is it possible to create a $c (controller) object in the cron script, rather than from a real web-request?
22:51 punter Or, how else can I call the helper?
22:53 blinky joined #mojo
22:59 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Application_embedding
23:03 da5id joined #mojo
23:04 russum joined #mojo
23:19 janus joined #mojo
23:21 Hengaini joined #mojo
23:22 Hengaini How can I find books about mojolicious?
23:35 Hengaini Is there anybody here?
23:35 sri Zzz
23:35 Hengaini Is there book about mojolicious?
23:36 sri not yet
23:37 Hengaini What's the best learning practice? http://mojolicio.us?

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