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

IRC log for #mojo, 2015-07-05

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

All times shown according to UTC.

Time Nick Message
01:18 Onigiri joined #mojo
02:21 noganex_ joined #mojo
02:32 bpmedley joined #mojo
03:08 dotandimet joined #mojo
04:12 absolut_todd joined #mojo
04:24 kaare joined #mojo
04:42 irqq joined #mojo
05:57 dotandimet joined #mojo
06:10 nnutter joined #mojo
07:01 bpmedley joined #mojo
07:44 trone joined #mojo
08:25 Vandal joined #mojo
08:26 berov joined #mojo
08:32 melo joined #mojo
10:55 zivester joined #mojo
10:57 Vandal joined #mojo
11:21 sh4 joined #mojo
11:59 berov batman: could you reply to my yesterday question?  Thanks! http://irclog.perlgeek.de/mojo/2015-07-04#i_10850034
12:00 berov or anyone who is familiar with Swagger2?
12:48 ToApolytoXaos joined #mojo
13:05 dod joined #mojo
13:10 dod joined #mojo
13:49 dod joined #mojo
13:52 nic joined #mojo
13:58 nic It was on the 186th day of 2015 that the last two survivors on #mojo realised everyone else had melted
13:58 mib_sdpew8 joined #mojo
13:58 nic They climbed out of the freezer in which they'd taken shelter
13:58 nic looked at each other
13:58 nic grabbed sun hats
13:59 nic and headed to the park with a frizbee
14:01 nic Then the first one (whom archaeologists believe was called 'nic') popped back indoors and left a note
14:02 nic "If there are any more survivors, I have a problem at https://gist.github.com/niczero/53402280f9674caeff10"
14:03 nic "My condition must be wrong because I can't get a Plan C to fire for users who fail the condition"
14:03 nic "And there are still some icecreams in the freezer"
14:04 CandyAngel ... what
14:04 purl Unimplemented. or see dotdotdot
14:06 pink_mist why are you doing full-app semantics in a ::Lite-app?
14:09 nic cos lite apps have some extra convenience I needed to step around
14:10 nic Either I've misunderstood how conditions work, or I've misunderstood how to implement them, or I've misunderstood my misunderstandings
14:11 nic I _thought_ that a condition should just return true or false
14:11 nic and if a req got false on a condition, it would then keep looking for a route it could satisfy
14:11 nic But in that example, it doesn't keep looking
14:12 nic It gets stuck inside the condition, glumly staring at 'undef', till it reaches timeout
14:16 hesco joined #mojo
14:17 * sri doesn't see a condition
14:17 nic oh
14:17 nic sri: Isn't under(sub ..) a condition?
14:18 sri wat? no!
14:18 nic bah, so it must be reading fail
14:18 nic k, I'll go read again
14:18 nic thanks
14:18 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Conditions
14:19 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Adding-conditions
14:19 sri how?
14:21 nic What do you call the thing that 'under' does when given a sub?
14:22 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Under
14:22 ajr_ joined #mojo
14:24 nic ok, so 'under' is just code sharing, and 'over' is condition application
14:25 nic checking conditions is often in shared code, but I'd been over-fixated on 'under' :)
14:25 gryphon joined #mojo
14:27 nic So 'under' makes sense for authentication, where it's success or death by burning
14:27 nic but if you want to check more routes you need 'over', hence not being able to have cache
14:28 bpmedley nic: May I ask what you're trying to accomplish from a high level?
14:29 bpmedley My AC is out, so I"m melting.. ;)
14:30 nic bpmedley: I need to catch cases where the user didn't get to their requested route
14:30 bpmedley A default route, perhaps?
14:30 nic because there may be a secondary (slower) way of serving what they want
14:30 nic perhaps
14:31 nic The idea is to default to the fast way in the routing
14:32 nic but catch any fall-thru and then check the slow way
14:32 bpmedley http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Catch-all-route
14:33 nic bpmedley: did you see my example?
14:33 bpmedley Yes.  I'm confused why your routes have no "/" in them.
14:33 nic and you see the last two routes?
14:36 bpmedley Yes; I can't seem to get your example to work.  When I try to access "/" or "/abc", I get a not_found exception.
14:37 nic try /abc/xyz
14:38 nic actually, just look at the test file ;)
14:54 bpmedley It appears that you have two catch all routes defined at the end of your app.
14:59 bpmedley nic: https://bitbucket.org/snippets/bpmedley/jkdr7  <-- Does this work for you?
15:28 PryMar56 joined #mojo
15:47 Kogurr joined #mojo
15:59 melo joined #mojo
16:00 dvinciguerra joined #mojo
16:09 irqq joined #mojo
16:31 till joined #mojo
16:33 till hi, why does this code generates the error "Can't load application from file "test.pl": No such file or directory at (eval 43) line 1."?
16:33 till use Mojolicious::Lite;
16:33 till app->start;
16:33 till my $n;
16:35 till when started with morbo
16:46 absolut_todd joined #mojo
17:03 PryMar56 joined #mojo
17:22 bpmedley till:  Will you create a pastie?
17:27 mst till: http://paste.scsys.co.uk/mojo
17:29 * pink_mist doesn't see the point -- he already provided three lines of code which is all that's needed to reproduce
17:30 pink_mist it's that my $n after the app->start that screws you over
17:30 pink_mist that's pretty much useless
17:31 pink_mist you should putt app->start at the very end of your code.
17:31 pink_mist *put
17:33 sri there should be more wrong, that case would get a different error
17:34 till ok thanks I just wondered about the confusing error message
17:35 pink_mist sri: http://p.0au.de/301f5e0c
17:36 sri pink_mist: i know, it shouldn't be like that
17:36 sri the app->start has a strange effect
17:39 sri this is the line that makes it happen btw. https://github.com/kraih/mojo/blob/master/lib/Mojo/Server.pm#L54
17:39 sri but i doubt anyone really cares
17:39 sri sooo.... whatever
17:39 mst I care slightly.
17:39 * mst plays the world's second smallest violin
17:40 bpmedley till: I'd love to see a pastie.
17:40 sri bpmedley: pay attention
17:40 mst bpmedley: we already solved it
17:40 bpmedley till didn't say anything
17:41 mst because pink_mist already reproduced
17:41 mst and sri traced it through the codew
17:41 bpmedley till: Is your code working now?
17:42 till yes thanks. I was just wondering about the message "No such file or directory"
17:43 mst because $@ isn't set, and $! happens to be
17:43 mst though $@ isn't set because the file didn't return a true value
17:43 bpmedley nic: Did you get your code working?
17:44 pink_mist *$@ is only checked because the file didn't return a true value
17:45 sri that makes sense
17:45 mst pink_mist: what?
17:45 pink_mist whether the file returns a true value or not doesn't /set/ $@ ... it only determines wether or not $@ (and $!) are checked
17:46 till can't mojo append a "1;" to the code automatically?
17:46 mst no.
17:47 mst sri: I wonder if 'local $!' and then ($@ || $! || 'file did not return a true value')
17:47 melo1 joined #mojo
17:47 sri i suspect $! is set inside the app
17:47 sri for some unrelated file check somewhere in the mojolicious code
17:49 sri actually, i'm not entirely sure we care about $! anyway
17:49 mst oh, hrm. at which point, how the smeg do you tell the difference between "file returned false" and "file failed"
17:50 sri the two die statements below might be entirely sufficient
17:50 mst I have memories that in such cases I always end up using require
17:50 sri plack actually uses the same idiom https://metacpan.org/source/MIYAGAWA/Plack-1.0037/lib/Plack/Util.pm#L123
17:50 sri hmm
17:52 sri there's exactly one affected test, and that one is new-ish
17:53 sri https://gist.github.com/anonymous/2a1bd699f84c83a70173
17:54 sri that would result in "File "$path" did not return an application object." for most cases
17:55 pink_mist looks sane to me
17:57 sri but actually it's not
17:57 sri the file used in the test contains a syntax error
17:57 sri that should result in a different error :S
18:02 sri perldoc -f do specifically mentions $!
18:02 sri so, both need to be checked
18:03 * mst still thinks require is a better approach
18:08 nnutter joined #mojo
18:12 sri well, i can't think of a better idiom
18:12 sri maybe jberger will look into it when he's back, that stuff usually interests him
18:13 mst delete $INC{$file}; my $app; eval { $app = require $file; };
18:25 sri results to look better
18:25 sri stumbled over something else now though while trying to add more test
18:25 sri s
18:25 sri the test we have can't run twice
18:26 sri FindBin->again fails for some reason
18:27 cpan_mojo Perl-Box-0.04 by FIBO https://metacpan.org/release/FIBO/Perl-Box-0.04
18:33 good_news_everyon joined #mojo
18:33 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vqsza
18:33 good_news_everyon mojo/master be44060 Sebastian Riedel: use a different idiom for application loading
18:33 good_news_everyon left #mojo
18:34 sri can't figure out the test problem though :(
18:36 sri https://gist.github.com/anonymous/8b86cf4b9db554ad9d65
18:36 sri if that test gets added, the old one fails
18:36 sri with "Cannot find current script '' at /Users/sri/repo/mojo/lib/Mojo/Server.pm line 48."
18:36 sri there's an "Use of uninitialized value $0 in scalar assignment at /Users/sri/repo/mojo/lib/Mojo/Server.pm line 46, <DATA> line 2231." too
18:37 sri so i suspect abs_path is having trouble
18:41 sri yea, it is in fact abs_path failing
18:42 sri it's the same with do and require btw.
18:45 mst yeah, the advantage of require was more "will always put the error in $@ thereby avoiding the original confusion" than anything else
18:49 melo joined #mojo
18:58 dod joined #mojo
19:01 batman berov: if the validation fail, the request will never hit the controller action
19:02 batman berov: i've been moving, so i wasn't around to answer your questions
19:02 absolut_todd joined #mojo
19:03 batman berov: i tried to describe it here: https://metacpan.org/pod/Mojolicious::Plugin::Swagger2#render_swagger
19:03 berov ok, thanks... just to make sure... for example I have in my operationId method the $c->$cb...
19:04 batman and here's an example controller/action: https://metacpan.org/pod/Mojolicious::Plugin::Swagger2#Controller
19:04 berov but wher to put my code which actually updates/creates/whatever in the database
19:04 PryMar56 joined #mojo
19:04 batman you put it inside the action (a method in the controller)
19:04 batman are your sure you read https://metacpan.org/pod/Mojolicious::Plugin::Swagger2#SYNOPSIS ?
19:04 aggrolite joined #mojo
19:05 batman if so, please let me know what you don't understand so i can improve the documentation at the same time
19:05 berov let me find the update example
19:07 berov https://metacpan.org/source/JHTHORSEN/Swagger2-0.35/t/Api.pm
19:07 berov her we have some examples
19:07 berov but where to put my actual code
19:07 berov in the actions
19:07 berov before oor after $cb(...)
19:08 berov for example add_pet https://metacpan.org/source/JHTHORSEN/Swagger2-0.35/t/Api.pm#L38
19:08 berov I will have some business logic
19:09 berov or adding to a database or something
19:09 batman that's no different than a regular mojo action.
19:10 berov can $cb be thought out as a render()
19:10 batman does this make more sense? https://ssl.thorsen.pm/paste/9f2d99233ef6
19:10 batman yes
19:11 batman it's what the documentation says "The callback should be called with a HTTP status code, and a data structure which will be validated and serialized back to the user agent"
19:11 berov ah and since the action will not be called if there are validation errors then
19:12 berov well "structure which will be validated"
19:12 berov will be validated against what?
19:12 batman the swagger spec
19:12 berov ahaaa, ok
19:13 berov thanks a lot
19:13 batman it's the whole point with swagger: you define your input/output rules.
19:14 berov a tutorial will worth it. But Let me play a little and will suggest a patch
19:15 berov how about lib/Swagger2/Tutorial.pod ?
19:15 batman not sure. just extend the SYNOPSIS and make it understandable.
19:15 berov this will give aboost to the usage
19:15 berov ok
19:16 batman it's not a swagger2 tutorial, so naming it swagger2::Tutorial would be wrong.
19:16 batman it's related to the mojolicious plugin. not the main module... i could be wrong of course :)
19:17 berov It is how to use Swagger2 with Mojo
19:17 mst Mojolicious::Plugin::Swagger::Tutorial maybe?
19:17 berov ok
19:17 mst calling it just Swagger2::Tutorial wouldn't make sense
19:17 berov ok agree there is also Resin afaik which implements Swagger2 too
19:19 berov ok let me do a finished CRUD Controller and will write the tutorial then  feedback will be wellcome
19:23 batman "Resin" ?
19:26 batman i appreciate any contribution berov :)
19:26 berov sure
19:26 berov http://swagger.io/open-source-integrations/
19:26 berov Raisin
19:27 batman i might not agree on the wording, but the any feedback will result in a different wording which is awesome :)
19:27 berov I think we should add Swagger2 to this list
19:27 batman ah. indeed.
19:27 berov yes
19:27 batman i thought i had a pr for that... maybe i remember wrong :P
19:28 bpmedley Anyone got RPerl to work?
19:29 pink_mist what's RPerl?
19:29 purl RPerl is directly related to Perl 5 core development.
19:29 pink_mist .... ok
19:29 bpmedley http://rperl.org/faq.html#faq_how
19:29 pink_mist that doesn't help purl =(
19:30 pink_mist ok, that seems nifty bpmedley
19:31 batman berov: maybe a blog post should be written. i would link from the documentation to the post.
19:31 mst it's an interesting idea in theory though I think he's still using his own parser rather than the PPI or B based approaches I suggested
19:31 berov batman: ok
19:31 mst on the upside, at least I managed to beat his Makefile.PL stuff into something approximating sanity ;)
19:33 berov rperl claims are so seductive :)
19:33 mst for computation heavy stuff, it may be a useful thing
19:33 bpmedley I can't get all the tests to pass on 5.20.2 and OS X 10.10.4...
20:04 trone joined #mojo
20:09 good_news_everyon joined #mojo
20:09 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vqsHX
20:09 good_news_everyon mojo/master 043bcaa Sebastian Riedel: more application loading tests
20:09 good_news_everyon left #mojo
20:42 PryMar56 joined #mojo
20:49 punter joined #mojo
22:55 davido__ joined #mojo
23:04 stephen joined #mojo
23:41 d4rkie joined #mojo
23:52 d4rkie joined #mojo

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