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

IRC log for #mojo, 2018-01-08

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

All times shown according to UTC.

Time Nick Message
00:19 marty joined #mojo
00:47 hesco1 Grinnz: I use Moose; extends 'Vote', 'Mojolicious::Controller';
00:48 mohawk and Vote has "use Mojo::Base 'Mojolicious';"
00:48 mohawk so its inheritance will hit Mojolicious first
00:49 mohawk (from the perlmonks article)
00:49 hesco1 and you are saying that should be ::Controller, instead?
00:50 mohawk i'm not a mojolicious expert
00:50 mohawk i think probably Vote would inherit from M::Controller
00:50 mohawk and i'm guessing the other controller also would
00:51 mohawk and as far as i know (someone correct me) the two controllers wouldn't have any "isa" relationship
00:51 mohawk they might both consume other code, such as roles, or models, or similar
00:51 mohawk in fact, re-reading - you only have one controller
00:51 mohawk so Vote is an app, and should inherit from Mojolicious
00:52 mohawk V::C::User::Login is a controller, and should inherit from M::Controller
00:52 mohawk but if i understand things right, VCUL has no business inheriting from V
00:53 hesco1 Vote is a Moose class with attributes which provide me access to configuration and database handles and other useful tricks.
00:54 mohawk but you've also made it be a Mojolicious app
00:54 hesco1 yes, I am told they know how to play well together.
00:54 mohawk cool, where did you read that?
00:55 hesco1 This is my first time out with this architecture, so we shall see.
00:56 hesco1 mohawk: this is what gave me hope: https://stackoverflow.com/questions/30804829/do-mojolicious-and-moose-play-well-together#30809096
00:57 mohawk so that is doing what i suggested
00:57 mohawk no "isa" relationship between the app and controller
00:57 mohawk if you want them both to consume a role with config, db handles etc, go ahead
01:00 hesco1 as I am getting a better handle on roles in the Moose framework, it might make sense to refactor that code as a Role.  At the moment, they are simply attributes of the class.
01:02 hesco1 so having talked through this, I am hearing that you advocate no change in my current code; and that I still have no clue why the ::User::Login is getting doubled up in the router.
01:11 mohawk your current code has VCUL "isa" V, yes?
01:13 mohawk if so, *do* change your code and stop it doing that
01:13 mohawk per my suggestion 16 mins ago
01:16 genio joined #mojo
01:17 hesco1 mohawk:  ok, I see this in my new test:  ok 1 - An object of class 'Vote::Controller::User::Login' isa 'Vote'
01:18 dotan_convos joined #mojo
01:18 hesco1 is it the extends 'Vote' which does that?  And if so, how do I access those db and cfg attributes, if I am not inheriting from Vote?
01:18 mohawk that's literally what "extends" does
01:19 mohawk move that code into a role
01:19 mohawk have both classes "with" that role
01:19 hesco1 ok, trying that next.
01:20 Leffe joined #mojo
01:21 marty joined #mojo
01:30 marty joined #mojo
01:39 Grinnz hesco1: Vote inherits from Mojolicious, controllers should only inherit from Mojolicious:: Controller. you can access the app in the controller actions as $self->app and you can add helpers that will be added as methods on both controllers and the app.
01:40 Grinnz there's no need for any other complication
01:40 Grinnz it's common to register configuration and database handles and such as helpers
01:43 Grinnz the problem is that inheriting from Mojolicious makes it a separate app, so you are overcomplicating your routing with that in there
01:43 Grinnz roles are great too so if you want to do it that way go for it
01:44 Grinnz but helpers are more "automatic" for things that will be used by various controllers
01:45 Leffe joined #mojo
02:45 marty joined #mojo
03:04 ilbot2 joined #mojo
03:04 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
03:33 Seth joined #mojo
04:40 ghenry joined #mojo
05:04 dboehmer joined #mojo
05:28 sh14 joined #mojo
06:21 ghenry joined #mojo
06:24 karjala_ joined #mojo
06:50 disputin joined #mojo
06:59 findow joined #mojo
07:02 ghenry joined #mojo
07:16 McA joined #mojo
07:22 Vandal joined #mojo
07:54 dod joined #mojo
07:58 dod joined #mojo
08:05 dod joined #mojo
08:15 trone joined #mojo
08:53 rcz joined #mojo
08:56 rcz Can I pass the entire stash to a partial view? I'm loading a view which is part of a layout. The layout includes a navbar, but the navbar needs some of the same data from the stash (display username, know which menu is active, etc.)
08:58 coolo joined #mojo
09:00 Grinnz the entire stash is passed to any template, minus any hidden keys
09:43 mohawk Grinnz, nice explanation. thanks
09:43 mohawk so helpers do what "roles" would do in a Moo*-ish set of s/w
09:44 coolo joined #mojo
09:56 sivoais joined #mojo
10:08 coolo joined #mojo
10:08 tyldis I guess that's one way to look at it
10:16 mohawk but there's the additional option of just calling app->my_funky_method
10:25 coolo joined #mojo
10:45 sivoais joined #mojo
11:02 mohawk hesco1, ^
11:16 tchaves joined #mojo
11:16 mohawk here's a cute JSON->YAML converter: perl -Mojo -MYAML::XS -e 'print Dump j f(shift)->slurp' $FILENAME
11:24 mohawk more sensible handling of booleans though: perl -Mojo -MYAML::XS -e '$YAML::XS::Boolean = "JSON::PP"; print Dump j f(shift)->slurp' $FILENAME
11:36 Atomics joined #mojo
11:42 FROGGS joined #mojo
11:42 mderasse joined #mojo
11:42 mderasse joined #mojo
11:45 mderasse Hi, I'm using Mojo Lite and i'm trying to find a way to get the url of the request made by the client. I tried with the ->url but Mojo::URL is removing some char (like /api/v1/object?test=1&, the & will not show up).
11:55 FROGGS well, the ampersand should not matter in most cases, because it is a request param separator, and in this example there is nothing to separate
11:56 FROGGS but if you really need it, you should be able to inspect the request headers
11:57 FROGGS I have a question about hypnotoad and websockets... when I try to hot deploy changes, the deployment fails as long as there are active websocket connections
11:58 FROGGS how can I close all websocket connections on hot deployment? or can I tell hypnotoad to ignore active websocket connections?
11:58 FROGGS or is there a better way of doing it?
12:05 Leffe joined #mojo
12:09 jberger FROGGS it shouldn't fail because of websocket connections
12:10 jberger Those should eventually be killed
12:10 FROGGS but I can reproduce
12:11 FROGGS I'll describe in a minute
12:11 pink_mist are you on latest version of mojolicious? (who knows, there may have been fixes committed, or possibly if the answer is yes, maybe new bugs? :P)
12:11 jberger http://mojolicious.org/perldoc/Mojo/Server/Hypnotoad#graceful_timeout
12:12 jberger Is it possible that you have set upgrade_timeout less than graceful_timeout?
12:15 mohawk has anyone ever suggested perl -Mojo=YAML, which would "with" ojo::Role::YAML? (for providing eg a "y" that acts like "j")
12:15 FROGGS I'm on 7.36
12:21 jberger mohawk I don't think anyone has come up with a clean way to extend ojo
12:21 FROGGS this is my log: https://gist.github.com/FROGGS/40cd33acea2e4b71a44a33fea514f1f9
12:21 jberger I'd be interested tho, my ojoBox module would benefit
12:22 pink_mist perl -Mojo=Box?
12:24 jberger FROGGS plenty interesting in there
12:24 pink_mist I'm not sure how much nicer that is compared to just perl -MojoBox
12:24 jberger pink_mist but not composable
12:25 jberger If that mattered
12:25 pink_mist right, that's a good point
12:25 pink_mist you mean like perl -Mojo=YAML,Box
12:25 jberger Yeah
12:26 jberger I need to add Mojo::File support to it too
12:26 pink_mist mohawk: I'd say add a feature request in the issues, I'll certainly +1 it :)
12:26 pink_mist (if you link it here so I see it)
12:26 jberger I doubt anyone actually uses ojoBox but it is fun to play with
12:28 jberger FROGGS so it looks like you have graceful timeout set to 60 as well?
12:33 dod joined #mojo
12:34 FROGGS I'm not sure, how can I check?
12:34 FROGGS I dont see a place where I specify the timeouts at all
12:36 jberger it'd be in your hypnotoad config block
12:37 jberger I'm also curious about reuse being involved
12:38 FROGGS but you need reuse for hot deployment, no?
12:38 jberger No
12:38 FROGGS I thought so
12:39 jberger I can't imagine that's necessary as reuse support came much later than hypnotoad
12:41 FROGGS http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Zero-downtime-software-upgrades
12:42 jberger That's using prefork and reuse
12:42 jberger If you use hypnotoad that's not needed
12:43 jberger I see the confusion there tho
12:44 jberger Something like "as an alternative to hypnotoad ..."
12:44 FROGGS so I shall just try without reuse?
12:52 FROGGS hmm, no, does not seem to help
12:52 FROGGS I restarted my hypnotoad so that the service is running without reuse option enabled
12:52 FROGGS then, hot deployed, and got again: [error] Zero downtime software upgrade failed
12:53 FROGGS and I know that websocket connections are involved because on hot deployment not all workers shut down
12:54 FROGGS and when I refresh the page on a client, on worker goes down because the client shuts down the websocket session
12:54 FROGGS and when I do that on all client, the manager goes down and the hot deployment succeeds
12:55 jberger Something definitely not right there
12:56 jberger Are you also getting lots of heartbeat timeouts?
12:56 ghenry joined #mojo
12:57 FROGGS no, last time on December 7th
12:57 jberger though if you were blocking the loop the websocket wouldn't work
12:58 jberger Does your application trap signals?
12:58 FROGGS it does not
12:59 jberger Do the websocket handlers make subprocesses?
12:59 FROGGS I'm not doing a fork there or somthing, just some pg->pubsub stuff
13:00 FROGGS bbi5
13:04 FROGGS_ joined #mojo
13:21 mohawk jberger, pink_mist - then Box would become ojo::Role::Box
13:33 mohawk really i just want it for ::Role::YAML so i could use "y" for my one-liner above :-)
13:34 CandyAngel Minion jobs can only be enqueued to one queue, but a worker can dequeue from multiple.. is that right?
13:40 sri FROGGS_: that would be a bug
13:40 FROGGS_ sri: I'm upgrading soon, and will retest
13:40 sri CandyAngel: yes
13:41 mohawk jberger, pink_mist - https://github.com/kraih/mojo/issues/1181
13:41 FROGGS_ if that does not help, I'll provide a self-containting testcaase
13:41 * sri still got the flu and won't be doing much investigating this week, so open issues need volunteers!
13:41 * sri sneezes
13:41 mohawk sri, get well soon
13:41 FROGGS_ sri: bless ya'
13:41 jberger sri wow, still?!
13:42 CandyAngel sri: Thankies for confirming
13:42 jberger Hope it's almost over
13:49 sri me too, don't even remember the last time i was sick more than three days :S
13:50 gizmomathboy joined #mojo
13:56 marty joined #mojo
13:57 marty joined #mojo
14:02 dod joined #mojo
14:16 trone joined #mojo
14:25 rcz Anyone know of a guide to write plugins and registering them? I'm having a lot of trouble making my application find my plugin.
14:30 stokachu joined #mojo
14:35 rcz Actually, I just had the plugin in the wrong location. Another question, though. Should I not be able to access the config plugin like this?: http://ix.io/DO9
14:36 dod joined #mojo
14:36 jberger rcz you should, however, you don't need to close over the application like that
14:36 CandyAngel Isn't it cusotmary to not directly read the config from within the plugin, but accept a configuration hash that is passed in from the app?
14:36 jberger CandyAngel: I usually do both
14:37 jberger accept pass in config and if not present check the app config
14:37 jberger but it depends on use-case of course
14:38 jberger rcz: also, do $file is a little tricky especially since the removal of dot-in-@INC
14:38 jberger you might want to be a little careful about location
14:38 jberger and indeed your file must be setting %hash ... which is a little odd
14:39 rcz I know it's not pretty.. It was just a quick fix. Apparently NMIS stores its configuration in a file like: %hash = ();
14:39 jberger ah, ol
14:39 jberger ok
14:39 rcz what do you mean I don't need to close over the application
14:39 haarg do File::Spec->rel2abs($fileName)
14:39 jberger haarg: or relative to the app home
14:39 jberger rcz: since it is a helper, its invocant is a controller
14:40 karjala_ joined #mojo
14:40 jberger so my $c = shift; $c->app->config->...
14:40 rcz jberger: alright, I changed it to that
14:40 rcz and it works now :) thanks
14:41 jberger odd that it didn't before
14:41 jberger but ok
14:41 rcz what's the point of getting both $self and $app in register? it was in the example so I just added it
14:41 gryphon joined #mojo
14:42 pink_mist so you have access to them if your plugin needs them
14:42 jberger you need $app in order to add the helper
14:42 rcz so I don't really need them if I'm just registering helpers..
14:42 rcz ah ofc
14:42 jberger but closing over it is problematic (though it should have worked in your case)
14:43 jberger but yeah, best to avoid unnecessary closures
14:43 haarg File::Spec->rel2abs($fileName, $app->home) # if you wanted the file to be relative to the app root
14:44 jberger or $app->home->child($fileName)
14:44 rcz I don't, but thank you
14:44 Leffe joined #mojo
14:47 haarg jberger: that will treat absolute paths as relative to the app root
14:48 haarg rel2abs will leave absolute paths alone
14:48 jberger yeah, I guess I was too short with mine
14:48 jberger usually check for absoluteness first
14:48 jberger ok carry on :-P
14:48 maschine joined #mojo
14:55 rcz what'd be a good way to only expose this functionality in the current controller instead of a helper that's available to the entire application?
15:00 rcz I need to do some authentication that checks a file first, then if the user doesn't exist here, check through LDAP, and if it's there, add it to the file, return 1. This seems a bit heavy to just have in my controller subroutine
15:01 Leffe joined #mojo
15:02 Pyritic joined #mojo
15:10 jacoby joined #mojo
15:16 sri oh, stickermule closed their marketplace
15:16 sri that means from now on the only way to get stickers is perl events
15:22 sri hmm, looks like they don't even have the raptor image saved anymore
15:23 sri i guess that one will be a rare sticker from now on
15:34 mib_51zndy joined #mojo
15:52 gregf_ joined #mojo
15:52 mishanti1 sri: You don't have the raptor in vector-format?
15:57 sri not with the good sticker outline
16:33 FROGGS joined #mojo
17:01 FROGGS jberger / sri: I believe the hot deployment is working now on my box
17:01 FROGGS I upgraded to 7.60, though that did not help
17:01 FROGGS I've seen in the logs that the graceful_timeout changed from 60 to 120, which implies that the defaults were changed
17:02 FROGGS though, the websocket session still kept workers alive, so the upgrade failed after *60* seconds still
17:03 FROGGS so that'd mean the upgrade_timeout is still 60, when the graceful_timeout is 120
17:03 FROGGS and I believe the second must be smaller that the former
17:03 FROGGS I changed it to upgrade:60 and graceful:30 and this worked
17:04 FROGGS will check the codebase later
17:04 FROGGS (mojo's codebase, that is)
17:22 sri FROGGS: i think you might be correct
17:25 dod joined #mojo
17:28 dod joined #mojo
17:28 good_news_everyon joined #mojo
17:28 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vNLzh
17:28 good_news_everyon mojo/master aeb1793 Sebastian Riedel: increase default upgrade_timeout from 60 to 180 seconds in Mojo::Server::Hypnotoad
17:28 good_news_everyon left #mojo
17:31 sri (please double check, my recent commits have not been particularly good...)
17:40 djk joined #mojo
17:57 Seth joined #mojo
17:59 Leffe joined #mojo
18:08 jamesaxl joined #mojo
18:23 trone joined #mojo
18:32 marty_ joined #mojo
18:35 ChmEarl joined #mojo
18:44 marty joined #mojo
18:48 djk joined #mojo
19:18 dod joined #mojo
19:23 marty joined #mojo
19:42 dod joined #mojo
19:44 marty joined #mojo
19:49 gryphon joined #mojo
20:11 marty joined #mojo
20:17 ghenry joined #mojo
20:18 Leffe joined #mojo
20:36 Leffe joined #mojo
20:37 Pyritic joined #mojo
20:57 Leffe joined #mojo
21:13 ghenry joined #mojo
21:29 Leffe joined #mojo
22:15 marty joined #mojo
22:32 Leffe joined #mojo
22:42 marty joined #mojo
23:23 Leffe joined #mojo
23:24 karjala_ joined #mojo

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