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

IRC log for #mojo, 2016-09-18

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

All times shown according to UTC.

Time Nick Message
02:08 meshl joined #mojo
02:19 noganex_ joined #mojo
03:08 jberger a lazy night so I was scrolling though stackoverflow [mojolicious] tag
03:08 jberger and I found this one: http://stackoverflow.com/questions/38054279/fail-to-test-the-rendered-output-after-a-redirect-from-a-delete-route-mojolici/39553660#39553660
03:09 jberger any other thoughts to add?
03:11 jberger oh, and now that I ask it seems that I was wrong :o
03:11 jberger 303 status
03:29 jberger actually, that was a very satisfying post, I might turn that into a blog post
03:32 jberger wait, now I'm totally confused though
03:39 preaction did you answer that? because it doesn't look answered
03:41 jberger I deleted it
03:41 jberger my answer was wrong
03:41 jberger Mojo::UserAgent doesn't handle 303 correctly
03:41 jberger I'm putting together a bug report and maybe a patch
03:41 jberger original text is here: https://gist.github.com/jberger/800fe7923f5cb48f39d3f1f9cde96e00
03:42 jberger I misread my own results though
03:45 jberger put a stub back in its place
03:51 jberger new issue: https://github.com/kraih/mojo/issues/999
03:51 jberger (ooooh, 999, that means if I make a PR ...)
03:58 good_news_everyon joined #mojo
03:58 good_news_everyon [mojo] jberger created status_303 (+1 new commit): https://git.io/viXck
03:58 good_news_everyon mojo/status_303 c88d919 Joel Berger: handle all 303 redirects with a GET method
03:58 good_news_everyon left #mojo
03:59 good_news_everyon joined #mojo
03:59 good_news_everyon [mojo] jberger force-pushed status_303 from c88d919 to acd3cfa: https://git.io/viXcL
03:59 good_news_everyon mojo/status_303 acd3cfa Joel Berger: handle all 303 redirects with a GET method...
03:59 good_news_everyon left #mojo
04:00 jberger woo hoo! I got #1000!
04:00 jberger \o/
04:04 jberger hmmm, I wonder if I can make perltidy happier (yes I did tidy, but)
04:07 kaare_ joined #mojo
04:11 jberger I can make it a lot prettier if I rearrange things a bit, but now, one line of 82 :-P
04:12 jberger $method is a long variable name ...
04:12 jberger no, I'll leave it for now
04:14 dugword joined #mojo
04:15 dugword users
04:16 dugword left #mojo
04:16 jberger no idea what ^^ was
04:37 jberger Chrome handles DELETE -> 303 -> GET
04:48 polettix joined #mojo
05:04 jberger ok here is my updated response to the SO OP: https://gist.github.com/jberger/800fe7923f5cb48f39d3f1f9cde96e00
05:10 jberger Actually in really reading the OPs post, he has a serious bug in using 302 rather than 303
05:11 jberger so I'm posting the response to him
05:11 jberger including a note about the open PR
05:11 jberger he won't be able to test correctly yet, but his actual clients (browsers) will work as expected
05:16 jberger (and in my haste I linguistically assume "he", sorry about that)
05:16 jberger (oh, but his name is Piotr and he has a male picture, probably correct then)
05:24 jberger and I opened an issue on his project's tracker
05:25 jberger I think that's enough excitement for one night
05:26 jberger hey sweet, that project might actually be worth looking at
06:33 jamesaxl joined #mojo
06:42 jamesaxl joined #mojo
06:57 dod joined #mojo
07:01 dod joined #mojo
07:15 Vandal joined #mojo
07:49 abra_ joined #mojo
08:05 anton joined #mojo
08:10 dod joined #mojo
08:19 inokenty-w joined #mojo
08:24 irqq_ joined #mojo
08:27 kaare_ joined #mojo
08:33 dod joined #mojo
08:35 cuechan joined #mojo
08:42 good_news_everyon joined #mojo
08:42 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/viXEF
08:42 good_news_everyon mojo/master 545da2a Sebastian Riedel: Merge pull request #1000 from kraih/status_303...
08:42 good_news_everyon left #mojo
08:45 polettix joined #mojo
09:06 good_news_everyon joined #mojo
09:06 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/viXub
09:06 good_news_everyon mojo/master 56cef83 Sebastian Riedel: no need to use so much code
09:06 good_news_everyon left #mojo
09:29 dod joined #mojo
09:45 dod joined #mojo
09:45 dod joined #mojo
10:00 dod joined #mojo
10:01 dod joined #mojo
10:57 Zx3 joined #mojo
11:01 rubin joined #mojo
11:43 sri oooh, this is a nice atom package https://atom.io/packages/git-time-machine
12:00 jberger Neat
12:05 dod joined #mojo
13:07 good_news_everyon joined #mojo
13:07 good_news_everyon [mojo] jberger deleted status_303 at acd3cfa: https://git.io/viX1N
13:07 good_news_everyon left #mojo
13:47 kaare_ joined #mojo
14:44 PryMar56 joined #mojo
15:07 polettix joined #mojo
15:24 thowe I thought my environment must be screwed up, but I installed a new perl and am getting the same DBIC error...  It doesn't really tell me how it got there...
15:24 thowe Can't locate object method "in_storage" via package "MoPieNg::Controller::Network" at /home/tim/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/DBIx/Class/Row.pm line 252.
15:27 pink_mist this doesn't really sound like a mojo issue 0_o
15:27 thowe yeah...
15:44 cpan_mojo Mojo-ACME-0.07 by JBERGER https://metacpan.org/release/JBERGER/Mojo-ACME-0.07
15:48 thowe pink_mist, I fixeded it...  bit of code didn't translate over from Catalyst to Mojo the way I thought it would and my reference id ended up undef...
16:40 polettix hello all
16:41 polettix using Test::Mojo::json_is does not allow to put \1 for “true” in the expected value, is this something that would be a nice to have?
16:44 jberger polettix: that is an interesting idea, not sure how hard it would be to do
16:45 jberger You can use Mojo::JSON::true in that case though
16:45 polettix I just thought it’s a bit inconsistent to have \0 and \1 allowed elsewhere and not in Mojo::Test. Sure I reverted to use Mojo::JSON->test for my test right now
17:09 jberger polettix: think of it in a different way
17:09 jberger \1 and \0 are shortcuts for constructing json documents
17:10 jberger in that context, since you aren't constructing a document to compare against, it wouldn't be the same thing
17:10 polettix eheheh
17:11 jberger I actually take it further though
17:11 polettix right, no inconsistency actually
17:11 jberger I think that \1 and \0 are only useful if you IMMEDIATELY encode a json document
17:11 jberger for example if you build some large hashref of data to be used in a few places before serializing it to json, then even it should use Mojo::JSON::true/false
17:12 jberger because who knows if consumers will handle the shortcuts correctly
17:12 jberger especially given that \0 is actually truthy while Mojo::JSON::false is falsey
17:14 polettix well, I think that in the context of Test::Mojo that’s a bit long-reaching and being able to use the “shortcuts” might be easier. Anyway, I understand that they probably come from compatibility with other JSON libraries, so it’s OK to just drop this.
17:15 jberger right, I see the value of being able to use the shortcuts in tests as expected values, but it has to be a separate discussions
17:15 jberger s/s$//
17:17 polettix uhm, I started asking if this would be a nice to have or not, we might just get back there :-)
17:18 noganex joined #mojo
17:18 sh14 joined #mojo
17:19 jberger :D
17:20 jberger now, I could ALMOST imagine running the expected value through a json serialization round trip ...
17:20 jberger that would handle things like objects with TO_JSON and stringification and shortcuts
17:21 jberger but that would also be (a) a big change and (b) a lot of logic happening to your expected value, which usually should be very close to what you actually type in
17:22 jberger in that case imagine what happens if the round trip doesn't do what you expect, now your test is at best invalid and at worse possibly falsely negative
17:22 * jberger is basically thinking out loud here
17:25 polettix yep, that’s probably more trouble that this whole shortcut is worth
17:25 polettix especially when one might have complicated structures to test that might happen to have blessed stuff inside by chance/error and this might not get detected
17:29 sri yea, too much trouble
17:29 sri we've not even figured out the trim problem yet
17:34 Ralesk joined #mojo
17:45 sri think i'll release minion 6.0 tomorrow
17:45 sri if anyone has any more wishes for breaking changes, now is the time to ask
17:46 sri especially schema changing stuff, i'd like to limit those more in the future
17:47 sri Grinnz: btw. if you want to make a quick compatibility update without adding remote control yet, you can just add broadcast/receive methods that do nothing
17:47 sri (of Minion::Backend::SQLite)
17:49 sri and while i am interested in more stats, this requires much more thought imo https://github.com/kraih/minion/issues/42
17:54 laidback_01 joined #mojo
17:54 Grinnz i have an implementation https://github.com/Grinnz/Minion-Backend-SQLite/compare/worker_remote
17:55 sri oh
17:55 sri Grinnz++
19:15 jamesaxl joined #mojo
19:29 asarch joined #mojo
19:55 itaipu joined #mojo
20:06 arpadszasz joined #mojo
20:35 polettix joined #mojo
20:37 sri hmm, i don't know, maybe worker state information is different from stats
20:37 sri re https://github.com/kraih/minion/issues/42
20:38 sri not sure it is worth the cost
20:39 sri i mean, that column would definitely be json, and get updated every minute
20:46 polettix is there a quick/obvious way (or a plugin maybe?) that can be used to return 405 Method Not Allowed for all methods that are not defined over a resource?
20:47 Grinnz https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Rendering-exception-and-not_found-pages
20:47 Grinnz might help
20:47 bpmedley polettix : I'm confused.  What does "not defined over a resource" mean?
20:47 sri path matches, but not method
20:48 sri i don't think that information is actually available
20:48 polettix bpmedley: sorry for the bad wording, like I do DELETE /projects/5 but for /projects/:id there is no DELETE method with a route
20:48 sri since we short circuit very aggressively
20:49 sri ->get('/foo')->any('/bar')->to('bar#baz');
20:50 sri there is just no way to know for a "POST /foo/bar" request that the resource /foo/bar exists
20:50 sri since ->get('/foo') short circuits
20:53 sri i think implementing a Method Not Allowed feature would require a path matching only mode
20:53 sri it would have to ignore methods, conditions, and stuff
20:54 sri the api for that should actually already be public, but you'd have to do quite a bit of low level work
20:55 sri writing the plugin would prolly take me 2 hours, so it's a little bit tricky
20:57 polettix TIL prolly
21:10 sri it's pretty much a worst case for our router, because of how it has been optimized
21:14 polettix I am setting header “Allowed” in an OPTIONS call for resources, so I might “just” intercept the 404 as suggested by Grinnz, figure out how to internally resolve the current request path for OPTIONS instead and see if the specific method is allowed or not, then change the error code accordingly
21:15 sri there is actually no need to intercept the 404
21:15 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Catch-all-route
21:16 polettix I see
21:17 polettix anyway, my impression is that this would jeopardize pretty much all the work on the optimization, which would be ok only in a friendly environment I suppose
21:18 sri you could build it in a way that only the 404 case would be really slow
21:18 sri with a catch-all route and custom route treee walking code
21:18 polettix although it actually means transforming any unresolved request into an OPTIONS request, then figuring out whether it’s 404 or 405 accordingly
21:19 polettix the custom route tree walking code would leverage on the current route search stuff I suppose?
21:20 sri yea
21:20 polettix at this stage, it’s probably better to document this as a 404 instead of a 405, and suggest using OPTIONS to figure out which methods are actually allowed
21:21 sri if you wanted to make a generic plugin to put on cpan, i think that's how you would do it
21:21 sri bascially rip out only the patch walking code from https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Routes/Match.pm#L41
21:21 sri s/patch/path/
21:22 jberger it would be kinda cool to walk the route map and get out the entire router as a path tree
21:23 sri with placeholders there's no definitive path tree though
21:23 jberger duh
21:23 jberger yep
21:23 jberger ECONTEXTSWITCHEDTOOFAST
21:23 jberger I've used that exact reasoning for people wanting to automagically generate tests for all routes
21:24 sri :)
21:30 polettix the catchall suggestion actually makes me think that I can install multiple “catch-all-methods” just after the “real” methods are defined. I have to repeat it for every path I define, but it’s automated anyway so it can work.
21:37 polettix yay
21:38 jberger polettix: if you are doing large-scale automation of what sounds like a RESTFUL api
21:38 jberger should you be looking at OpenAPI (swagger2) or one of the RESTful plugins?
21:39 polettix jberger: yes, totally. I discovered it yesterday as a matter of fact (OpenAPI to be precise)
21:40 jberger I don't know if the Swagger2 plugin is officially deprecated yet (in favor of OpenAPI) but certainly new code should use the OpenAPI plugin
21:40 polettix but I still have a lot to study anyway, so reinventing a few wheels does not hurt at this stage (although they come out a little… squared)
21:41 jberger as to 404 vs 405, I can see why there is a draw to that (semantically it is more correct)
21:41 jberger but 404 isn't wrong either (no route can handle that request)
21:42 jberger and most consumers (even highly automated ones) wouldn't probably handle 404 vs 405 any differently
21:42 polettix well, 404 refers to the resource actually
21:42 polettix that’s right anyway
21:44 polettix but but… 404 might prompt for e.g. automatic creation of a resource (that is currently “Not Found”), while 405 says that you can’t do that kind of operation on the resource
21:45 polettix then of course with generalized routes like /foos/:id there is always a dilemma about what METHOD /foos/12 should return if /foos/12 does not exist (404) but METHOD would not be permitted anyway on it (405)
21:46 polettix I would still lean on the latter anyway, just to cut expectations
21:51 jberger you're right of course, and if you can generate the handlers for the methods you don't implement then yeah go ahead
21:51 jberger most people just don't because of the effort involved I think
21:52 jberger (and lack of real return on time for being that careful)
21:52 jberger but, that is the choice that each developer/project has to make for themselves
22:09 itaipu joined #mojo

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