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

IRC log for #mojo, 2017-04-03

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

All times shown according to UTC.

Time Nick Message
00:02 _dave_ joined #mojo
00:44 genio sri: not the most elegant: https://gist.github.com/genio/dfe09035d5bb7ae6b4b2aa6355c5826f
00:44 genio :/
00:46 genio If that's too far outside the realm of being acceptable, I won't bother with a PR
01:13 jberger genio: check my math here, but is your line if ($close && ((!$res->code && !$res->error) || ($check_len && !$comp))) {
01:13 jberger the same as
01:17 jberger if ($close && !$res->error && ($res->code || !$comp) {
01:17 jberger lost a paren at the end there
01:19 genio if ($close && !$res->error && (!$res->code || $res->code && !$comp)) {   maybe?
01:19 jberger you shouldn't need both true and false of any condition in an "or"
01:20 jberger should you?
01:20 purl should you is, like, another question
01:21 jberger no, its just
01:21 genio && happens before the ||, so either $res->code && !$comp   or !$res->code.
01:21 jberger if ($close && !$res->error && !$res->code && !$comp) {
01:22 jberger which I think makes sense just reading the logic out
01:23 jberger if you're closing and you don't have an error and you don't have a code and you aren't complete
01:23 jberger indeed it sounds like it could be
01:23 jberger if ($close && !($res->error || $res->code || $comp)) {
01:24 genio but you'd have a code in this case
01:24 jberger if you're closing and you don't have an error or a code or are complete
01:24 genio if you're closing and you don't have an error and you do have a code and your lengths don't match, it's also bad
01:25 jberger isn't that in my logic?
01:27 genio I don't think so. but maybe I'm too tired to think
01:29 jberger "your lengths don't match" is !$comp right?
01:29 genio right
01:30 genio closing and no error and no code, fail.   closing and no error yet with code and a length mismatch, fail.
01:32 genio I think your last one would short out on the existence of a code regardless of the length comparison
01:33 jberger oh, it isn't commutative
01:34 jberger if ($close && !$comp && !$res->code && !$res->error) {
01:35 genio that wouldn't pass when you have a code and a length mismatch
01:36 genio unless you add that as part of the building of $comp
01:37 jberger nm, I give up
01:37 genio nvm, that couldnt' be moved to the building of $comp either.
01:37 jberger I was trying to do it with formal logic math and I got screwed up on commutivity
01:37 genio I don't think there's a good way to shorten it. :/
01:40 kiwiroy joined #mojo
01:44 genio jberger: https://gist.github.com/genio/dfe09035d5bb7ae6b4b2aa6355c5826f#gistcomment-2044782   does that look any cleaner?
01:46 jberger https://gist.github.com/jberger/f6c9aad71dd99cf6106066efb8bdacd3
01:47 genio ah.. makes sense
01:48 jberger yeah, I dropped something the first time around
01:51 genio jberger++
01:54 genio jberger: Do you have any other hangups now that the logic there looks a lot better?
01:55 jberger I just refreshed your gist and I think you duped the error line
01:56 genio gah. I sure did.  probably shouldn't manually edit diffs :)
01:58 jberger tbh I have no idea, but that certainly LOOKS better
01:58 jberger in the mojo style, do we implicitly return values in a multiline sub?
01:59 jberger ie, should it be: return $cl == ($self->{real_size} // 0)
01:59 jberger ;
02:01 genio fixed
02:03 jberger ok so assuming all the other logic is correct (meaning the defintion of is_complete and $comp) and the problem being solved is a real one, them I'm ok with that
02:04 sri i'm not ok with it
02:05 sri the result is incorrect for chunked transfer encoding too i think
02:06 jberger presumably that's more logic in is_complete?
02:08 genio complete is probably also a bad choice of word.
02:10 jberger is_expected_length or is_full_length
02:10 jberger perhaps
02:10 genio should probably also short out with a return 0 unless $self->is_finished; as well?
02:11 jberger I can see that opinion, but I'd let sri rule on that
02:12 genio let me look into the chunked length and try to understand sri's comment a bit. this seems like it's turning out to be a lot of extra code to catch one small edge case
02:13 jberger the other way to spin it is, though, it might be nice just have this generic way to check if the message is complete from a logical sense
02:15 jberger and especially since the code to do so relies on private data, this seems like a useful method to have
02:17 genio sri: I realize I should just take your word for it as you're more likely than not to be corret, but real_size does look correct to me if we're in a finished state
02:23 genio and what's the preference on returning a falsey value?  I see return unless ...;  as well as return 0 unless ...;
02:25 genio nevermind.  the return unless ... is on methods not explicitly returning a boolean value.
02:29 genio adding the return 0 if $self->is_finished; breaks tests so I think it's bed time for me.
02:33 noganex_ joined #mojo
02:35 genio ah, I'd need to use the various ->body_size methods. but that would have to not default to giving me the content-lenth header first.
03:16 Janos_ joined #mojo
03:20 mattp joined #mojo
03:25 kiwiroy joined #mojo
03:41 dabudabu joined #mojo
04:04 dboehmer joined #mojo
04:09 lluad joined #mojo
04:21 stryx` joined #mojo
05:01 inokenty-w joined #mojo
05:22 dod joined #mojo
05:35 dod joined #mojo
06:08 ashimema joined #mojo
06:15 dod joined #mojo
06:17 kaare joined #mojo
06:37 prg joined #mojo
06:43 dod joined #mojo
07:09 marcus jberger: https://gist.github.com/30b2427cf088cb4fbfd3a13c5004118c
07:14 AndrewIsh joined #mojo
07:17 trone joined #mojo
07:43 marcus jberger: https://gist.github.com/9604bd5f3c9c4f3620d0daedbdab975d updated version with select instead of sleep.
07:45 pink_mist why select instead of sleep?
08:15 coolo postgresql really has no index enforcement option?
08:55 rshadow joined #mojo
08:58 dod joined #mojo
09:06 batman pink_mist: because sleep() sleeps for the whole time, while select() will sleep MAX timeout seconds.
09:07 batman so if a change happens before timeout, it will be detected.
09:15 kaare joined #mojo
09:17 irqq joined #mojo
09:21 simbabque joined #mojo
09:34 mtths joined #mojo
09:42 dod1 joined #mojo
11:08 mattp joined #mojo
11:28 tchaves joined #mojo
11:44 rshadow joined #mojo
11:50 mishanti1 coolo: What do you mean by index enforcement? Make it always use an index?
11:52 coolo mishanti1: a specific index - to enforce a specific query plan
11:52 mishanti1 If so, then no. That is a deliberate choice, as index enforcement can not guarantee any performance gains. Statistics can produce better plans than force.
11:53 * coolo read meanwhile that postgresql sells that feature as enterprise
11:53 coolo mishanti1: yeah, I read all that nonsense - why should humans guess if machines can guess too :)
12:05 mishanti1 coolo: Is it not the company EDB that sells that, in that whole "we'll give you a PostgreSQL-bundle plus fluff" thing of theirs?
12:13 sri coolo: you can do "SET enable_seqscan = OFF;" though
12:13 sri which takes care of the not enough data for the planner to use an index problem
12:17 coolo sri: yeah, with that I verified that the indices are fine. But it's said not to be used in production
12:30 stryx` joined #mojo
12:30 cng joined #mojo
12:31 sri marcus: looks reasonable
12:32 sri genio: yes, my chunked transfer encoding comment was related to the extremely generic name, it implies much more functionality than is there
12:45 genio sri: I'll play around a little more this evening as I'm learning a bit more how everything works. If someone works it out before then, oh well. :)
12:45 genio thanks for all the pointers though
13:21 gizmomathboy joined #mojo
13:26 marcus sri: Kinda looks like it can be merged then, with batman's vote?
13:28 sri marcus: there's still style fixes needed
13:28 sri some docs are inconsistent and stuff
13:32 batman sri: we've been through the code a couple of times already... can you point to a line?
13:37 sri i'll do a formal review if you're confident
13:46 sri marcus, batman: i did find "a few" things :)
13:49 sri btw. i've made another change to minion https://github.com/kraih/minion/commit/d81cb2aa21567a849f7ce593b87a61b8c4668d23
13:53 sri this is what the result looks like with the default worker command https://gist.github.com/anonymous/2468c67622477c52c40f8f71331aa4fc
13:55 sri it's an attribute so other status information can be added from events like worker and dequeue
13:55 sri and i've lowered the heartbeat frequency since heartbeats are getting a little more expensive
13:59 jberger and given that you are showing the queues as status, I'm assuming the next change will be to make the --queue command line option handling more flexible thereby addressing the subclass concern from the other day
13:59 sri actually, i was more thinking about remote control commands
14:00 sri as in changing the queues at runtime
14:00 jberger but, I think that would address the concern in that PR too
14:00 sri jberger: how should the command line handling be more flexible?
14:01 jberger I'm not saying that, I'm speaking in regards to https://github.com/kraih/minion/pull/49
14:01 jberger notice that I finally investigated the OP's use-case and discovered that their proposed fix wouldn't actually help
14:02 jberger because though the Worker class will default to 'default' queue, the worker command always provides a queue name
14:02 jberger which also defaults to 'default'
14:03 jberger so being able to overload that in the worker, and then instantiating some other worker class somehow would not fix their problem
14:03 jberger BUT
14:03 jberger what you seem to be working towards now does seem to have that possibilty
14:04 jberger ... as you've now commented on that PR
14:04 Janos_ joined #mojo
14:05 Pyritic joined #mojo
14:05 batman sri: quite impressive that we missed so many things.
14:06 batman marcus is on his way home. will probably fix it later.
14:06 batman thanks for the feedback :)
14:29 vicash joined #mojo
15:04 lluad joined #mojo
15:53 disputin joined #mojo
16:23 sh14 joined #mojo
16:27 maschine joined #mojo
16:45 rshadow joined #mojo
16:50 dod joined #mojo
17:19 dexteruk joined #mojo
17:26 stryx` joined #mojo
17:27 dexteruk joined #mojo
17:41 irqq joined #mojo
17:54 tchaves joined #mojo
18:07 sri wonder what is keeping people from trying to make this one happen https://github.com/kraih/minion/issues/25
18:12 arcanez sri: minion's README.md has an extra >
18:12 arcanez [documentation](http://mojolicious.org/perldoc/Minion>)!
18:12 Rob joined #mojo
18:12 sri oops
18:12 Rob Hi guys
18:13 arcanez sri: a pr would probably have taken longer :P
18:13 Rob I'm looking for a way to get the *base URL* from a Mojo::Message::Response object. I've coded it myself but I would have thought it would be part of the module
18:14 Grinnz Rob: response messages don't have a URL
18:15 Rob They have a *base URL* so that any relative URLs in the message body are based on
18:15 gizmomathboy joined #mojo
18:16 Grinnz where?
18:16 Rob @Grinnz: It's supposed to come from an HTTP header, or from a <base> element in the HTML, or from the most recent redirect URL
18:17 Grinnz that's far too specific for a general response message which often is not even HTML
18:17 Rob Grinnz: Where what?
18:17 Grinnz i was asking where you would find this base URL in a general response message, which you answered
18:18 Rob Grinnz: It's part of the HTTP spec. Forget the HTML content, it's either an HTTP header Content-Location or the latest reuqested URL
18:19 Rob Grinnz: It used to be Content-Base
18:19 Grinnz you can get the Content-Location or Content-Base header from the message; anything beyond that would be higher level than the ::Message class can handle
18:19 Grinnz i.e. that would be something for the user agent to figure out
18:20 Rob Grinnz: Yeah but it doesn't seem to do that.
18:20 Grinnz do what?
18:20 purl rumour has it do is just a loop where something controls/constrains it to execute once or de do do do de the da da
18:20 Rob Grinnz: You're saying that Mojo is supposed to be HTML agnostic?
18:20 sri you're the first to ask for it since mojolicious exists :)
18:20 Grinnz i'm saying Mojo::Message is HTML agnostic
18:21 Rob Grinnz: It's built into HTTP::Response
18:21 Pyritic joined #mojo
18:21 Grinnz that's nice?
18:21 Rob Grinnz: So you're saying it's not built-in anywhere and I have to code it myself?
18:22 sri it does not currently exist
18:22 Grinnz if you reference the appropriate specs and it's useful enough, maybe it can be added to the appropriate class
18:23 Rob RFC 1808 - Relative Uniform Resource Locators - IETF Tools
18:26 sri you can discuss your feature here to get support from the community for it, formal feature requests can then be sent to github https://github.com/kraih/mojo/issues
18:26 sri if it gets enough votes it will usually get implemented
18:26 Rob It's hard to believe that it's not already in there. I'll do that, thanks
18:27 sri or you submit a pull request http://mojolicious.org/perldoc/Mojolicious/Guides/Contributing#CONTRIBUTING-CODE
18:27 Grinnz everyone has different needs from the toolkit, this one has apparently not come up before, at least not from someone with the mind to ask for it
18:28 jberger the idea being that the response base might be different than the request base?
18:29 Rob jberger: The request doesn't have a base. It has a URL that may change if the request is redirected
18:29 jberger but the request has a stack of redirects
18:30 jberger and IIRC you see the last one's url once it is done redirecting and gives you a response
18:30 jberger I bring this up because I haven't yet needed the feature you are asking for and I'm curious why I haven't
18:30 jberger as you say, it is surprising that something would go unasked for this long
18:31 Rob @jberger: The response may return a resource from a different location, and send a Content-Location header to say where it';s really from. That will be the base for any relative URLs. And if the content type is text/html then it may include a <base> element which says something different again
18:32 pink_mist isn't the base for where /-anchored urls should be based? ... thanks to $c->url_for it's not usually needed in mojo
18:32 Rob It's for *any* relative URLs in the message content
18:33 Rob pink_mist: What is $c?
18:33 purl $c is the current request or three letters shorter than $self
18:34 pink_mist the controller object
18:34 jberger Rob I may be wrong but I don't see HTTP::Response parsing the response HTML body: https://metacpan.org/source/ETHER/HTTP-Message-6.11/lib/HTTP/Response.pm#L77-99
18:34 Rob pink_mist: I'm talking about an HTTP client here
18:34 _Janos joined #mojo
18:35 pink_mist Rob: oh, so you're not writing a webapp, you're just using Mojo::UserAgent?
18:36 Rob @jberger: It's done elsewhere, I can't remember exactly. The response is parsed and a pseudo-header "Base" is added. That's what HTTP::Response uses
18:36 Grinnz HTTP::Response objects also contain a reference to their respective request agent; Mojo::Message objects don't
18:36 Grinnz so the latter part of that sub would have be higher level
18:36 Grinnz request object*
18:37 Rob pink_mist: At the moment I'm writing the part of a web app that pulls data from another site
18:37 pink_mist Rob: I mean, the issue you're having is while using Mojo::UserAgent?
18:37 sri yes, you could only do it transaction level
18:37 Rob pibk_mist: yes
18:38 Grinnz luckily Mojo::UserAgent requests return the transaction object, not the message directly
18:38 pink_mist right, then I need to re-read the conversation from the beginning because my initial assumptions were completely wrong ;)
18:38 Grinnz so you could still call this new method on that
18:39 Grinnz https://metacpan.org/pod/Mojo::Transaction::HTTP is probably the most appropriate place
18:39 Rob There's no reason a response object couldn't keep a copy of the request URL
18:39 Grinnz there's no reason it needs to
18:39 jberger Rob: but the response doesn't have it, the request does
18:40 jberger so you are considering the entire transaction
18:40 jberger the semantics of this seem exactly correct to me
18:40 Rob I'm not keen on a transaction having a base URL
18:40 jberger it doesn't, the transaction has the request
18:41 jberger which has the base url that was requested
18:41 jberger it is a different paradigm yes, but I don't see that changing
18:41 Grinnz this would likely just be a convenience method on the transaction, that uses both the request and response objects to determine what you're asking for
18:41 Rob @jberger: Yeah, but it would be $txn->base_url
18:41 Grinnz you could name it response_base_url or something if it needs to be more specific
18:42 Rob While I'm laying stuff down, the Content-Location header used to be called Content-Base, which may need to be supported
18:43 Rob Grinnz: I'm not worried about ambiguity, just that it's a strange place to look for that method
18:43 jberger Rob: if you are actually going to implement something that does HTTP parsing as part of the hunt for the base url, I'm going to jump ahead and say that it is unlikely to be accepted, that's my first guess
18:43 jberger all of this is public api, you could as easily write a cpan module which can do this more complex computation
18:43 Rob The other part is whether you want to support the <base> element in HTML, which would need a Mojo::DOM object etc.
18:44 Grinnz the transaction object has methods that access the request object and methods that access the response object, nothing new there
18:44 Janos_ joined #mojo
18:45 Rob jberger: Erm, the module already parses the HTTP
18:45 Grinnz i think he meant HTML parsing
18:45 Rob oki
18:45 jberger sorry, yes, that's what I meant
18:47 Rob The major use is going to be for HTML transactions, and a base URL without considering the response content isn't much use
18:47 Rob But to refuse this is to say that you don't want people using Mojo::UserAgent as a general-purpose HTML UA
18:48 Grinnz Rob: as linked earlier the HTTP::Response method doesn't either; and that could be implemented as a separate module that takes the response and uses ->dom to find the data
18:48 pink_mist Rob: nobody is refusing
18:48 Grinnz Rob: don't be overdramatic
18:48 jberger Rob: I haven't said we will refuse it
18:48 Rob I'm not supposing you will. I'm just comparing the options
18:49 jberger we try to keep these classes lean and make the data available
18:49 jberger all the data you need is public api
18:49 Grinnz intending something to be general purpose doesn't mean implementing specific methods for every possible purpose
18:49 Rob Grinnz: I explained that above. It's done in a different module which creates a "Base" pseudo-header which HTTP::Response uses
18:50 jberger if there were data that couldn't be gleaned publicly I think there would be a much more compelling case
18:50 Rob Yeah but HTML is a pretty major "purpose"
18:50 rshadow joined #mojo
18:51 jberger Rob: do you really think we don't agree with you?
18:51 Rob jberger: That's a little extreme. I can write anything I want using Sockets, so there's no need for Mojo
18:51 Rob jberger: No. I don't know where that came from
18:52 jberger Rob: ok, I think I'm going to let others take care of this, someone ping me if you need me
18:53 Grinnz Rob: Mojo::UA sees plenty of use for retrieving HTML and using ->dom to parse the result; this functionality hasn't been asked for, so clearly it's not required for that general purpose
18:53 Rob I need to go. If anyone uses Stack Overflow then there's this question that I raised that you may want to read or respond to http://stackoverflow.com/questions/43170389
18:53 Grinnz or where it has, perhaps people just implemented it themselves
18:55 Grinnz but you're assuming quite a lot about the structure and intent, i suggest dialing it down a bit if you want the discussion to be productive
18:56 Rob Grinnz: That is what I'm worried about. Getting everyone to implement their own RFC 1808 just because it hasn't been implemented in the module is going to result in thousands of dormant bugs
18:57 Grinnz nobody has disagreed so far with that premise
18:57 Rob Grinnz: That is absolutely not what I intended to convey. My apologies
18:57 Grinnz just that the HTML parsing component may not be a great fit for the core Mojo module, and may work better as a separate CPAN module
18:57 jberger all I ever said was that it was unlikely and that was based on the fact that USUALLY we don't have convenience methods that fetch data from multiple different locations
18:58 jberger that isn't to say that we wouldn't consider it if there was a compelling case to do so
18:59 jberger and as Grinnz says, none of the Transaction/Message classes have specifics for HTML other than a shortcut to create a Mojo::DOM object (that I can think of)
18:59 Rob jberger: I had no intention of saying otherwise, and I apologise if that's appropriate. I agree: I think Mojo should support RFC 1808, and perhaps DOM could offer a "base" method?
18:59 Rob That's all. Thanks again
19:00 jberger we DO like to support RFCs that's a good angle to approach us on I think ;-P
19:01 gizmomathboy joined #mojo
19:01 jberger it is an interesting thing to ponder, thanks for approaching us with the idea
19:01 jberger something to mull over certainly
19:10 marcus sri: Thanks for the review, will resolve the issues as soon as my kids fall asleep.
19:15 sri wonder if i make a terrible minion ui if people will send patches :)
19:15 sri s/if//
19:15 sri just to have a foundation with plugin and stuff
19:16 pink_mist (I think both 'if's in your sentence belongs there)
19:16 Grinnz it's... ambiguous, better to swap the sentence around :P
19:18 sri if only i got as many patches for my code as i get for my sentences muttered on irc
19:18 Grinnz :)
19:18 pink_mist :P
19:18 jberger I've already offered my code as a start
19:18 disputin joined #mojo
19:18 jberger you are welcome to it if you want
19:19 jberger especially the api side (not sure the HTML is worth anything)
19:19 sri jberger: too opinionated
19:19 sri this is what we want https://github.com/kraih/minion/issues/25#issuecomment-234754959
19:20 jberger k, if you don't want it api-backed then yes
19:20 jberger mine not much help
19:22 sri i want it totally old school
19:23 sri those are the admin uis that survive
19:23 sri like flower https://flower.readthedocs.io/en/latest/screenshots.html
19:26 kaare_ joined #mojo
19:36 Sebbe joined #mojo
19:37 marcus https://www.youtube.com/watch?v=u9ZqbRj8ZF0
19:41 jberger was Rocknrolla the one about how Kaballah is amazing?
19:42 genio Hmm.  keyboards on the 2017 XPS laptops don't travel that far either.  some weird new trend going on, I guess
19:42 batman genio: it's really not bad once you get used to it (i got a macbook pro)
19:42 jberger no, that was Revolver
19:46 stryx` joined #mojo
20:04 stryx` joined #mojo
20:22 marcus jberger: Rocknrolla was about a Rocknrolla =]
20:26 marty joined #mojo
20:32 sri genio: i actually like the new apple keyboards more than the xps ones
20:32 sri the xps are so not clicky at all, i hate that
20:37 Grinnz ick, my old asus laptop had non clicky keys, it was so imprecise and spongy
20:37 Grinnz now theyre all chiclet basically, much better
20:51 genio Yea, it is going to take me quite some time to get used to this
20:52 genio I'm trying to remove all the windows bloatware now though.  they make it really annoying to get a fresh windows install sans all the dell add-ons
20:53 sri since it's been so hard to explain what i had in mind for the minion admin, here's an example https://github.com/kraih/minion/compare/admin
20:54 sri really not much more than that for starters
20:54 dikim joined #mojo
21:01 sri plugin returns a route that can then be reattached somewhere else for authentication and stuff
21:02 sri standard templates and static files with a prefix, which allows for customizing in the app
21:06 marcus sri: Do my changes look ok? Want me to rebase and force push to a single commit before I call it a night?
21:06 sri marcus: have not looked yet
21:06 marcus ack
21:06 sri but yea, rebase in any case
21:31 jberger sri: can you explain how you would reattach a route under authentication?
21:32 jberger in circumstances like this I have accepted an optional route argument that I attach to or else create a new route from the base router
21:32 jberger but I like the simplicity of what you are doing if I knew how to then do something with that
21:37 sri my $admin = plugin 'Minion::Admin'; my $auth = $app->routes->under('/auth')->to('Auth#openid'); $auth->add_child($admin);
21:38 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Rearranging-routes
21:38 sri you can move them around before the first request
21:42 jberger neat, I've read that a dozen times but without that context it didn't internalize very well
21:42 jberger I haven't decided if I think that is better than passing in a route in some sense it is cleaner
21:43 jberger because then the user needs to understand how the route is an object to be passed around
21:45 jberger I guess that's true in both cases
21:45 * jberger mind blown
21:49 batman where it is documented that $app->plugin() has a return value?
22:01 sri btw. everybody think the status feature was done right? https://github.com/kraih/minion/commit/d81cb2aa21567a849f7ce593b87a61b8c4668d23
22:02 sri (as an attribute in Minion::Worker that gets sent with every hearthbeat)
22:08 howitdo joined #mojo
22:35 PryMar56 joined #mojo
22:38 mtj joined #mojo
23:09 sri btw. that ghost in the shell movie was really disappointing
23:10 sri special effects were spot on, but the director doesn't know how to tell a story
23:40 PryMar56 joined #mojo
23:46 irqq_ joined #mojo

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