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

IRC log for #mojo, 2017-09-15

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

All times shown according to UTC.

Time Nick Message
00:21 mishanti1 joined #mojo
01:24 aborazmeh joined #mojo
01:34 bwf joined #mojo
01:45 aborazmeh joined #mojo
01:54 ilbot2 joined #mojo
01:54 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
02:04 firnsy joined #mojo
02:04 plicease joined #mojo
02:04 renormalist joined #mojo
02:04 mikegrb joined #mojo
02:04 ranguard joined #mojo
02:04 geheimnis` joined #mojo
02:04 eday joined #mojo
02:04 augensalat joined #mojo
02:04 Gedge joined #mojo
02:04 haarg joined #mojo
02:04 charsbar joined #mojo
02:04 cromedome joined #mojo
02:04 alilles joined #mojo
02:04 mrallen1 joined #mojo
02:04 lari joined #mojo
02:04 mgrimes joined #mojo
02:04 tuxlovesyou joined #mojo
02:04 stein joined #mojo
02:04 matt_ joined #mojo
02:04 brunoramos joined #mojo
02:04 jnap joined #mojo
02:04 skaji joined #mojo
02:04 foursixnine joined #mojo
02:04 mattp_ joined #mojo
02:04 robx joined #mojo
02:04 jacoby joined #mojo
02:04 vinnix joined #mojo
02:04 diegok joined #mojo
02:05 Ralesk joined #mojo
02:05 noganex joined #mojo
02:05 marty joined #mojo
02:05 TBSliver joined #mojo
02:05 Xyem joined #mojo
02:06 ccakes joined #mojo
02:06 S joined #mojo
02:06 ribasushi joined #mojo
02:06 Bender joined #mojo
02:07 jabberwok joined #mojo
02:07 phillipadsmith joined #mojo
02:07 CandyAngel joined #mojo
02:08 noganex_ joined #mojo
02:08 gabiruh joined #mojo
02:11 kamyl joined #mojo
02:13 purl joined #mojo
02:13 iamb joined #mojo
03:08 bwf joined #mojo
04:04 dboehmer_ joined #mojo
04:08 bianca joined #mojo
04:16 disputin joined #mojo
05:05 disputin joined #mojo
05:52 n16gel joined #mojo
06:12 inokenty-w joined #mojo
06:19 dod joined #mojo
06:25 dod joined #mojo
06:27 Vandal joined #mojo
06:30 karjala_ joined #mojo
06:47 AndrewIsh joined #mojo
07:36 trone joined #mojo
07:38 bianca joined #mojo
08:04 bianca joined #mojo
09:22 dod joined #mojo
09:50 inokenty-w joined #mojo
10:17 bianca joined #mojo
10:25 jamesaxl joined #mojo
10:54 bjakubski joined #mojo
11:11 tchaves joined #mojo
11:51 geheimnis` joined #mojo
11:58 dod joined #mojo
12:47 cng joined #mojo
12:55 bianca joined #mojo
13:07 Pyritic joined #mojo
13:23 marty joined #mojo
13:41 bianca joined #mojo
13:44 gryphon joined #mojo
13:57 PopeFelix joined #mojo
13:57 gryphon joined #mojo
13:57 geheimnis` joined #mojo
13:57 karjala_ joined #mojo
13:57 bwf joined #mojo
13:57 purl joined #mojo
13:57 iamb joined #mojo
14:00 PopeF joined #mojo
14:16 ChmEarl joined #mojo
14:30 disputin joined #mojo
14:40 jabberwok Before I add a test, I need to understand why » prove -r « never showed me any errors even for incorrect code.
14:41 sri jabberwok: maybe try fixing all the stuff and then push one commit? i really don't like getting all those notifications from your pull request
14:41 sri every time you push i get an email
14:41 jabberwok sri, apologies.  coding since 1977 but I am new to this procedure
14:42 sri one of the main reasons i hate work in progress pull requests
14:42 jabberwok I do see "set TEST_UNIX to enable" on user_agent_unix.t for example (which is what failed on github) but even setting that never produced a failure even when github gives me one later. Unsure how to proceed
14:43 sri i mean, i guess i could unsubscribe, but then people will have to poke me here if there's an issue that needs attention
14:44 jabberwok i need to know (1) how can I actually make the tests properly fail locally, and (2) is there a way to run the github tests as a trial
14:44 jabberwok this must be written up somewhere but where
14:46 sri ah, i guess i will just unsubscribe from pull requests that get lots of tiny commits
14:47 sri ok, if you get a "work in progress" batch that means i won't follow the pull request anymore
14:47 sri *badge
14:48 jberger sri can you paste your test run command with all the env vars set?
14:48 sri make clean; perl Makefile.PL; TEST_POD=1 TEST_HYPNOTOAD=1 TEST_MORBO=1 TEST_PREFORK=1 TEST_EV=1 TEST_ONLINE=1 TEST_IPV6=1 TEST_TLS=1 TEST_SOCKS=1 TEST_SUBPROCESS=1 HARNESS_OPTIONS=j9 TEST_UNIX=1 make test
14:55 karjala_ joined #mojo
15:03 disputin1 joined #mojo
15:05 jabberwok thank you sri
15:08 jberger sri: I'm glad you have a solution to noisy PRs, is there some way we can make that badge more visible to contributors?
15:08 jberger in the PR template or so?
15:09 jberger because in the end jabberwok was just trying to help/get feedback but the response here was pretty negative as a result
15:13 sri i guess it's a little unfortunate that people are not aware that when they open a pull request every comment/push results in an email being sent to 241 people
15:17 jberger like it or not, PRs are the tool we have to accept contributions
15:17 sri looks like you can only deactivate email notifications for *all* pushes on github
15:17 sri not per repo
15:18 jberger I suppose potential contributions could be branches in forks and then linked here, but now with a designated tag (that can be filtered) and if that can be made clear to everyone, then perhaps the problem can be alleviated?
15:19 jberger I do want to make it reasonably easy for contributors and especially new contributors to contribute
15:19 sri well, i for one have push notifications disabled globally now
15:25 sri since jberger seems to think i'm criticising jabberwok, that's not at all my intention, i was complaining about github
15:27 jabberwok everything is good. --- tests in progress.  curiously, » $tx = $ua->build_tx(GET => 'http://cdeabcdeffoobarnonexisting.com'); « does not fail on system with AT&T dns (they do the nasty wildcard-goes-to-our-happy-fun-fun-redirect page)
15:28 jabberwok so in fact mojo tests indicate that AT&T itself *is* failure =grin=
15:29 brunoramos joined #mojo
15:31 jberger jabberwok: for the record I've always gotten test failures of t/mojo/user_agent_online.t
15:31 jberger at my home connection
15:32 jberger been that way for years: https://irclog.perlgeek.de/mojo/2015-12-06#i_11663919
15:32 jberger interestingly I get two failures in that test now
15:33 jberger I now fail this one: https://github.com/kraih/mojo/blob/master/t/mojo/user_agent_online.t#L60
15:33 jberger I get an empty string
15:33 jberger (along with the one that always fails https://github.com/kraih/mojo/blob/master/t/mojo/user_agent_online.t#L163 where I get a 301 rather than a 302)
15:59 Grinnz jabberwok: did you see my comment that 'scalar @$_ - 1' can be shortened to '$#$_' ?
16:02 Grinnz and you're right about the parentheses, I didn't notice that there was a second item after the map in the assignment
16:17 disputin joined #mojo
16:25 sh14 joined #mojo
16:36 dod joined #mojo
16:59 trone joined #mojo
17:02 arcanez I thought scalar and $# were different
17:02 arcanez oh
17:02 arcanez I missed the - 1
17:02 Pyritic joined #mojo
17:12 arcanez and i think '$#$_' is why some people hate perl ;)
17:15 jacoby joined #mojo
17:17 pink_mist very often one can get away with just '-1' instead of '$#...'
17:17 pink_mist if you're just using it to index the last element of an array
17:17 tcohen joined #mojo
17:18 Grinnz this is in a range, though
17:18 jabberwok gotcha
17:18 jabberwok i mean:  == aha
17:19 pink_mist yeah, which is why I didn't suggest this for jabberwok, but just as a reply to arcanez's complaint
17:42 arcanez wasn't so much as a complaint as an observation
17:45 maschine I had no idea what '$#$_' even was until pink_mist commented. lol
17:46 maschine *10 years of perl programming.. still feel like a n00b
17:46 Grinnz it's weird at first, but it's just a combination of the $# syntax for last-index, and dereferencing $_
17:49 maschine actually I can't add, it's been 20 years! :|
18:01 arcanez you haven't been around mst enough then
18:04 maschine I try not to do stuff like that..  mostly because I will probably forget how my own program works.  actually, that's likely to happen anyway..
18:15 PopeF joined #mojo
18:25 rshadow joined #mojo
18:27 disputin joined #mojo
18:31 [0xAF] Hi guys. Any suggestion on how to extract .po file from my sources with Locale::Maketext (xgettext.pl tool). It seems it supports TT2 and looks for <%= l('text') %> to extract. But it does not recognize the format <%= l 'text' %>. So I understand I need to write a parser to recognize the wanted format, but do you have any suggestion, before I get into RegEx voodoo...
18:32 bianca joined #mojo
18:35 pink_mist why not just change it to l('text') ?
18:36 [0xAF] that was the obvious solution to me too... but too many templates to change, and i prefer to write it s <%= l 'text' %> actually. so i was hoping there would be an easy way...
18:39 stryx` joined #mojo
18:44 bianca joined #mojo
19:05 disputin joined #mojo
19:07 jabberwok joined #mojo
19:21 tchaves joined #mojo
19:27 PopeFelix joined #mojo
19:32 Pyritic joined #mojo
19:34 gryphon_ joined #mojo
20:39 dwatson joined #mojo
20:41 dwa hello #mojo, I am curious how hard is it to extend Mojo::UserAgent to respdond to a custom HTTP code?
20:42 dwa in particular I would like to add a custom HTTP response whihc tells the useragent to sleep some small amount of time then follow a given URL.  so like a redirect but with a number of seconds to wait
20:43 dwa I saw the part in the cookbook about Decorating_follow-up_requests but no other example code looked anything like what I am trying to do
20:45 Grinnz Mojo::UserAgent is just a client, it does whatever you tell it to do
20:47 dwa yes and right now it will follow redirects which is great.  How do I tell it to sleep N seconds then follow a redirect when given a custom HTTP return code?
20:49 pink_mist a custom return code means it won't "follow" it on its own. so you write code that checks if that was the return code, and if so, you can sleep yourself, and then follow it yourself
20:50 dwa right! I guess I am looking for where I would hook that code in.
20:51 Grinnz if you want a client to do something which isn't in the HTTP spec, then just do it yourself based on the response
20:51 Grinnz no hook. you get the response from the first request, you inspect it, you do other things
20:53 pink_mist my $client = Mojo::UserAgent->new(); my $tx = $client->get(...); if ($tx->code == 24872874827) { sleep 5; $client->get($tx->headers->{Location}); } ... or something along those lines. I didn't look at the documentation so I might be misremembering what's returned by things and how to access the things
20:53 pink_mist but you can read the documentation for the right way to do it yourself
20:54 dwa hmm I suppose.  I was hoping to extend the useragent and not have the application deal with it.  I see what you're saying though.  Thanks
20:54 sri make a role, add a new user agent method ($ua->get_with_slow_redirect(...))
21:04 jberger trying to think about doing this, on a redirect the start event is emitted again, correct?
21:04 jberger and you can tell that it is a redirect because the previous requests will exist in the transaction (or message, I can't remember exactly atm)
21:05 jberger but I'm not sure how you delay the request
21:05 jberger as pink_mist says you'd have to blocking sleep at that point to do so, but that blocks the loop
21:06 jberger can the start event be used to prevent a request from being made?
21:06 jberger consider the simpler case:
21:07 jberger $ua->on(start => sub ($ua, $tx) { $ua->prevent($tx) if $tx->req->url =~ /$banned_site/ });
21:07 jberger where the prevent method is what I'd be looking for
21:08 jberger because if so then you could prevent/remove the tx while adding it back in a timer
21:11 dwa the use case is that I have useragent talking to an http server.  sometimes that server needs a few seconds to catch up so it issues an html page with a meta refresh tag in it.  This causes the browser to effectively sleep for a couple seconds then come back and query the server again.  I would like to emulate this behavior with Mojo::UserAgent except by passing a custom http return code or something.
21:13 Grinnz you could easily have your code check for the meta refresh tag in the response and do that yourself
21:13 Grinnz without using any custom http code
21:15 Grinnz if (my $meta_refresh = $tx->res->dom->at('meta[http-equiv="refresh"]')) { my $refresh_time = $meta_refresh->{content}; ... }
21:16 Grinnz or i guess you'd need to parse out the url from the content attribute, since it's a redirect
21:20 dwa well that's not the problem Im solving.  I dont want to parse the content.  A custom http return code or header would be out of band and a much better solution in my particular case if that makes sense.
21:28 maschine so I have a problem that seems like it should be really simple.. just a form for a 'PUT' request - %= form_for editrow => (method => 'PUT', enctype) => begin
21:29 maschine I have a matching route "put '/editrow' => sub { ... }" but it doesn't find the route
21:29 maschine it says "can't find GET request'
21:29 maschine if I change it from PUT to POST, it works...
21:30 maschine trying to understand why it's ending up being a GET request instead of PUT.  my browser maybe?
21:31 Grinnz dwa: well the meta tag is a standardized way to do it, so there's that. but if you are controlling the server and client you can implement it however you feel is best
21:34 maschine er realized there's a typo in the snippet I posted above ", enctype" - ignore that (was halfway through deleting part of that line)
21:35 Grinnz form methods can only be get or post
21:35 Grinnz browsers don't support anything else
21:35 maschine *facepalm*
21:35 maschine thanks :p
21:35 Grinnz there is a workaround, i forget what it is
21:36 maschine probably ajax or something
21:36 maschine actually that might be easier anyway
21:36 Grinnz well, usually i find ajax to be easier than html forms but that's besides the point :P
21:37 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Forms
21:38 Grinnz the _method query parameter is the workaround
21:39 pink_mist dwa: if you can control both the server and the client, why not have the server stall sending the reply until the resource has been generated?
21:52 jnap in Mojo::DOM there's a number of places were we seem to serialize and reparse in ways I don't understand.
21:53 jnap for example when calling replace, we serialize the replacement $dom and reparse into into a DOM before doing the low level tree surgery
21:53 jnap is that just 'this was the easiest way to do this and DOM tree manipulation is hairy as it is already, or something deeper?
21:55 jnap I only noticed because I was doing crazy stuff like $dom->attr( info=>sub { ...} ) and that was getting stringified when in a replace or a few other places that seem to do ->parse("$dom")
21:59 jnap example: https://metacpan.org/source/DBOOK/Mojo-DOM58-1.003/lib/Mojo/DOM58.pm#L130
22:00 jnap I'm guessing the DOM needs to be cleaned up or normalized in some why and doing it with ->parse("$dom") is the easiest and safest way to do that
22:01 jnap I do think it would likely be a performance improvement if we could avoid that, particularly in cases where the replace $dom (in this example) was big.
22:05 sri a lot of that was just the easiest way to implement it, and just never came up as a bottleneck
22:05 maschine Grinnz: I don't see how that example adds the "?_method=PUT" string to the action.. When I run the example code, if I change the action name to anything other than "nothing" it disappears.
22:05 maschine I ended up just typing the HTML manually.. and that does work
22:06 Grinnz maschine: i think the form_for does it automatically when it's referring to a PUT route
22:07 Grinnz https://metacpan.org/pod/Mojolicious::Plugin::TagHelpers#form_for
22:07 maschine ahh
22:08 maschine I didn't change the route, I just changed the template and refreshed the source HTML
22:21 jnap sri: so you don't mind if I fork and mess around?  I could see benefits if was can avoid re-parsing as much as possible
22:22 sri jnap: performance improvements are always welcome, just make sure you can demonstrate them
22:23 jnap aye aye
22:30 maschine is there a way to deref something like $self->param, like I would do to a hashref?
22:35 maschine this must be what I'm looking for: http://mojolicious.org/perldoc/Mojo/Message/Request#params
22:40 Grinnz not sure what you mean
22:40 Grinnz $self->param is a method, not an attribute
22:40 Grinnz $self->req->params is a Mojo::Parameters object
22:44 maschine right that's what I was looking for.. the object, not the method.  so I can iterate through the form submission without having to know ahead of time what's in it. :)
22:46 Grinnz yeah, you can iterate through ->names on a Parameters object
22:47 Grinnz or ->pairs
22:48 marty joined #mojo
23:12 jzawodn joined #mojo
23:12 jzawodn left #mojo
23:38 marty joined #mojo

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