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

IRC log for #mojo, 2016-01-25

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

All times shown according to UTC.

Time Nick Message
01:53 kaare joined #mojo
02:22 Kogurr joined #mojo
02:30 binlei joined #mojo
03:40 jasanj joined #mojo
03:41 jasanj Hi all, I'm trying to use Mojo to build a web site, here is my question:
03:42 noganex_ joined #mojo
03:43 jasanj I'm using Mojolicious::Lite, how can I get the 'controler' in my Model/*.pm
03:44 jasanj actrually I want get to config by using app->config('') in my Model/*.pm, but not work
03:44 preaction if your model is a plugin, you'd get a copy of the app in the register() sub. that might be the best way to do it
03:45 preaction otherwise, you could make your model into a helper that registers and gives the app its config
03:46 jasanj my model just like this example of Mojo::SQLite
03:46 jasanj https://metacpan.org/source/DBOOK/Mojo-SQLite-0.019/examples/blog/lib/Blog/Model/Posts.pm
03:46 jasanj not using plugin I think
03:47 preaction see how it "has 'sqlite';"? you could add another thing, "has 'config';" or "has 'app'"; and give it the config or app when you create the object
03:48 jasanj thanks, preaction :)
03:59 inokenty-w joined #mojo
04:20 binlei joined #mojo
04:27 binlei joined #mojo
04:32 c--_ joined #mojo
04:36 binlei joined #mojo
04:38 binlei joined #mojo
04:53 irqq joined #mojo
05:09 Shaeto joined #mojo
05:13 Shaeto left #mojo
05:22 binlei joined #mojo
05:38 binlei joined #mojo
05:58 jberger getting close: https://github.com/jberger/Mojolicious-Plugin-ACME/blob/master/lib/Mojolicious/Plugin/ACME/Command/acme.pm
05:59 jberger so the idea is that your app uses the plugin
05:59 jberger the plugin adds a route and a command
05:59 jberger the route handles the challenge request
06:00 jberger the command does all the acme protocol stuff and when it comes time for the challenge, the app's route makes a request to the command's server to get the response it should pass forward
06:01 jberger in this way you don't need to modify your running server at all in order to respond to the challenges
06:45 binlei joined #mojo
06:46 ashimema joined #mojo
06:55 dim2 joined #mojo
07:29 McA joined #mojo
07:30 dod joined #mojo
07:35 dod joined #mojo
07:47 sugar joined #mojo
08:11 salva joined #mojo
08:15 Vandal joined #mojo
08:20 trone joined #mojo
08:23 osfabibisi joined #mojo
08:36 mtths joined #mojo
08:46 AndrewIsh joined #mojo
08:52 dim2 joined #mojo
08:52 zivester joined #mojo
08:53 odc joined #mojo
08:56 kes joined #mojo
08:58 jontaylor joined #mojo
09:14 berov joined #mojo
09:33 n16gel joined #mojo
09:41 CandyAngel It's still really weird looking at my old code.. so much whitespace x.x
09:41 batman CandyAngel: \t ? :)
09:42 CandyAngel No.. if ( $Element -> type == 1 ) {
09:42 CandyAngel vs
09:42 CandyAngel if ($element->type == 1) {
09:42 batman oh.
09:42 batman never understodd " -> "... -> is already more verbose than "."
09:44 CandyAngel I used to find the former more readable.. but now I don't :\
09:47 CandyAngel Unfortunately, I'm looking at it because a major bug has been discovered >.<
09:47 berov joined #mojo
09:50 CandyAngel Basically, a certain bit of (garbage) input makes it exit... but there is an END block which runs anyway, which makes it look like it completed successfully
09:51 CandyAngel But it exits halfway through creating the output, so *everything* looks fine -.-
10:00 Shaeto joined #mojo
10:15 cpan_mojo Mojo-Weixin-1.0.0 by SJDY https://metacpan.org/release/SJDY/Mojo-Weixin-1.0.0
10:37 sue joined #mojo
10:49 punter joined #mojo
11:25 kaare joined #mojo
11:41 ilbot2 joined #mojo
11:41 Topic for #mojo is now ???? cheers | http://mojolicio.us | http://irclog.mojolicio.us | http://code-of-conduct.mojolicio.us
12:03 vanHoesel joined #mojo
12:06 dim2 left #mojo
12:13 asarch joined #mojo
12:27 jberger CandyAngel: that's a danger of end blocks
12:28 jberger That's why you don't do END { done_testing }
12:37 CandyAngel jberger: Yeah, the new version won't have end blocks (and will create outputs in a temp file and move them)
12:37 CandyAngel Lessons have been learned :P
12:41 CandyAngel It's also going to be a Mojo app :P Working nicely so far :)
12:44 CandyAngel Though I have dropped my idea of having all the importing and such be done automatically by plugins (for now)
13:00 ajr_ joined #mojo
13:01 binlei joined #mojo
13:04 binlei joined #mojo
13:11 binlei joined #mojo
13:28 binlei joined #mojo
13:29 mcsnolte joined #mojo
13:50 n16gel joined #mojo
14:06 zivester joined #mojo
14:23 mspo left #mojo
14:23 CandyAngel Hm.. are there any recursive uses of find_modules? I'm not sure of the most Mojo way of setting up what I am trying to do..
14:42 n16gel joined #mojo
14:42 jb360 joined #mojo
14:44 go|dfish joined #mojo
14:45 marty joined #mojo
14:50 neilhwatson joined #mojo
15:15 sawtooth joined #mojo
16:20 lluad joined #mojo
16:23 zivester joined #mojo
16:23 CandyAngel I decided against making it recursive :P I just had it scan over $self->namespaces instead
16:23 CandyAngel And put all the "top" level ones in there
16:26 andrew_ joined #mojo
16:28 gryphon joined #mojo
16:33 sue joined #mojo
17:33 inokenty-w joined #mojo
17:37 ajr_ joined #mojo
17:52 Kogurr joined #mojo
17:54 Perl627 joined #mojo
17:56 Perl627 hi, I'm getting the error "EV does not work with ithreads." on my raspberry pi platform with latest mojo debian jessie package installed. I added the line $ENV{MOJO_REACTOR} = "Mojo::Reactor::Poll"; into my code, but it doesn't fix the issue. It's strange that it worked when I installed the mojo package with cpanm
17:57 Perl627 is there anything else I need to configure to "fix" that error?
17:58 vanHoesel1 joined #mojo
17:58 Grinnz_ Perl627: where did you add it? it must be before any module using Mojo::IOLoop is loaded
17:59 Grinnz_ in a BEGIN {} if it's loaded with "use"
17:59 Grinnz_ you can also set the env var before running the scripts
17:59 preaction are you doing "use threads" anywhere in your application?
18:01 Grinnz_ see https://metacpan.org/pod/Perl::Critic::Policy::Freenode::Threads about using ithreads.
18:01 Perl627 Grinnz_: I just set it before the Mojo::UserAgent->new() which is the first use of mojo. I'm going to try it before use Mojo...
18:02 Grinnz_ that's not enough. the reactor is set as soon as Mojo::IOLoop is loaded
18:02 Grinnz_ it must be in a BEGIN {}
18:02 Perl627 preaction: yes, I have "use threads;" as well in place
18:02 Grinnz_ and before any use statement that loads the ioloop
18:02 preaction that's a problem
18:03 preaction because EV does not work with threads (ithreads is "interpreter threads", and is what "use threads" gives you)
18:03 Grinnz_ it works with Coro! but nothing else does <_<
18:03 preaction including Perl, now :p
18:03 disputin joined #mojo
18:03 nchambers with Mojo::DOM, I want to find all div tags that have a specific class name "C_forThread". I currently have ($dom->find("div[class]")->each). is there a way to specify that classname?
18:04 Grinnz_ div.class
18:04 Perl627 preaction: it was working already when I installed the modules with cpanm. maybe a different version is installed than the debian jessie one
18:04 Perl627 Grinnz_: cool....BEGIN { $ENV{MOJO_REACTOR} = "Mojo::Reactor::Poll"; } did the trick :)
18:05 Perl627 many thx!
18:05 preaction EV has likely never, ever worked with threads. forcing the mojo reactor to be Mojo::Reactor::Pool means you are no longer using EV
18:05 Grinnz_ please read my other link about ithreads as well.
18:06 Grinnz_ as you're already using an event loop, there's likely a better solution using either the loop or forking
18:06 nchambers Grinnz_, thanks!
18:06 nchambers am I actually going to want to do div.class, or div.the_name_of_the_class_here?
18:06 Grinnz_ yes the name of the class
18:06 nchambers thanks!
18:06 Perl627 ok, that means I just discard the usage of threads in perl
18:07 Grinnz_ Perl627: yeah thats the general idea
18:07 preaction Perl627: because generally using fork, in its various forms, ends up being better
18:07 Grinnz_ nchambers: https://metacpan.org/pod/Mojo::DOM::CSS#E.warning
18:07 Grinnz_ the other recognized CSS selectors are also documented there
18:07 nchambers thanks I'll read that
18:08 Grinnz_ you wouldn't use ->select, but it's the same argument you pass to ->find or ->at
18:08 preaction nchambers: here's a little game to play to learn css selectors: http://flukeout.github.io
18:08 nchambers Grinnz_, right
18:08 Perl627 preaction: can I still use threadqueues to communicate between the processes if they are forked?
18:09 Grinnz_ no
18:09 preaction as in the Thread::Queue module? no, you'd need something else, like SysV queues, ZeroMQ, pipes, or otherwise
18:09 Grinnz_ but first decide whether forking is what you need
18:09 jberger Perl627: what is it that you are doing?
18:10 preaction oh, or Mercury, that's a thing too
18:10 Perl627 actually I'm just writing a module for an already existing software (fhem.de - home automation). I just implemented a module which is connecting to the Bose Soundtouch system websocket to receive events and therefore I'm using mojo as the websocket connector
18:13 jberger and the rest of it already uses threads?
18:13 jberger yeah, you know, you probably don't need EV anyway
18:13 jberger for that application, poll is probably fine for you
18:14 jberger recently poll has gotten to relatively comparable speeds as EV
18:14 jberger the only reason to need EV is for large numbers of file handles
18:14 jberger which you aren't going to have thousands of connections on your socket
18:15 Perl627 some modules are using threads already. the application itself is currently not using any threads at all, there is just the main loop where all modules are loaded and events are forwarded to that modules
18:15 Perl627 ehm, no, just 1 connection otherwise the Bose Soundtouch player might get problems ;)
18:17 Perl627 currently the architecture of that software doesn't allow any long running actions, therefore I used threads to have a upnp & bonjour discovery thread.
18:22 bwf joined #mojo
18:28 Perl627 btw, how can I start the useragent connection without using the blocking Mojo::IOLoop->start? Can I use some sort of Mojo::IOLoop->receive (non-blocking) which calls the callbacks (on => message) afterwards?
18:31 Grinnz_ you must use the mojo ioloop for nonblocking useragent calls
18:32 Grinnz_ but the mojo ioloop can use different backends, if you're running a different event loop
18:42 jberger Perl627: there is no explicit condvar-style interface
18:43 jberger condvars are the devil
18:43 sri jberger: condvars aren't magic
18:43 sri they block too
18:43 jberger yes, but the reliance on condvars, especially in libraries I've tried to use, makes other non-blocking work very hard
18:44 jberger its why it seems I can rarely just use AnyEvent::SomeSeeminlyUsefulLibrary
18:45 sri those modules are broken then
18:45 jberger probably
18:47 jberger am I wrong to think that condvars are often used as a crutch though?
18:47 dod joined #mojo
18:48 sri when such a module calls ->recv on the condvar, it's broken
18:48 sri everything else should be just fine
18:48 jberger perhaps I've just had bad luck in finding modules then
18:48 sri (assuming you meant ->recv, otherwise you're the one using condvars wrong ;p)
18:49 jberger I wish I could remember the name of the one I'm thinking of
18:49 jberger something from $job[-2]
18:49 sri $condvar->recv is basically Mojo::IOLoop->start
18:49 sri (with return values, which is horrible)
18:50 sri we had that once with the old $delay->wait
18:50 * sri shudders
18:50 Perl627 if there is no way to trigger the mojo ioloop from extern, how can I send something via a websocket? I would need to define the msgs I would like to send before Mojo::IOLoop->start
18:50 PryMar56 joined #mojo
18:51 sri http://mojolicious.org/perldoc/Mojolicious/Guides/FAQ#What-is-an-event-loop
18:54 Perl627 I think I still didn't get it...if the event is triggered by the user, I can't send such an event to the ioloop. I understand that I can define the callbacks and use there some send() code or do Mojo::IOLoop->recurring, but what if the user defines the input for the websocket during runtime!?
18:55 sri sounds like you need to learn more about how to use an event loop
18:55 sri sadly we don't have a tutorial for that yet
18:59 Perl627 you are right I'm not an expert in event loops yet ;) I thought I could register somewhere at the ioloop so that it calls my code where I would check for input...let me google some more..
19:00 dod1 joined #mojo
19:00 sri you're prolly still imagining some sort of magical behavior, but in the end you will have to call Mojo::IOLoop->start and think of it as a while (1) {...} that takes over your process
19:01 sri it's how everyone starts out
19:01 jberger I think I was the one that advocated removing the return values of ->wait
19:03 Perl627 the issue I have is that I have 2 event loops in place. one from the main application and the other from mojo. and in my case I need to send events from the main application to the mojo loop
19:03 sri there can be only one
19:03 sri event loops are the highlander
19:05 Perl627 therefore I created a thread ;) I know, it's an ugly way, but I can't change the main loop and I couldn't find something non-blocking in mojo for websockets
19:06 sri that could be fine
19:06 jberger Perl627: what type of loop is the main loop?
19:08 Perl627 https://github.com/mhop/fhem-mirror/blob/master/fhem/fhem.pl#L577
19:09 sri ouch
19:09 * Grinnz_ winces
19:10 Perl627 it's not something I implemented, but I need to stick to it as I don't want to re-create the whole fhem application
19:10 Grinnz_ this reminds me of a script i saw from a contractor, but with more prototypes
19:11 neilhwatson Sure, knock the contractors ;)
19:11 Grinnz_ just that one in particular :P
19:13 jberger my refactor-all-the-things ocd is going berserk
19:13 jberger must. stop. reading.
19:13 Grinnz_ lol
19:15 jberger still in general that's an IOLoop
19:16 jberger you could in theory call Mojo::IOLoop->one_tick at the end of that
19:17 jberger Perl627: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Web-server-embedding
19:37 Perl627 I think one_tick might work for me, thx!
19:49 absolut_todd joined #mojo
19:50 punter joined #mojo
19:51 n16gel joined #mojo
19:56 Perl627 cu, thx again for you help!
19:57 Grinnz_ scripts like that are where everyone's perl hate comes from :/
20:01 jberger sigh
20:05 neilhwatson Because somehow, it is Perl's fault.
20:07 jberger and indeed we fixed his problem with one line
20:22 * sri still can't get over that horrible new rails logo
20:22 kablamo joined #mojo
20:23 tyldis Currently refactoring a big single script mess similar to that into microservices.
20:24 genio ugh.  and hasn't red always been a no-no color for logos and such?
20:24 tyldis Our whole production line was going through it, callings subs all over the place, with dozens of hardcodes and special cases.
20:25 sri i like the red ruby logo
20:25 Grinnz_ tyldis: fun
20:26 tyldis Grinnz_: Well, it actuallty is as it will soon start worign as intended and not as someone hoped...
20:26 tyldis Hmm.. My keyboard isn't cooperative today
20:27 Grinnz_ well, i usually find refactoring fun, non-sarcastically
20:27 Grinnz_ if i can get the time to do it
20:28 Grinnz_ the best part, is git rm old_code :)
20:28 tyldis In this case I get to play with new things and learn stuff. Like Mojo.
20:36 good_news_everyon joined #mojo
20:36 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vzP0q
20:36 good_news_everyon mojo/master 6f79a68 Sebastian Riedel: improve a few examples to avoid timing attacks
20:36 good_news_everyon left #mojo
20:38 sri so easy to miss that attack vector
20:43 sri hmm, i hope that doesn't give the impression we recommend hardcoding passwords... :S
20:44 * sri shrugs
20:47 jberger its an example
20:53 sri until it ends up in a ccc talk bashing perl ;p
20:53 genio heh
20:58 mullagain joined #mojo
21:02 c--__ joined #mojo
21:02 ajr_ joined #mojo
21:11 zivester_ joined #mojo
21:35 jb360 joined #mojo
21:55 disputin joined #mojo
21:57 cpan_mojo Dist-Zilla-Plugin-Stenciller-MojoliciousTests-0.0101 by CSSON https://metacpan.org/release/CSSON/Dist-Zilla-Plugin-Stenciller-MojoliciousTests-0.0101
22:03 sue joined #mojo
23:06 lluad_ joined #mojo
23:11 lluad joined #mojo
23:11 sugar_ joined #mojo
23:19 sri argh, the first photo of a mojolicious sticker in the wild is just a tiny thumbnail :S https://twitter.com/s1037989/status/691760545440075776
23:32 lluad joined #mojo
23:43 sue joined #mojo
23:47 lluad joined #mojo
23:55 berov1 joined #mojo
23:57 binlei joined #mojo

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