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

IRC log for #mojo, 2017-03-21

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

All times shown according to UTC.

Time Nick Message
00:32 dave Grinnz: perl -MMojo::URL -e 'print Mojo::URL->new("http+unix://%2Ffoo%2Fbar")->path . "\n";'
00:32 dave that prints nothing :D
00:35 pink_mist he actually meant ->host =)
00:35 Grinnz why would the filename be the host?
00:35 pink_mist because it's a unix socket path
00:35 Grinnz i don't know how http+unix scheme usually works
00:36 Grinnz my experience with file: and sqlite: have the filename as the path
00:36 Grinnz with an empty host or localhost
00:36 pink_mist that's not how this works - you couldn't put an actual path part to the URL as well then
00:45 dave joined #mojo
00:49 ningu joined #mojo
00:49 ningu is there any way to look up a minion job by something other than id?
00:50 ningu for example, one of its attributes sent to enqueue?
00:51 ningu hrm I see. the options aren't extensible. but args are
01:03 dave joined #mojo
01:14 _dave_ joined #mojo
01:37 aborazmeh joined #mojo
01:39 marty joined #mojo
01:45 _dave_ yay chat logs! ->host is what I needed :)
02:14 castaway joined #mojo
02:25 stryx` joined #mojo
02:26 marty joined #mojo
02:58 Crisewng joined #mojo
03:30 noganex joined #mojo
03:34 marty joined #mojo
03:38 stryx` joined #mojo
03:47 cng joined #mojo
03:49 marty joined #mojo
03:50 cng I’m trying to proxy an EventSource connection (effectively betweeen a firewalled server and browser) and having trouble with writes from proxy to browser not flushing. All data appears in browser once connection finishes. Is there a special trick to drain the write buffer? (I’ll do a pastebin with some example code)
03:58 cng http://pastebin.com/DUZ54ad0
03:59 cng I get the $bytes printed in log as each event is read, but nothing appears in browser until after connection gets finish event.
04:18 disputin joined #mojo
05:04 dboehmer_ joined #mojo
05:26 cng I think I’ve found *why* I’ve got a problem, but still not sure how to solve it:
05:26 cng $ua->start(…) performs a blocking request (according to docs in Mojo::UserAgent)
05:34 Grinnz with no callback, yes
05:34 cng yeah, just grokked that part, but not a solution yet
05:34 cng I added callback, and it’s not blocking, but request just starts over
05:34 Grinnz also, Mojo::IOLoop->start will block until the event loop stops
05:35 Grinnz not sure what's going on here without the bigger picture
05:35 cng what part of the bigger picture? Did you see pastebin?
05:42 inokenty-w joined #mojo
05:49 cng I’m suspecting my approach is completely wrong, so rather than trying to fix inherently broken code, what technique should I use to proxy an EventSource request to a backend server?
05:50 cng Aside from doing some auth stuff, I want to send the same request to a ‘private’ server, and send response (events) to user’s browser.
05:54 disputin left #mojo
06:58 dod joined #mojo
07:05 dod joined #mojo
07:13 irqq joined #mojo
07:24 irqq_ joined #mojo
07:33 irqq_ joined #mojo
07:37 AndrewIsh joined #mojo
07:45 Vandal joined #mojo
07:52 prg joined #mojo
07:56 batman cng: have you tried without the proxy?
07:58 batman ah. Yeah, the blocking UA request doesn't work, since it runs inside another ioloop
07:58 batman you need to do $ua->start($tx, sub { ...; $self->finish() });
07:59 batman and (at least) move the Mojo::IOLoop->start part under $ua->start
08:05 Dandre joined #mojo
08:25 trone joined #mojo
08:45 Crisewng1 joined #mojo
08:45 rshadow joined #mojo
09:08 osfabibisi joined #mojo
09:20 Crisewng joined #mojo
09:35 batman joined #mojo
10:16 batman joined #mojo
10:20 eseyman joined #mojo
10:34 janl joined #mojo
10:55 xdg joined #mojo
11:22 batman joined #mojo
11:36 tchaves joined #mojo
12:20 irqq joined #mojo
12:27 gizmomathboy joined #mojo
13:21 borisd joined #mojo
13:24 borisd hello. I'm trying to do very basic template nesting since over two hours and just can't figure it out... I have 3 .ep files, one for the most outer html, one for some title-stuff and then one for the actual content... the middel one just gets ignored, no matter what I do. I debug-messages all 3 templates are being rendered though...
13:24 borisd is there a resent valid and valid good tutorial somewhere?
13:29 itaipu joined #mojo
13:34 batman borisd: maybe you did `% include "middle"` instead of `%= include "middle"`
13:35 nic or did you call it 'content'?  Does it work if you rename it?
13:35 borisd batman: I tried following this https://gist.github.com/sharifulin/335531
13:35 borisd the I found somewhere I should try "extends"
13:36 batman Sidenote: this is bad: `<%== content %>`
13:36 borisd the example seems bad after all, but I can't find a simple minimalistic and working example
13:37 batman i didn't know a layout could have a layout
13:37 borisd maybe it can't?
13:37 pink_mist pretty sure it can't
13:38 pink_mist the layout is a stash value, and will simply be overwritten by the last call
13:38 borisd so how do I nest 3 .ep files then?
13:38 janl left #mojo
13:38 borisd pink_mist: a, that is why the moddle one disapears then
13:38 stryx` joined #mojo
13:38 batman sure you can't just include partials instead?
13:39 aborazmeh joined #mojo
13:39 borisd batman: this would be a completely different approach of strukturing as fas as I can tell.. can try it out
13:39 sri there's http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Template-inheritance and the content_with helper if you really really need stuff like that
13:40 sri http://mojolicious.org/perldoc/Mojolicious/Plugin/DefaultHelpers#content_with
13:40 sri very advanced stuff though
13:41 sri use a simple pattern if that works just as well for you
13:43 borisd hm... so nesting templates is not really a thing?
13:44 borisd better including than nesting?
13:44 batman i think it's better to only have one layout and include the rest.
13:44 batman better, because i can read it instantly.
13:44 pink_mist using include works fine
13:46 mcsnolte joined #mojo
13:47 borisd ok thanks... I was completely in a mess here.. will stop looking in the nesting-direction then
13:48 batman borisd: if you can choose, choose the simplest solution :)
13:48 pink_mist layout nesting might work if you were to localise the layout ... maybe
13:48 gryphon joined #mojo
13:49 pink_mist but my brain hurts just considering it
13:55 sri guess the best way to explain our system is that you can only have one layout, but more than one template can redefine named blocks
14:01 Peppard joined #mojo
14:04 osfabibisi how do I set a Mojo::DOM node's namespace?
14:05 osfabibisi I'm trying to parse a document and output child nodes only, in the namespace of the parent node
14:05 pink_mist name it foo:bar
14:05 pink_mist possibly with a \ to escape the :
14:05 osfabibisi oh :-(
14:07 sri changing namespaces is rather uncommon
14:07 sri of course you're welcome to open a feature request
14:09 osfabibisi I don't want to change namespace
14:09 osfabibisi I want to output a child node in the namespace it's already in
14:09 osfabibisi but if you just print the child node, you lose the xmlns declarations
14:10 marty joined #mojo
14:10 osfabibisi (which is arguably incorrect, but very few libs seem to Do The Right Thing here)
14:11 itaipu joined #mojo
14:12 rshadow joined #mojo
14:24 lluad joined #mojo
14:48 itaipu joined #mojo
14:52 asarch joined #mojo
15:02 PryMar56 joined #mojo
15:14 itaipu joined #mojo
15:19 kes joined #mojo
15:21 kes Hi. Mojo::Util::decamelize do not describe case like: SMTPClient.
15:21 kes I get: s_m_t_p_client
15:21 kes but it would be more proper: smpt_client
15:22 nic nope
15:22 nic that's a common misconception
15:23 kes why? may you provide a link to read about that, please
15:23 osfabibisi it's round-trippable
15:25 nic in titlecase, qty_entities(word) == qty_caps(word)
15:25 nic in camelcase, qty_entities(word) == qty_caps(word) + 1
15:26 batman kes: how would you get camelize("smpt_client") to be "SMTPClient" ?
15:27 kes yes
15:27 batman yes?
15:27 purl yes is the answer to the latest question
15:28 jberger kes: in the router you can use the camelized name to point to a controller
15:28 jberger and you can override the moniker
15:28 nic I see devs who go one step further: say they're using camelcase then use names like 'userID'.  Ask them what the 'D' stands for and watch their eyeballs :D
15:29 jberger I think those are the only two uses of the decamelize
15:29 kes batman, yeah. I saw the problem. misconception
15:29 kes maybe SMTPClient -> smtp__client -> SMTPClient ?
15:30 jberger kes: ?
15:32 kes never mind, sorry
15:32 osfabibisi that might work, but it's not a common convention
15:33 kes ** I was trying to autogenerate route names by package name. And it looks terrible: $app->routes->find( 's_m_t_p_client' )
15:33 osfabibisi does that matter?
15:34 osfabibisi and if so, you could write a sub that first checks your %exceptions and if not found, then decamelizes
15:44 lluad If you want to do it in reusable way, kes, you can take a look at the way Go does it, and maybe snarf their list of common initialisms.
15:45 lluad (e.g. https://github.com/golang/lint/blob/206c0f020eba0f7fbcfbc467a5eb808037df2ed6/lint.go#L731 )
15:45 sh14 joined #mojo
15:45 kes lluad: Thank you
15:46 lluad If you want to see the algorithm they use to make it work with roundtripping, take a look at the source for ... snaker, I think. It's a pretty dumb, simple algorithm, though.
15:59 Grinnz nic: that's why i started using lowercase and underscores for everything
16:00 disputin joined #mojo
16:00 Grinnz nic: in our case we had userId and stuff
16:35 dod joined #mojo
16:36 osfabibisi bah, Mojo::DOM with ->xml(1) is sometimes emitting &amp; as "&" instead of &amp;
16:36 * osfabibisi goes back to the joys of libxml for now
16:37 Grinnz what do you mean by "emitting"?
16:38 osfabibisi print $dom;
16:38 Grinnz do you have a reproduction code? it works for me
16:39 osfabibisi in the xml doc we're processing, it works for 4 elements, fails for one...
16:39 osfabibisi I'll see if I can code up a minimal failing case
16:44 sri perl -Mojo -E 'say x("<lalala>&</lalala>")'
16:56 stryx` joined #mojo
17:05 disputin joined #mojo
17:50 gryphon joined #mojo
18:16 howitdo joined #mojo
18:28 dod joined #mojo
18:32 FROGGS joined #mojo
18:47 rshadow joined #mojo
18:54 gryphon joined #mojo
19:06 chandwki joined #mojo
19:17 irqq joined #mojo
19:26 asarch joined #mojo
19:33 trone joined #mojo
19:57 tchaves joined #mojo
20:31 dod joined #mojo
20:35 zivester joined #mojo
20:38 vicash left #mojo
20:54 tinita joined #mojo
20:58 tinita joined #mojo
21:08 cng batman: thanks for that, I’m still not getting desired results. I updated the pastebin: http://pastebin.com/DUZ54ad0
21:10 cng With the non-blocking ->start the response from the private server finishes immediately, so same happens with response to browser; I get ‘get_enquiry_events-callback for start’ repeatedly in the log as the browser attempts to reconnect the EventSource.
21:11 cng Also, pointing a browser directly to the private server and the EventSource works as desired.
21:12 rshadow joined #mojo
21:17 cng I hadn’t updated logging on private server (or hadn’t restarted the process); the request doesn’t get sent to the private server when start has a callback. I must be doing something else wrong which is preventing that.
21:18 batman cng: second problem: $ua goes out of scope.
21:18 batman you should store it back into $self->stash()
21:18 cng ok, that matches what I’m seeing, but goes out of scope where?
21:19 cng stash it for re-use in the start callback?
21:19 batman at the end of the sub (at least if you have the ioloop already running)
21:20 cng I’m only using $ua within the controller, I don’t reference it (directly) within any of the callbacks.
21:24 cng I’m contemplating a refactor of the private server to use websockets rather than EventSource. The proxy server would setup websocket to private server, and then generate an EventSource for the browser. Would that potentially work better?
21:25 batman cng: do you know what "goes out of scope" mean?
21:25 cng yes, I don’t see what/where it’s needed once it goes out of scope.
21:25 cng I can stash it, to use it again where?
21:26 batman the $ua object need to be "kept alive" for the request to start/finish.
21:26 cng ok, ta; will try that
21:26 batman so just calling start() isn't enough, since the callback given to start() and the whole request will just "vanish" once the $ua goes out of scope
21:28 cng WOOT!!
21:28 batman cng?
21:28 purl cng is a better algorithm than LSI.
21:29 cng That was a cheer
21:29 cng This part of docco was confusing: $ua->start($tx => sub {  my ($ua, $tx) = @_; … });
21:30 cng How does the callback get passed a copy of $ua unless it was already stashed somewhere
21:30 preaction because the ua knows itself
21:30 cng Anyway, I can proceed with the business logic now. Thanks for the help.
21:31 cng There’s still lots of grey area for me and the event model. I continue to learn and get better with it.
21:33 batman cng: yeah, this isn't straight forward. but it's extra fun when you see the benefit :)
21:34 cng Decades of Perl, decade of catalyst, 18 months of Mojo - I’ll keep learning the event stuff cause it is pretty damned cool.
21:35 cng Once I have time to ponder the implications of today’s learning, I suspect I’ll grok a lot of other rough edges heaps more. Good learning, so thanks again.
21:37 Grinnz event loop code is definitely a different way of thinking. once you get it, things start to click
21:37 Grinnz I mostly got it after reading the source of Mojo::Reactor::Poll
21:38 Grinnz it's really rather simple at the basic level
21:38 pink_mist is that still true? :P
21:38 Grinnz _poll is a little weird to parse, but for timers, yes
21:39 cng cheers; MT::Poll page open for reading after brekky.
21:40 Grinnz everything in event loops is either timers, handles, or signals, and mojo doesn't really touch your signals
21:42 cng Again, thanks all, this works so effing well now; I can’t stop smiling :-D
21:43 cng I’ve not gotten this stuck on a problem for a LONG time.
21:45 cng ok, another question as I tidy code, do I need both the start callback and attaching to finish event: $tx->on(finish =>  …) - should I move code from finish event to start callback?
21:46 Grinnz you probably don't need both, no
21:46 Grinnz havent looked at that section of the code though
21:46 cng That’s they way it seems from testing; just checking I was understanding the flow.
21:47 Grinnz finish events are much more rarely needed than standard callbacks for nonblocking code
21:47 cng I just need to remove an earlier recurring timer, that seems to be happening
21:47 cng I get errors if I don’t remove it, no errors removing it in start callback
22:20 ccakes joined #mojo
22:22 miller joined #mojo
22:23 ccakes_ joined #mojo
22:24 ccakes joined #mojo
22:37 disputin joined #mojo
22:42 marty_ joined #mojo
22:58 stryx` joined #mojo
23:01 _dave_ sri: have you actually tested chmoding an IO::Socket::UNIX glob?
23:12 pink_mist what
23:15 _dave_ ?
23:21 _dave_ http://paste.scsys.co.uk/557603 ... try it
23:35 marty joined #mojo
23:42 irqq_ joined #mojo

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