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

IRC log for #mojo, 2016-12-20

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

All times shown according to UTC.

Time Nick Message
00:10 howitdo joined #mojo
00:16 q_gone joined #mojo
00:56 aborazmeh joined #mojo
01:00 jontaylor joined #mojo
01:22 marty_ joined #mojo
01:22 marty joined #mojo
01:35 dmanto joined #mojo
02:16 howitdo joined #mojo
02:19 stryx` joined #mojo
03:02 noganex_ joined #mojo
03:59 ajmrch joined #mojo
04:00 noganex joined #mojo
05:04 dboehmer joined #mojo
05:08 inokenty-w joined #mojo
05:34 howitdo joined #mojo
06:19 elik joined #mojo
06:24 rshadow joined #mojo
06:29 eseyman joined #mojo
06:48 Vandal15263 joined #mojo
07:14 parv joined #mojo
07:42 mbudde joined #mojo
07:44 dod joined #mojo
07:50 dod joined #mojo
08:25 trone joined #mojo
08:26 rshadow joined #mojo
08:28 schelcj joined #mojo
08:37 janl joined #mojo
08:39 good_news_everyon joined #mojo
08:39 good_news_everyon [mojo] kraih tagged v7.12 at cb4aa3b: https://git.io/v1bM1
08:39 good_news_everyon left #mojo
08:41 good_news_everyon joined #mojo
08:41 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1bMQ
08:41 good_news_everyon mojo/master e5a957d Sebastian Riedel: bump version
08:41 good_news_everyon left #mojo
08:41 AndrewIsh joined #mojo
09:23 Lee what's the accessor to get the SERVER_ADDR?
09:26 Jonis $req->env->{SERVER_ADDR} if it's from env
09:27 Lee ok, there's no public method to get at that?
09:28 Lee oh ignore me, i'm not well
09:35 osfabibisi joined #mojo
09:37 good_news_everyon joined #mojo
09:37 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1bQ3
09:37 good_news_everyon mojo/master 3d6b372 Sebastian Riedel: use the same style consistently
09:37 good_news_everyon left #mojo
09:58 dod joined #mojo
10:04 jontaylor joined #mojo
10:11 howitdo joined #mojo
10:13 polettix joined #mojo
10:53 henq joined #mojo
12:03 henq joined #mojo
12:08 dod joined #mojo
12:18 dod joined #mojo
12:30 dantti_laptop joined #mojo
12:39 a6502 hmm.. '(in cleanup) Can't call method "_unwatch" on an undefined value at ...perl5/Mojo/Pg/PubSub.pm line 32 during global destruction.' (perl 5.10.1 on rhel6)
12:39 a6502 is that worth a bug report?
12:48 sri does it cause problems?
12:49 sri otherwise no
12:49 sri 5.10.1 is only partially supported
12:50 a6502 not that i can see... but i haven't seen it do that before
12:59 stryx` joined #mojo
13:03 henq joined #mojo
13:22 rshadow joined #mojo
13:29 perlpilot joined #mojo
13:49 gryphon joined #mojo
14:04 mib_6497i1 joined #mojo
14:05 mib_6497i1 if I have a table I can get all the cells text via  ->find('td')->map(sub { $_->text })->to_array
14:05 mib_6497i1 how would I go about "all text in column N" ?
14:05 mib_6497i1 let's say second column
14:13 Pyritic joined #mojo
14:16 marty joined #mojo
14:17 mib_6497i1 td:nth-child(2) I guess, but ugh that's fragile...
14:20 sri ->at('table')->find('td')->[1]->text
14:22 sri ever since alexbyk attacked this channel i'm hesitant about helping anonymous visitors :S
14:23 mib_6497i1 but your solution gets only a single cell value, I want to get all of the texts in a specific column as an arrayref
14:24 mib_6497i1 my current code is $tablething->find("td:nth_child($column_number)"->map( sub { $_->text })->to_array
14:24 mib_6497i1 missed a ) but that's the idea
14:24 sri well, take it as inspiration
14:24 sri easy to adapt the idea
14:26 mib_6497i1 I suppose... $tablething->find("tr")->map(sub { $_->find('td')->[$col]->text })->to_array...
14:26 mib_6497i1 sri: ^^ is that essentially the best the API allows for?
14:37 marty joined #mojo
14:45 marty joined #mojo
14:50 asarch joined #mojo
15:10 henq joined #mojo
15:25 q_gone joined #mojo
15:54 sh14 joined #mojo
15:56 sri someone should look into this, i don't really have time https://groups.google.com/forum/#!topic/mojolicious/1AfTkanzct0
15:57 henq joined #mojo
16:31 kes joined #mojo
16:32 kes Hi. If there are two Content-Type/Content-Length headers. How should I process params in this case? Mojolicious does not see them...
16:32 kes http://paste.scsys.co.uk/540293
16:37 kes The content contains another content: http://paste.scsys.co.uk/540294
16:37 kes in this case
16:53 disputin joined #mojo
16:56 rshadow joined #mojo
16:59 sh14 joined #mojo
17:09 howitdo joined #mojo
17:16 howitdo joined #mojo
17:17 jberger kes: generally the answer would be to use http://mojolicious.org/perldoc/Mojo/Headers#every_header
17:17 jberger but that dump looks like you are getting some broken data
17:18 jberger (though I only looked briefly, and I could be wrong)
17:19 kes ok. Thank you. will look what is wrong with it and why.
17:24 disputin joined #mojo
17:31 marty joined #mojo
17:32 marty joined #mojo
17:42 PryMar56 joined #mojo
17:58 dmanto joined #mojo
18:01 dod joined #mojo
18:03 dmanto about the new subprocesses feature
18:03 dmanto is there a way to get the app inside the subs?
18:04 dmanto I mean I did't actually tryied
18:04 Grinnz you can just close over it
18:04 Grinnz the subs are just run in a forked process that has the same app state
18:04 Grinnz you won't be able to affect the application in the parent process of course
18:04 blonewolfs joined #mojo
18:05 dmanto but if in the calling ioloop I have for instance, a $app variable
18:06 dmanto can I access, for instance, the model part
18:06 dmanto like $app->files->all
18:06 dmanto well files is for MyApp::Model::Files I mean
18:06 Grinnz i don't see why not, but keep in mind if you make a database connection, it's going to make a new connection (if you're using something like DBIx::Connector or Mojo::Pg that is fork-aware)
18:07 Grinnz and if you're not, the existing handles will break
18:07 dmanto that will be veeeery nice
18:07 dmanto I will try that and let you know after
18:08 dmanto thanks
18:08 lluad joined #mojo
18:15 Grinnz i think i asked this before, but sri/jberger would you object to me releasing Mojolicious::Plugin::Subprocess? or maybe under a different name?
18:18 dmanto Grinnz it works very well
18:19 dmanto I mean I am just using $self->app->log
18:19 dmanto $self coming from the parent pid
18:20 dmanto mmm
18:20 dmanto $subprocess->pid should be the same as $$ right?
18:20 dmanto I am allway getting 0
18:21 dmanto $$ is fine, keeps taking different pids, guess it is ok
18:21 dmanto always
18:21 Grinnz it's set to the child pid in the parent process and 0 in the child process, it looks like
18:22 rshadow joined #mojo
18:22 dmanto yes but I don't think it is intentented that way
18:23 dmanto I mean you always can find your pid with $$
18:23 dmanto probably it is meant to use by the parent inside the parent part of the fork
18:25 disputin joined #mojo
18:26 tyldis joined #mojo
18:27 asarch joined #mojo
18:30 Grinnz yes
18:42 henq joined #mojo
19:20 Pyritic joined #mojo
19:27 kes is there a way to automatically extract param from application/json?
19:30 Grinnz kes: $c->req->json
19:31 kes no, to access them as: $c->param( 'xxx' )
19:32 Grinnz no, because $c->param accesses a Mojo::Parameters object which is strictly for urlencoded params
19:33 kes hm... I thought about it as parameters which come with request
19:33 kes I think I may use next workaround: around_action + params->merge( $c->req->json )
19:33 Grinnz how could that work? the json could be many levels deep, Mojo::Parameters is one level
19:34 kes so there will be error on validation
19:34 Grinnz you would just end up with parameter values of ARRAY(0xdeadbeef)
19:34 Grinnz and such
19:35 kes I just experiments. My controller do not distinguish what is this html or json
19:35 kes s/do not/would not/
19:36 Grinnz it doesn't make sense to access urlencoded params and json params the same way
19:37 kes But why controller should care if param is urlencoded or json?
19:37 kes it cares about param data
19:40 kes So if controller accepts 'application/json' it should get params usually
19:42 kes Actually 'application/x-www-form-urlencoded' is just hardcoded now
19:46 Grinnz kes: because the data is accessed differently
19:46 Grinnz $c->req->json->{foo} can be a hashref, but $c->param('foo') cannot
19:46 Grinnz $c->param('foo') may be a scalar even if there are multiple 'foo' variables but $c->req->json->{foo} will be an arrayref if it's an arrayref in json
19:47 rshadow joined #mojo
19:47 Grinnz s/may be/will be/
19:51 kes It is right limitation for Mojo::Parameters but for Mojolicious::Controller it should not. because controller is more high level in compare to Mojo::Parameters
19:52 kes But your note is useful. Thank you.
19:52 preaction what if the json body is an array?
19:52 kes validation just fails
19:53 preaction so, it's not allowed to do that?
19:53 kes yes
19:54 preaction and you want that to be the default mojolicious behavior?
19:54 kes params are key/value pairs, hash is key/value pairs. Array is not
19:55 kes no, but if be able to configure it will be good.
19:55 preaction right. but you want $c->param, when sent a json body, to contain the data in the json hash. and that only works if the json body is an object, not an array or any other kind of json thing. and that's not a good default
19:56 preaction you could make a helper that runs your json body through the validation and makes it show up as a param. you could do that as an under() or an event handler so that it happened for all your routes even
19:57 Grinnz the keys in a json object can also be any json type, including another json object, which will similarly not be handled by Mojo::Parameters
19:57 Grinnz s/keys/values/
20:01 kes maybe this other kind of parameters? it is controller parameters. And it should care somewhere. I do not know. I am experimenting and it seems handy when controller take data, process it and render. It has not matter is it urlencoded or json. Application take care based on Headers: Content-Type (how to parse input)/ Accepts (how to render)
20:02 Grinnz maybe you can add your own helper which accesses either urlencoded or json parameters based on the header
20:02 kes maybe, I do not know how it should be better
20:05 sri Grinnz: what do you mean with "the keys in a json object can also be any json type"?
20:05 Grinnz i meant values
20:06 sri ah
20:22 dmanto Grinnz: trying to access other helpers inside the subprocess, it works but I got errors after it returns
20:23 dmanto is the last sub {} mandatory?
20:24 dmanto http://mibpaste.com/mDAEVq
20:30 jberger kes: I agree with Grinnz, this seems like a perfect use-case for a helper
20:30 jberger dmanto: yes
20:30 jberger if you really want it "set and forget" then pass sub {}
20:32 kes http://paste.scsys.co.uk/540306
20:32 kes I implemeted this as hook for around_action:
20:32 kes seems works fine
20:39 dmanto jberger: ok
20:54 sri i can't imagine a case where you wouldn't want to look for errors in subprocesses at least
21:04 dmanto sri: well if you have the full app inside, you can just log errors to review them later
21:04 dmanto but anyway I agree, normally you need some kind of feedback
21:05 sri dmanto: doesn't capture exit status if stuff goes really wrong
21:07 dmanto yes probably that happened in my case. Could you see the pastebin with the error?
21:08 dmanto ahh sorry, thay could have been due to the lack of the last sub {}   :(
21:09 dmanto I will retry with it
21:11 howitdo joined #mojo
21:28 sri hehe, people are still surprised when i say perl 6 is a disappointment
21:34 sri that reminds me
21:34 sri i think Mojo::UserAgent could use a few more features for consuming web apis
21:35 sri https://github.com/openSUSE/build-check-statistics/blob/master/lib/SUSE/BuildCheckStatistics/Updater.pm#L86-L94
21:35 sri that pattern is way verbose
21:35 * sri pokes jberger
21:35 sri maybe you got an idea?
21:35 gryphon joined #mojo
21:35 sri i mean, the primitives are not terrible, they get the job done
21:36 sri but there has to be a more elegant way for dealing with connection errors and different response codes/code classes
21:37 sri i've just written the same thing again for another app
21:38 sri thinking maybe something like respond_to for response statuses, and it dies for connection errors
21:38 sri is there prior art in other languages?
21:43 dmanto sri, jberger:fyi retrying with the last sub {} works fine
21:45 jberger sri: I agree that I would like something better
21:45 jberger I usually end up with a section of code like that
21:46 jberger jquery has options that handle different status codes
21:47 jberger http://api.jquery.com/jQuery.ajax/ search statusCode
21:47 sri not particularly appealing
21:48 jberger I'd suggest that if we did something like that it would include fallbacks for unhandled codes and non-code errors
21:48 jberger but yeah
21:49 jberger I'm not saying that that is great, just that its prior art
21:49 sri the first question is what the use cases actually are
21:50 sri i usually want a) to die on connection errors, b) die on a certain status code, c) run some additional code on certain status codes, d) get an undef return value for anything else than 200
21:53 sri now that i think about it, seems odd there's no version of $tx->success that dies on connection errors
21:54 sri if you didn't have to mess with $err->{code} and $err->{message} things would already get cleaner
21:57 sri yea, i don't think we'll find a perfect solution
21:57 sri a more granular approach seems better
21:57 sri variations of $tx->success
21:58 sri if/else blocks on $tx->res->code don't look too bad if you need them, the other stuff is what makes it odd
22:01 Grinnz ->connection_succeeded or something?
22:01 Grinnz bit verbose
22:02 sri along the lines
22:02 sri nicer names of course ;p
22:02 jberger I'd be happy to see something like that
22:02 Grinnz a better api for that would be nice
22:10 polettix joined #mojo
22:10 sri actually two variants i guess
22:10 good_news_everyon joined #mojo
22:10 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1AaF
22:10 good_news_everyon mojo/master 1a19e9d Sebastian Riedel: be a little more specific
22:10 good_news_everyon left #mojo
22:11 sri i want a method that dies on connection errors or returns $tx->res for everything else (even 4xx/5xx), and one that behaves like $tx->success but dies on conenction errors
22:12 sri finding names is hard though
22:13 PopeFelix joined #mojo
22:15 sri you better propose something before i pick something silly like $tx->failed_maybe
22:15 sri :D
22:16 sri guess $tx->maybe_failure would be more fitting
22:17 sri $tx->successful_exchange would be appropriate, but verbose
22:18 sri perhaps more pragmatic
22:18 sri $tx->result
22:21 sri i like that one actually
22:22 sri if would only die on connection errors, and return $tx->res for everything else
22:22 sri now, it would need more variations
22:22 sri a) returns undef for 4xx/5xx
22:23 jberger could it take an argument
22:23 rshadow joined #mojo
22:23 sri thought about that too, but it would prolly turn into a jungle of flags
22:23 jontaylor joined #mojo
22:24 sri $tx->result({client_errors => 0, server_errors => 0})
22:24 jberger boolean/scalar for "die on 4xx/5xx"
22:24 jberger or maybe an arrayref of "success" codes
22:24 sri see, that's another problem :)
22:24 jberger I'm just spitballing
22:24 sri die on 4xx seems kinda wrong
22:25 jberger right, I like your default
22:25 sri die on connection error and 5xx is more standard
22:25 jberger "i want a method that dies on connection errors or returns $tx->res for everything else (even 4xx/5xx)"
22:25 sri also been thinking about just adding more test methods to Mojo::Message::Response
22:26 sri $res->is_error/is_success/is_client_error/is_server_error/is_redirect
22:26 jberger that sounds reasonable in any case
22:26 jberger is_connection_error
22:27 sri the current $res->is_status_class() can't really provide the $res->is_error for example
22:27 sri since it has to cover 4xx and 5xx
22:28 sri not sure if is_status_class would be deprecated then
22:28 jberger is status class could take multiple classes
22:29 jberger $res->is_status_class(400, 500)
22:29 sri hmm, guess that would work too
22:30 jberger crazy idea, negative number to check for connection errors?
22:30 jberger $res->is_status_class(500, -1);
22:31 sri ewww
22:31 sri you never know when to stop ;p
22:32 jberger I throw out ideas, you beat them up until we find one
22:32 jberger it would at least give you a comprehensive/expressive check using an existing interface
22:33 * jberger remembers the greate "splice" change for $delay->begin
22:33 jberger s/greate/great/
22:37 good_news_everyon joined #mojo
22:37 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1AKh
22:37 good_news_everyon mojo/master 3d81cd1 Sebastian Riedel: improve is_status_class method in Mojo::Message::Response to be able to check for multiple classes at once
22:37 good_news_everyon left #mojo
22:44 sri hmm, not sure about this
22:45 sri is that really better than more specific methods?
22:45 sri $res->is_error vs $res->is_status_class(400, 500)
22:45 sri it feels wrong
22:46 jberger no idea
22:47 Grinnz might be slightly more convenient if you want to check something like (200, 300, 400)
22:47 jberger nice thing is that it is the same interface as before
22:47 Grinnz but i could see just using ->is_* methods too
22:47 * jberger commutes, biab
22:47 sri i would totally use ->is_error
23:01 good_news_everyon joined #mojo
23:01 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1AX5
23:01 good_news_everyon mojo/master 1343373 Sebastian Riedel: add a few new methods to Mojo::Message::Response
23:01 good_news_everyon left #mojo
23:01 sri having is_status_class too feels odd, but we need the code anyway :S
23:02 sri might still deprecate it though and hide the code
23:05 good_news_everyon joined #mojo
23:05 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1A14
23:05 good_news_everyon mojo/master 7810737 Sebastian Riedel: use the new methods
23:05 good_news_everyon left #mojo
23:16 howitdo joined #mojo
23:18 good_news_everyon joined #mojo
23:18 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/367ff24b82ae906c47be405487af852948a50208
23:18 good_news_everyon mojo/master 367ff24 Sebastian Riedel: deprecated Mojo::Message::Response::is_status_class
23:18 good_news_everyon left #mojo
23:28 marty_ joined #mojo
23:29 marty joined #mojo
23:34 jberger If the code is there why not make it available? If only to avoid a deprecation
23:38 good_news_everyon joined #mojo
23:38 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1ASM
23:38 good_news_everyon mojo/master 97f16ad Sebastian Riedel: add result method to Mojo::Transaction
23:38 good_news_everyon left #mojo
23:38 sri jberger: that doesn't seem reason enough to me
23:39 sri new Mojo::UserAgent synopsis example https://github.com/kraih/mojo/commit/97f16adbc5e93448d3e4fd8a16db264aedee58ff#diff-955b07afef3c0b8632a50118b370262cR345
23:39 sri that's what i had in mind
23:41 sri i'm open for suggestions with better names for $tx->result
23:43 sri i see possibilities for confusion between ->res and ->result
23:44 sri maybe that's even a plus
23:47 good_news_everyon joined #mojo
23:47 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/1f3db645216959e92d989c7b259f1b1a00706a26
23:47 good_news_everyon mojo/master 1f3db64 Sebastian Riedel: slightly more consistent descriptions
23:47 good_news_everyon left #mojo
23:52 jberger I'd be perfectly happy to document it as "lower level" as we have done elsewhere
23:53 jberger I understand deprecating/removing code when it reduces maintenance burden on us, but we still have the code
23:54 jberger Users will have to port away from a method that still exists internally and that makes me a little sad
23:55 jberger Officially I'll say I'm +1 on most of these changes and -1 on the deprecating of is_status_class and let the vote decide

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