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

IRC log for #mojo, 2016-12-21

| 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:27 * sri thinks the new fine grained response handling example fits well in there http://mojolicious.org/perldoc/Mojo/UserAgent#SYNOPSIS
00:33 jberger indeed
01:00 jontaylor joined #mojo
01:31 aborazmeh joined #mojo
01:51 asarch joined #mojo
01:54 dantti_laptop|2 joined #mojo
03:34 jabberwok joined #mojo
03:36 q_gone joined #mojo
03:58 noganex_ joined #mojo
05:04 dboehmer_ joined #mojo
05:13 inokenty-w joined #mojo
05:35 howitdo joined #mojo
06:04 polettix joined #mojo
06:34 Grinnz https://github.com/Grinnz/Mojolicious-Plugin-Subprocess still gotta come up with some tests, but pretty simple
06:36 Grinnz also bummed that line about inactivity_timeout from the ForkCall plugin :P
06:38 rshadow joined #mojo
07:03 Vandal15263 joined #mojo
07:35 mbudde joined #mojo
08:00 dod joined #mojo
08:07 dod joined #mojo
08:14 AndrewIsh joined #mojo
08:16 howitdo joined #mojo
08:24 trone joined #mojo
08:37 sri Grinnz: seems unlikely we'd want that plugin namespace for core
08:38 sri we'd just add the subprocess helper to DefaultHelpers
08:54 rshadow joined #mojo
09:18 trone joined #mojo
09:22 ashimema_ I came across that subprocess stuff yesterday and it sounded interesting
09:23 ashimema_ couldn't work out what the difference between it and ForkCall was.. so sounds interesteing that you've bumped a line?
09:34 henq joined #mojo
09:40 henq goodmorning, I need to process all form field values, in order to do that i put them into a hash like this:
09:40 henq my %form_fields = ();
09:40 henq foreach (qw/foo bar foz/) { $form_fields{$_} = $c->req->body_params->param($_)};
09:41 Lee henq: http://mojolicious.org/perldoc/Mojo/Parameters#to_hash
09:41 henq Am I overlooking an easier way? (Now I have to maintain the list of fields)
09:41 henq UGH
09:41 henq thankx @Lee
09:42 Lee np
09:42 henq You know what “normalize” is here?
09:43 Lee i guess it's when you have more than one param with the same name
09:43 henq Also, I assume it’s a has of all params, not just the ‘body’ params, right? Still have to slice those out, I’d guess.
09:43 henq hash
09:43 osfabibisi joined #mojo
09:44 henq okay, I see it now, thx again.
09:53 parv joined #mojo
10:09 sri ->body_params->to_hash
10:10 polettix joined #mojo
10:14 gregf_ joined #mojo
10:21 rshadow joined #mojo
10:40 dod joined #mojo
11:10 dotan_convos joined #mojo
11:21 polettix joined #mojo
11:22 rshadow joined #mojo
11:22 tyldis Sooo... Moose and Mojo. Or simply Moose vs Moo vs use Mojo::Base -base;
11:23 tyldis What are the pros/cons.. Recommendations?
11:24 tyldis No expert in either.
11:25 tyldis Right now I got a small legacy Moose model I'm trying to utilized inside Mojo, but as I try to instantiate it with some helpers from the mojo app I sometimes get those undef'ed. Totally random.
11:26 tyldis The models are small enough that I can rewrite them in anything. They will be used outside the Mojo apps.
11:27 tyldis So I need some guidance from someone who knows their stuff better than me.
11:29 tyldis Didn't find too much on the topic, but did find this: http://stackoverflow.com/questions/30804829/do-mojolicious-and-moose-play-well-together
11:29 sri pick the one you need
11:30 sri they all work
11:30 sri just have different features
11:30 sri personally, i use all three
11:31 tyldis Ah, great. ;)
11:32 tyldis So we are creating small microservice-ish APIs. And they need a model geared towards their tiny domain. These are pure mojo. The next layer would consume these APIs and will be a mix of mojo apps and standaole scripts.
11:35 tyldis The problem I am having right now is unpredictable behaviour when creating Moose object with ->new and passing ( db => shift->db) from the mojo controller. For some reason it's randomly not set.
11:36 tyldis I don't understand why. The alternative aproach would be to create the models as helpers, and that's my next aproach
11:37 tyldis Inspired by the Mojo::Pg example
11:49 tyldis That worked consistently. If I get the time to it I must use a debugger on the old code. That randomness was completly bonkers (though most likely user error than anything else)
11:50 tyldis The Blog example from Mojo::Pg is good
12:05 sri marcus, tempire, batman, crab: please take a look at the changes from yesterday
12:06 marcus sri: ack
12:06 marcus sri: the $tx->result stuff?
12:06 sri https://github.com/kraih/mojo/compare/v7.12...master
12:06 sri yea, the goals have been explained in great detail on irc yesterday
12:07 sri started here https://irclog.perlgeek.de/mojo/2016-12-20#i_13775307
12:07 marcus yeah, I've read some of the backlog on it.
12:08 sri i really like how this stuff looks now https://github.com/kraih/mojo/blob/master/lib/Mojo/UserAgent.pm#L345-L350
12:08 sri just wondering if there are maybe things we could do even better
12:08 marcus I like the goal.
12:09 sri having to check for connection errors manually was the worst problem
12:09 sri imo
12:09 howitdo joined #mojo
12:09 batman sri: looking
12:09 batman is this change message correct? "Deprecated Mojo::Message::Response in favor of new is_* methods"
12:11 sri that's not the message
12:12 batman https://github.com/kraih/mojo/blob/master/Changes#L3 ?
12:13 sri oops
12:16 sri this stuff will make my SUSE apps a lot more pleasant to read
12:16 good_news_everyon joined #mojo
12:16 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/65eab8882eb3956acdd6b9724da4ba8b763284d8
12:16 good_news_everyon mojo/master 65eab88 Sebastian Riedel: fix a few typos
12:16 good_news_everyon left #mojo
12:18 batman <3 https://github.com/kraih/mojo/compare/v7.12...master#diff-043e2f66961405ddba094f929f80edc0R47
12:18 batman loving it
12:18 purl YESSIR APPLYING SOME HOT LOVIN' RIGHT NOW SIR
12:20 batman Think maybe $tx->res and $tx->result is a bit confusing... will see if i can come up with an alternative
12:21 batman sri: why did you change the description here? https://github.com/kraih/mojo/compare/v7.12...master#diff-043e2f66961405ddba094f929f80edc0R203
12:21 batman you can still use $tx->error to check for connection errors..?
12:22 sri yes, just made the description consistent with others
12:22 batman cool.
12:23 sri $tx->success also works just the same
12:23 sri i'm not very attached to the name $tx->result, but it's the least worst name i could find
12:24 rshadow joined #mojo
12:24 sri i guess one could also say $tx->success is misleading, since it doesn't actually check for "success", which would be a 2xx response code
12:25 sri $tx->res->is_success is more correct
12:25 sri naming things is hard
12:25 sri ¯\_(ツ)_/¯
12:28 batman i guess it would require a major version bump to steal $tx->success() ?
12:28 batman as in, adding the croak() to success()=
13:26 batman What about res_or_die() ?
13:27 batman res_or_throw() ? Could use Mojo::Exception :)
13:40 gizmomathboy joined #mojo
13:47 vinnix joined #mojo
13:57 sri batman: that does not look nice
13:58 sri hahaha, i guess $tx->maybe_res would be kinda consistent ;p
14:10 marcus maybe_consistent
14:11 marcus schroedingers_res
14:20 gryphon joined #mojo
14:22 Pyritic joined #mojo
14:32 sri we used to be better at naming things
14:32 jberger We used to be naming easy things
14:33 sri *cough* delay *cough*
14:34 sri *cough* transactor *cough*
14:34 jberger Hehe
14:34 sri i can go on!
14:35 sri or my recent masterpiece http://mojolicious.org/perldoc/Mojo/Server/Daemon#close_idle_connections
14:36 sri acceptor just a few lines below is nice too
14:36 jberger connected?
14:36 purl connected is probably better...
14:36 jberger Awww thanks purl
14:36 sri connected is much earlier
14:36 sri we're past a successful exchange
14:37 jberger Yeah, that's true
14:37 sri and we want the result of the exchange
14:37 sri ;p
14:37 jberger I was thinking from a sense of "did connect" but yeah, you're right
14:38 jberger Honestly I'm OK with result
14:38 jberger You got a result
14:38 sri YOU GET A RESULT AND YOU GET A RESULT AND YOU GET A RESULT AND YOU GET A RESULT AND YOU GET A RESULT...
14:39 sri https://imgflip.com/s/meme/Oprah-You-Get-A.jpg
14:39 jberger EVERYBODY GETS A ...... ALL GLORY TO THE HYPNOTOAD
14:40 jberger Related:  http://beesbeesbees.com
14:42 meredith joined #mojo
14:50 jberger purl: bees?
14:50 purl You never can tell with bees. or http://forums.somethingawful.com/showthread.php?s=&amp;threadid=2243176
14:50 jberger purl bees is also http://beesbeesbees.com
14:50 purl okay, jberger.
14:56 dboehmer_ did anyone already take a look at https://github.com/kraih/mojo/issues/1023 ?
15:19 polettix joined #mojo
15:23 henq joined #mojo
15:27 perlpilot_ joined #mojo
15:28 asarch joined #mojo
15:37 sh14 joined #mojo
15:44 disputin joined #mojo
15:47 dod joined #mojo
15:56 kes joined #mojo
15:58 kes Hi. Can not understand what is the difference between: $next->() VS $c->$action(). Where may I read about that?
15:58 lluad joined #mojo
15:59 pink_mist kes: $next->() calls the subroutine reference stored in $next, and $c->$action() calls the method on $c with the same name as is in $action
15:59 pink_mist they have very little to do with eachother
16:00 kes will call $action break chain?
16:00 pink_mist huh?
16:00 purl huh are you talking about sqlfiddle.com ?
16:00 pink_mist also, this has very little to do with mojo
16:00 pink_mist just general perl
16:01 blonewolfs joined #mojo
16:02 bwf joined #mojo
16:17 tyldis ARGH! My dear colleague was passing the controller as argument inside the model. No wonder things were funky.
16:19 tyldis Hurts on so many levels.
16:33 jberger purl forget huh
16:33 purl jberger: I forgot huh
16:58 jabberwok when the model needs configuration stuff that's inside the controller, what _is_ the "right" way to access it? does the controller need to know all the gritty model implementation details and pass every little thing the model might need on every request? i know "everything is global" is outmoded but this is where i get confused
17:10 howitdo joined #mojo
17:14 sri this is how you abstract it https://github.com/kraih/mojo-pg/tree/master/examples/blog
17:15 sri if you pass a conroller to the model, you're wrong
17:18 jabberwok =nod= So, for example, passing all the config stuff (and database objects) when instantiating the model.
17:20 jabberwok I'm still pondering how to autogenerate documentation that helps with "What you want is a thing inside a thing inside the request inside the transaction inside the controller" puzzles
18:01 PryMar56 joined #mojo
18:03 chandwki joined #mojo
18:08 kes http://paste.scsys.co.uk/540321
18:08 kes Is this OK that endpoint has value after find failed?
18:11 rshadow joined #mojo
18:17 go|dfish joined #mojo
18:18 dikim joined #mojo
18:19 dikim Hi, is there a way to play with perl like rackup on ruby?
18:31 jberger dikim: can you describe what that is?
18:33 jberger is it just starting up an in-place application server?
18:33 dikim jberger: I am not an actual user of rackup but I have seen people using rackup to run a web server + his/her web application at the same time.
18:33 dikim Yes, that is right.
18:34 jberger if you are using mojo (as I would assume in this channel) then http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Commands
18:34 jberger have you read the guides?
18:34 jberger if not, I highly suggest that you do
18:34 dikim Sorry, I have not. Thanks for the pointer. :-)
18:34 jberger Here's the suggested order: http://mojolicious.org/perldoc#TUTORIAL
18:35 jberger s'ok
18:35 jberger read it carefully, it is densely packed
18:35 jberger most readers skim the first time, they end up needing a second time :-P
18:37 dikim Maybe, I’d better be patient.  BTW, any youtube or more visual instructions available. I will google it.
18:37 jberger there are the mojocasts
18:37 jberger but they are getting a bit old
18:37 jberger http://mojocasts.com/e1
18:38 dikim thanks. jberger
18:38 jberger there's an errata here someplace
18:39 jberger dikim: https://github.com/kraih/mojo/wiki#screencasts
18:39 dikim Thanks. jberger
18:39 jberger cheers!
18:42 dod joined #mojo
18:49 Pyritic joined #mojo
18:59 sri wow, that's mojolicious 1.53 in that screencast :O
19:00 kes dikim: http://mojocasts.com/e5
19:00 purl rumour has it http://mojocasts.com/e5 is giving me a solid white page on ubuntu 11.10/chromium 15
19:01 sri we've come so far since then
19:01 kes oh, it was already posted (
19:01 dikim Thanks. kes purl
19:05 sri purl: what are you?
19:05 purl I am a (modified) flooterbuck infobot, and my owner is perigrin.  Download source at http://flooterbuck.sourceforge.net/ or edenc's bitch or espertinho or bugado or stupid. or the mongodb of irc bots or Nuclear Biological Chemical or a big metal dummy. or he mongodb of irc bots or a big fat liar or my favorite robot or delightful today
19:06 rshadow joined #mojo
19:07 sri marcus, batman, jberger, tempire: so we can't find a better name for $tx->result?
19:11 rshadow1 joined #mojo
19:21 mrEriksson joined #mojo
19:23 rshadow joined #mojo
19:26 Pyritic joined #mojo
19:45 good_news_everyon joined #mojo
19:45 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v1pVt
19:45 good_news_everyon mojo/master a3893b1 Sebastian Riedel: add a cookbook recipe with hints for how to build REST clients
19:45 good_news_everyon left #mojo
19:45 batman sri: i can't come up with anything better :/
19:45 sri not my best work, but i think it adds value to the cookbook
19:46 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#REST-web-services
19:46 sri it's more about giving pointers for modules to look into
19:54 rshadow joined #mojo
20:01 kes http://paste.scsys.co.uk/540326
20:01 kes I pass right header, but $self->stash->{ format } still defaults to html. What do I wrong?
20:03 good_news_everyon joined #mojo
20:03 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/e0ad165bfbec7d8e9d9ae96f89281f229e788a61
20:03 good_news_everyon mojo/master e0ad165 Sebastian Riedel: actually show the transaction
20:03 good_news_everyon left #mojo
20:07 pink_mist kes: without you showing what you've actually done, how can we tell what you've done wrong?
20:14 jberger kes: I think you are looking for http://mojolicious.org/perldoc/Mojolicious/Plugin/DefaultHelpers#accepts
20:14 jberger not the format stash value
20:15 jberger see also: http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Content-negotiation
20:21 kes I have two templates: x.json.ep and x.html.ep. I expect x.json.ep is rendered when Accept: application/json
20:22 kes jberger: and Headers are not checked here: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Renderer.pm#L97
20:23 rshadow joined #mojo
20:30 kes and the request headers only checked here: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Controller.pm#L230
20:31 kes but should be checked here also: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Controller.pm#L171
20:32 kes or in the renderer...
20:35 jberger I think you misunderstand the format stash value
20:35 jberger or how it gets set
20:36 jberger http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Formats
20:36 jberger if you want to render x.json.ep, then you need to call $c->render('x', format => 'json')
20:37 kes >The best possible representation will be automatically selected from the Accept request header, format stash value or format GET/POST parameter and stored in the format stash value
20:38 jberger kes: where are you seeing that?
20:38 jberger it isn't in the link I just sent you
20:38 kes http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Content-negotiation
20:38 jberger while in the respond_to
20:39 kes I expect it works when I have no action in controller
20:39 kes but it works only for respond_to
20:40 jberger it is only documented in respond_to
20:41 jberger the problem is that format affects render_to_string and include etc
20:41 jberger indeed, that makes me wonder about .$format too
20:42 jberger but anyway, just use respond_to, that's what its for
20:43 kes ((
20:43 kes this force me to write something: http://paste.scsys.co.uk/540327
20:44 sri if you know how to do it better please send a pull request
20:44 jberger or, set the format parameter yourself
20:44 jberger $c->stash->{format} = $c->accept('html', 'json');
20:44 jberger or something like that
20:44 purl something like that is totally possible
20:44 * jberger pats purl
20:44 purl don't mess with me
20:45 jberger accepts
20:45 sri looks like nobody is monitoring our github issues anymore
20:48 polettix joined #mojo
20:49 jberger ok, lets clean them up
20:49 jberger the websocket test bug seems stale and can't be replicated
20:49 kes ok, thank you.
20:49 jberger agreed?
20:49 purl Just kidding!
20:49 sri the bug is real though
20:50 karjala Does Mojo::IOLoop have something similar to setInterval of JS? A repeating timer?
20:50 sri and still exists as far as i know
20:50 karjala yes
20:51 sri as much as i hate open issues, keeping a known bug open makes sense
20:51 jberger ok, I can reopen
20:51 jberger just tell me what to do
20:51 Grinnz karjala: recurring
20:51 purl recurring is more like a cron task
20:51 sri jberger: dunno really
20:52 sri i mean, yea, we can reopen if there's new  information
20:52 sri ¯\_(ツ)_/¯
20:53 jberger how about 1022?
20:53 sri we already have $dom->content
20:53 sri kinda meh
20:53 jberger text is documented to return just the text content
20:53 sri if it's a common problem we could make ->text work too
20:54 sri but yea, it's meh at best right now
20:54 sri guess i'd be interested in prior art... jquery, DOM API and so on
20:55 sri as it stands, i don't think the issue will go anywhere
20:55 jberger "Extract text content from this element only (not including child elements)"
20:56 jberger let me try the example with all_text
20:57 jberger no, you're right, content is documented to work on nodes, text is documented to work on elements
20:58 jberger maybe a cross-link from text to content
20:58 jberger ?
20:58 jberger (in the documentation I mean)
20:59 sri lol, i think it's easier to make ->text work on nodes than to find better documentation
20:59 jberger hahaha
20:59 jberger well, either way :-P
21:00 jberger we have several options, and I think any are fine by me
21:01 jberger I'll comment just noting them for now
21:08 jberger I don't totally follow 1023
21:09 howitdo joined #mojo
21:12 jberger why are they using url_for at all?
21:12 sri whole thing is weird
21:14 jberger let me cook up a counter-example and maybe the whole thing goes away
21:16 sri http://assets.vice.com/content-images/contentimage/no-slug/ea0b035cdb855110d10f0f39237ec623.jpg
21:17 jberger oh, I think I get the question here at least
21:17 jberger they are trying to use redirect_to which internally uses url_for
21:18 Grinnz yes, iirc redirect_to was url-decoding the target with the fragment and not the one with the query. i traced it to the call to url_for but havent had time to dig deeper
21:19 jberger so a work-around would certainly be just to set the location header directly and rendered(302)
21:20 jberger now the question is why is url_for corrupting it
21:21 pink_mist uhm, shouldn't the fragment be unencoded?
21:21 pink_mist but in a query it needs to be encoded
21:22 pink_mist I mean: I believe mojo does the right thing, and dboehmer's expectations are wrong
21:23 Grinnz no, fragments should also be urlencoded
21:23 Grinnz i think more characters are valid, though
21:24 Grinnz https://metacpan.org/source/SRI/Mojolicious-7.12/lib/Mojo/URL.pm#L65 this might be what's doing it, so maybe it is correct
21:27 kes oh my God, I miss really miss ((
21:28 kes >you can also use respond_to INSTEAD OF render
21:32 sri Grinnz/jberger: well, that can only be resolved with lots and lots of spec reading
21:33 sri and possibly looking into other implementations
21:39 sri not to be done by me though ;p
21:40 sri someone else's turn
21:40 pink_mist Grinnz: well, just being after a ? is a different thing to being inside the value of one of the keys defined after the ? ... I've looked at the specs and they definitely allow all the characters in his testcase to be in the fragment without encoding them more ... but inside the _value_ part of a query string they need an additional encoding
21:41 pink_mist which Mojo::URL does correctly
21:49 jberger I've added some examples and closed it
21:50 jberger I think the odd thing is that they are trying to build a query string in the fragment, doing it themselves and THEN running it through url_for which sends it through Mojo::URL->parse
21:50 pink_mist it's basically the difference between /?key=$value and /#thisisnotakey=andthisisjustsomestringnotavalue
21:51 pink_mist yeah
21:51 dantti_laptop|2 joined #mojo
21:52 jberger so that leaves what to do with 1022
22:00 jberger sri / others: perhaps http://paste.debian.net/903814/
22:10 pink_mist I would think changing it to DTRT would be the better solution
22:11 pink_mist (but this may be why I'm not a core dev :P)
22:11 pink_mist (err, one of many many reasons that is :P)
22:11 jberger my only reason to lean against that is that we have carefully separated (and indeed painfully renamed where necessary) the node vs element methods
22:12 pink_mist ah, right
22:12 pink_mist fair point
22:12 jberger to let one DTRT and cross that boundary seems to be problemativ
22:12 jberger s/v/c/
22:12 jberger my concession to "but text seems like a fairly generic name" is to propose cross linking the documentation
22:16 sri jberger: that's a silly argument
22:17 sri all you do is replace element with node in the description
22:17 sri there is no boundary
22:18 jberger I didn't say I'm firmly in this camp, it is just my leaning. Pretty sure I actually said earlier that I was ok with any of those three solutions I posted
22:22 pink_mist looking at the documentation for Mojo::DOM's tree(), I'm very confused what that is actually documented to do .. all it says is "Document Object Model." and then a warning to be careful? doesn't really tell me anything at all about what it's for ... might be more prudent to make that a private method instead?
22:23 PopeF joined #mojo
22:26 pink_mist (or actually describe what it does and returns better?)
22:34 sri pink_mist: it's intentionally vague
22:34 sri problem is the DOM tree is what connects all the pieces
22:34 sri Mojo::DOM::HTML/CSS
22:35 sri without that interface we'd have a 1500 line monster Mojo::DOM
22:38 jberger tree is "almost private"
22:38 pink_mist ah
23:49 stryx` joined #mojo

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