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

IRC log for #mojo, 2017-07-19

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

All times shown according to UTC.

Time Nick Message
00:11 genio I'm implementing UV::Poll now. One change they've made since v0.x is to have two ways to initialize a poll object. You used to only initialize it against a file descriptor. Now, you can also initialize it against a socket (windows support).
00:12 genio What's a good way to distinguish between the two in ->new()? ->new($fd, $loop) and ->new_sock($sock, $loop)?
00:13 genio or the opposite, ->new($loop, {fd=> $fd,}) and ->new($loop, {sock=>$sock});     along those lines? Figuring out the proper XS code for this will be fun to allow for a hashref or a hash, etc.
00:14 genio Every other UV::Handle type so far has only really accepted a loop as an optional argument (defaulting to the default_loop())
00:18 genio I guess I could expect an even number of args (hash) and if the loop key isn't found, default it to the default_loop and require one or the other of fd and sock to exist
00:51 schelcj joined #mojo
01:17 simcop2387 anyone have an existing example of using Mojo::IOLoop::Client inside a mojolicious request?  I'm sure it's easy to do i just want to be lazy.
01:18 simcop2387 basically POST /paste => Send requests to TCP server, await response => responses back, send data to browser
02:05 genio I don't guess that will matter too much to begin with. I'll implement without sockets for windows.
02:16 Grinnz simcop2387: https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Synchronizing-non-blocking-operations just using Mojo::IOLoop->client instead of $ua->get
02:17 Grinnz the key is to use the $c->delay helper so it keeps the transaction around and sets render_later for you
02:18 Grinnz you pass $delay->begin in place of the callback, and then your next delay step will get the arguments the callback would have gotten (minus the invocant)
02:30 noganex_ joined #mojo
02:46 simcop2387 Grinnz: yea i figured it'd have to do something with $c->delay.  good to know.  I'll have to figure out the best way to organize this.  right now i'm treating the evalserver as a model and it's gonna be hugely async after this.
02:47 simcop2387 probably not too hard though.
02:47 simcop2387 once that's done then I can properly allow evalall though on the pastebin without causing issues for myself.
02:49 simcop2387 evalall ends up a very different path than the usual so it'll pose some organizational issues.
02:56 hkclark joined #mojo
03:23 perlpilot joined #mojo
03:27 bobkare joined #mojo
03:27 stephan48 joined #mojo
03:27 kaare joined #mojo
03:27 preaction joined #mojo
03:27 Lee__ joined #mojo
03:27 ssm joined #mojo
03:27 arcanez joined #mojo
03:29 mtths joined #mojo
03:40 ilbot2 joined #mojo
03:40 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
03:41 haarg joined #mojo
03:42 jberger joined #mojo
03:42 mattp_ joined #mojo
03:42 Jonis_ joined #mojo
03:42 eseyman joined #mojo
03:42 vicash joined #mojo
03:42 Armen joined #mojo
03:42 dustinm joined #mojo
03:44 castaway joined #mojo
05:07 inokenty-w joined #mojo
05:28 mudpit joined #mojo
06:49 AndrewIsh joined #mojo
06:53 dod joined #mojo
06:59 dod joined #mojo
07:36 karjala_ joined #mojo
07:51 stephenyao joined #mojo
07:52 Vandal joined #mojo
07:54 sri genio: looks like in the lua binding its new_poll and new_socket_poll https://github.com/luvit/luv/blob/master/src/poll.c#L37
08:07 trone joined #mojo
08:37 dod1 joined #mojo
08:48 prg joined #mojo
08:48 dod joined #mojo
08:52 rshadow joined #mojo
11:39 yukikimoto joined #mojo
12:21 yukikimoto joined #mojo
12:31 gizmomathboy joined #mojo
12:33 bwf joined #mojo
12:58 genio sri: I'm just implementing ->new() for now.  I'll do ->socket() later as another constructor (bad, I know). But, polling a file descriptor is done (no real testing yet). Turning an IO::Socket into a SOCKET in the background would have to be figured out before I can setup windows socket polling
13:00 genio It doesn't look like they're actually trying to do windows SOCKET stuff properly. They're just handling the other way to do a file descriptor (both are integers on *nix) but a socket poll watches an actual SOCKET object in windows
13:02 dod joined #mojo
13:24 gryphon joined #mojo
13:31 Vandal sri, can I ask why you doing this https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/EPRenderer.pm#L40 instead of just some thing like $c->stash->[c} = $c; ?
14:04 bianca joined #mojo
14:17 AndrewIsh joined #mojo
14:39 perlpilot joined #mojo
14:50 bianca joined #mojo
14:56 jberger Vandal: that localizes the controller into the template's compile namespace but only for the life of the compilation
14:57 jberger compilation and execution I should say
15:01 Vandal jberger, why?
15:03 tchaves joined #mojo
15:11 dod joined #mojo
15:12 sri MOJO_TEMPLATE_DEBUG=1 might give you the answer
15:13 sri look at the code, and then think of the performance cost of using the stash
15:14 sri and the part you don't see https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/EPRenderer.pm#L51
15:17 sri (hint, using the stash would mean that every new helper makes every template slower)
15:17 jberger oh the good (read: bad) old days
15:19 gizmomathboy joined #mojo
15:21 rick_soc joined #mojo
15:21 rick_soc hello
15:21 purl niihau, rick_soc.
15:24 rick_soc First I just want to say how incredibly happy I am with mojolicious, just started using it and this is the fastest I've ever been able to build a working prototype =)
15:26 rick_soc I have a question about the I18N plugin that has since been removed from mojo
15:26 jberger rick_soc: what a nice complement! thanks for that
15:26 bianca joined #mojo
15:27 rick_soc On github and cpan the last update to the independent Mojolicious::Plugin::I18N was in 2015
15:27 rick_soc I know there have been a lot of updates to Mojo since then, so does anybody know if this Plugin still works as-is?
15:28 sri it should
15:29 sri i've been thinking about bringing i18n back into core, but the implementation is not clean enough
15:30 rick_soc Are there any recommended alternatives to it?
15:30 rick_soc I looked at the code, it has a pretty small footprint
15:31 rick_soc It's not available in yum and I was trying to avoid compiling it via cpan so I copied the .pm from github but that didn't work so well :]
15:31 genio ah. that's a different problem, rick_soc. When working with EL, you need to have your own local::lib setup for your app at least.
15:32 genio I tend to Perl::Build a version particularly for the app I'm working on.
15:32 sri it's a little sad that the I18N plugin has not been updated in a long time
15:33 sri would have been nice to get support for po files
15:33 genio The code doesn't look overly complicated
15:33 sri it's not, the lexicon detection code is still a bit sketchy
15:34 sri that's the part that got it removed from core
15:35 Vandal sri, I'm confused now, why would $c->stash->{c} = $c; increase performance cost if it would be turned into local var $c with controller object here https://github.com/kraih/mojo/blob/master/lib/Mojo/Template.pm#L264 just like my $c = _C; here https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/EPRenderer.pm#L18 ?
15:36 sri Vandal: and how would helpers work then?
15:37 rick_soc hmm.  My project has an internationalization requirement and if there are no alternatives then the only choice I have is to fork it and update it
15:39 sri try to send pull requests
15:41 PryMar56 joined #mojo
15:41 rick_soc I'm a github noob but I'll give it a try
15:42 wouter joined #mojo
15:42 wouter hi -- i'm trying to write a command dispatcher
15:43 wouter it would sit there, waiting for mojo::pg::pubsub events, and run particular commands when a notification is received
15:43 wouter and do nothing else
15:43 wouter I'm trying to figure out what the best way to do that is
15:44 jberger rick_soc: are you experiencing problems with it or was it just the availability?
15:44 wouter I was thinking of mojolicious::command, but that doesn't seem to start an event loop, unless I'm reading the documentation wrongly?
15:44 sri wouter: this example uses an event emitter, you could make up your own events for that https://github.com/kraih/mojo/blob/master/examples/chat.pl#L4
15:45 sri mojochat is an arbitrary event https://github.com/kraih/mojo/blob/master/examples/chat.pl#L17
15:45 wouter sri: that runs a websocket and therefore a full webserver though
15:45 wouter I don't need that, just need an event loop and nothing else
15:46 sri Mojo::IOLoop->start;
15:46 wouter (if that can't be done, I can probably deal with it, but it seems overkill)
15:46 sri and done :)
15:46 wouter oh, heh
15:48 rick_soc jberger: problems with what?
15:49 jberger "if there are no alternatives then the only choice I have is to fork it and update it"
15:49 jberger does it not work as-is?
15:49 jberger (I don't use it, I'm really just curious)
15:50 rick_soc That is based on sri's comment that some of the code is sketchy, if I need to depend on it in my project then I would like to address any quirks in the code
15:51 rick_soc Back to the my very first question, I actually don't know if it works as-is yet, I have not successfully installed it
15:51 sri it should work reasonably well
15:51 rick_soc I don't know enough about this framework yet to know how to just copy/paste it from github into files, so I wanted to make sure it was worth firing up cpan for it
15:51 sri my comment about sketchy code was regarding some of the parts i originally wrote
15:52 sri for which i never found a better solution
15:52 Vandal sri, like here https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/EPRenderer.pm#L51 only changed from  $class->_C->$sub(@_) to  "$class::c"->$sub(@_)
15:52 rick_soc I was able to load the pm in my app but then it died on trying to use _helper
15:53 rick_soc Which is probably really simple to fix but my understanding of how hasn't matured to that level yet
15:58 jberger I don't see _helper
15:58 jberger can you paste (to a paste site) the error you get?
16:03 sh14 joined #mojo
16:04 rick_soc Sorry I mean get_handle
16:04 rick_soc here you go https://pastebin.com/6qNicb1X
16:06 Grinnz rick_soc: copying cpan modules manually is insane. it was already mentioned that you can use a local::lib to install the modules locally
16:07 sri there might be a bug in Mojo::IOLoop->reset
16:07 sri it doesn't reset the events
16:07 sri Mojo::IOLoop->singleton->on(finish => sub {...})
16:08 sri that would survive into a subprocess
16:08 jberger oh, its own events? yeah I can see that
16:08 jberger those should probably be scrubbed
16:08 jberger does the reactor emit events? if so those too I guess
16:09 sri yes, an error event
16:09 purl it has been said that an error event is for exceptions that can't be connected to a specific operation
16:09 sri and agreed
16:10 jberger rick_soc are you supposed to implement get_handle in your class? (sorry I don't know the protocol around I18N, maybe someone else knows?)
16:24 rick_soc Grinnz: It's from github, and there is literally just 1 .pm in the project, otherwise I agree I wouldn't have tried it
16:24 Grinnz it's still insane. you should always install perl modules with a cpan installer, no exceptions
16:25 rick_soc jberger:  ¯\_(ツ)_/¯
16:25 Grinnz (or distribution packages if applicable)
16:25 sri add a local lib to your project if you have to
16:25 rick_soc It's there
16:25 Grinnz cpanm -l local/ Foo::Bar
16:25 Grinnz this installs Foo::Bar to local/lib/perl5
16:25 Grinnz which you can then add to @INC in whatever way
16:26 sri as in https://metacpan.org/pod/local::lib
16:26 sri what Grinnz said
16:26 Grinnz carton makes this process per-project more defined
16:26 Grinnz but this is the basic way
16:26 rick_soc Oh speaking of metacpan, how do I install that
16:26 Grinnz uh
16:26 rick_soc I do not see metacpan or cpanm in my repos
16:27 Grinnz metacpan is a cpan search engine
16:27 rick_soc And everyone keeps telling me to stop using cpan
16:27 Grinnz cpanm can install itself
16:28 Grinnz wget -qO - https://cpanmin.us | perl - App::cpanminus
16:28 rick_soc ok thanks much
16:28 Grinnz https://metacpan.org/pod/App::cpanminus#Installing-to-system-perl
16:28 Grinnz normally i wouldn't recommend installing with sudo to system perl, but cpanm is one exception that works fine
16:29 Grinnz it's pure perl, no dependencies, and the system won't be depending on it to be there
16:31 Grinnz if you were referring to search.cpan.org, just use https://metacpan.org instead
16:31 Grinnz neither of those are "cpan", they are cpan search engines
16:32 Grinnz the s.c.o. branding confuses the matter a bit
16:32 bianca joined #mojo
16:47 good_news_everyon joined #mojo
16:47 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vQj1X
16:47 good_news_everyon mojo/master 8262828 Sebastian Riedel: fix bugs in Mojo::IOLoop and Mojo::Reactor::Poll that would prevent a reset from clearing events
16:47 good_news_everyon left #mojo
16:51 rick_soc That's it, working.  Perfect.  Thanks for everyone's hepl.
16:51 rick_soc And also help.
16:59 zivester joined #mojo
17:07 rick_soc sri: "would have been nice to get support for po files" <- Is there something preventing it from supporting po now?
17:07 sri rick_soc: the code for it is missing
17:08 sri Locale::Maketext::Lexicon needs to be used
17:09 rick_soc It would still work when specified in url, correct?  I just created 6 language files and they all tested fine, I assume creating a po.pm would work as well?
17:12 rick_soc Oh you're not talking about po language are you
17:12 rick_soc :]
17:13 rick_soc whoops
17:14 rick_soc What is the advantage of using .po files?  (This is my first crack at I18N stuff so I am unfamiliar)
17:19 bianca joined #mojo
17:20 esh joined #mojo
17:39 dod joined #mojo
17:42 Vandal sri, what about my question? will it work?
17:42 Vandal or will it evetually blow up
17:54 dod joined #mojo
17:55 sri Vandal: have you actually tried it?
17:59 bianca joined #mojo
18:06 Vandal sri, yes
18:07 Vandal it works
18:09 sri Vandal: patch?
18:09 purl Patches welcome!
18:09 Vandal sri, what?
18:09 purl sri, is under effectively $r->bridge('/')->to(cb => sub{});
18:10 pink_mist yes purl
18:10 sri Vandal: everything you've shown so far does not work
18:10 sri so, i'm assuming you forgot to share your diff
18:11 tchaves joined #mojo
18:12 Vandal sri, sorry if I misslead you, I'm not trying to change mojo, I'm using EPREnderer as an example to make renderer for my home-made template
18:12 Vandal and trying to avoid monkey_patch to do it
18:13 Vandal cuz I cant understand it
18:14 Vandal so basicaly my code is *{$settings->{namespace} .'::url_for'} = sub {$c->url_for(@_)};
18:22 preaction isn't url_for a helper? which can be overridden
18:23 preaction oh, sorry, that's in your template generator. ignore me
18:24 Vandal its just for testing idea
19:10 dod joined #mojo
19:34 quiggle joined #mojo
20:05 rshadow joined #mojo
20:12 itaipu joined #mojo
20:55 PopeFelix joined #mojo
22:02 PopeF joined #mojo
22:37 mgrimes joined #mojo

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