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

IRC log for #mojo, 2017-05-10

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

All times shown according to UTC.

Time Nick Message
01:56 jnbek joined #mojo
02:30 tchaves joined #mojo
02:47 noganex joined #mojo
02:50 Pierre joined #mojo
02:59 mcsnolte joined #mojo
03:10 aborazmeh joined #mojo
04:10 purl joined #mojo
04:34 disputin joined #mojo
04:54 Pyritic joined #mojo
05:09 inokenty-w joined #mojo
05:42 Pierre joined #mojo
05:48 dod joined #mojo
05:55 dod joined #mojo
05:59 dod joined #mojo
06:20 tianon joined #mojo
06:39 AndrewIsh joined #mojo
06:40 CHYC joined #mojo
06:59 faraco joined #mojo
07:01 faraco my $foo = $r->under('/foo')->to('foo#baz');..im stuck at this route.. what is it..and what is foo#baz.. what it does.. in the Mojolicious::Guides::Routing
07:02 ashimema /foo is the 'route' your hitting.. i.e http://whatever.com/foo
07:03 ashimema foo#baz is the shorthand for controller & action
07:03 faraco then why it is different than normal get/post routes
07:03 ashimema is it the 'under' that's confusing you?
07:04 ashimema under allows you to group routes
07:05 ashimema so /foo/bar, /foo/baz, /foo/bing will all match /foo first
07:05 faraco yeah.. im following Oliver's moblog guide right now.. and stuck at session.. which is routing after a user has logged in.. but not sure where to redirect after that
07:05 ashimema for instance if you wanted everything 'under' /foo to be authenticated then you could add an auth action in the 'under'
07:06 ashimema is that this one: http://oliverguenther.de/2014/09/applications-with-mojolicious-part-seven-relationships-in-dbixclass/
07:06 ashimema http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Under is the relevant doc for 'under'
07:07 faraco yes... but to be exact,  http://oliverguenther.de/2014/04/applications-with-mojolicious-part-three-forms-and-login/
07:07 * ashimema is probably not the best to explain this stuff to be honest.. still fully getting to grips with it all himself
07:09 ashimema so, he's using under in the way I mentioned above.. basically he's saying everything 'under' /admin should require authentication
07:09 faraco ah,  when you said must go through foo first..it helped me to see the concept.  now I can understand the doc better.
07:10 ashimema So.. his intermediary step in the routing chain is in the 'Login' controller and refers to the 'is_logged_in' method
07:11 ashimema so when you hit '/admin/users' for instance, the router will go "hey, that's /admin, best hit Login::is_logged_in first to check their authenticated then if that returns true I'll go ahead and hit /admin/users"
07:11 ashimema cool..
07:11 ashimema sorry for resorting to 'rtfm'.. it likely does a better job of explaining than me 'tis all ;)
07:12 ashimema his is_logged_in routine isn't a bad example.. though I'd probably dump a redirect header in there too.. get the user to the login page.. and use the flash to remember where they were so we can redirect back once they've logged in..
07:13 ashimema but that's possibly a bit out of scope ;)
07:13 * ashimema heads off for the school drop off now
07:13 ashimema have fun
07:13 purl Don't do anything I wouldn't do!!!
07:14 faraco thank you very much,  you explained it a lot better!  :) ashimema
07:14 Pierre joined #mojo
07:14 ashimema :)
07:28 trone joined #mojo
07:42 prg joined #mojo
07:54 Vandal joined #mojo
08:32 rshadow joined #mojo
08:44 karjala_ joined #mojo
08:57 gregf_ joined #mojo
09:11 stryx` joined #mojo
09:21 stryx` joined #mojo
09:26 dod joined #mojo
09:29 karjala_ How can I programmatically get the path of my website's app.pl from inside a route handler?
09:29 karjala_ Wherever it might be residing (it's different on development server than on production)
09:36 nic Do you mean url_for?  There's also something for 'current route'
09:37 karjala_ no i don't mean url_for
09:38 karjala_ I meant the file path
09:38 karjala_ like /home/www/myapp/app.pl
09:38 karjala_ Does FindBin do it? or will that return the path of hypnotoad?
09:42 karjala_ yes, findbin does it
09:42 karjala_ thanks all
09:45 batman karjala_: have you looked at $app->home ? maybe that's what you want...
09:49 karjala_ batman, that's nice
10:03 stryx` joined #mojo
10:08 prg so i have this legacy script which basically calls readdir() every n seconds in a big while(1) loop, and i was wondering if i could replace that with something like Mojo::IOLoop::Stream?
10:46 pink_mist readdir isn't really a stream ... perhaps you wanted an inotify type thing
10:51 tchaves joined #mojo
10:52 prg yeah, i started reading up on it and realized it's not what i imagined
10:54 prg unfortunately there's no Mojo::IOLoop::Inotify :(
10:56 pink_mist you can probably take a look at https://metacpan.org/pod/Mojo::Server::Morbo::Backend::Inotify for inspiration
10:56 pink_mist if you want to make your own
10:59 prg not sure if i can justify building that just to replace a legacy script :\
11:05 sri it shouldn't be too hard, maybe 10 lines of code
11:08 prg if you have your level of understanding, i'm still figuring this thing out ;)
11:08 prg shouldn't it be a Mojo::Reactor subclass anyway?
11:09 batman prg: did you look at the source code for Mojo::Server::Morbo::Backend::Inotify ?
11:09 prg batman: briefly, why?
11:10 batman just curious. often such a module might seem complex from what it does, and then you open it up and it has surprisingly little code
11:11 prg i'm not that worried about the Inotify part, i'm confident i can figure that part out. just not sure where to integrate it in the whole Mojo::IOLoop thing
11:12 prg anyway, going out for lunch. back in a bit
11:13 nic what is this lunch thing I keep reading about on here?
11:25 sri hmm, i guess it would actually make for a good documentation example
11:25 sri (how to write Mojo::IOLoop::Inotify)
11:26 sri since it's tiny and would show how to use the reactor for watching a handle
11:27 nic that would be great
11:40 prg i agree, obviously :)
12:13 dod joined #mojo
12:18 dod joined #mojo
12:29 Armen goodest of mornings! I wonder if there are any good examples of inheritance using Mojo::Base I could look at. Something a bit more complex than the Cat/Tiger example in the documentation. In particular, the "correct way", if any, to inherit package-level methods (rather than instance-level)
12:50 gizmomathboy joined #mojo
12:52 ranguard joined #mojo
12:55 gryphon joined #mojo
12:59 pink_mist Armen: there's no difference
13:01 jberger Perl has no instance methods, at least not usually
13:02 nic 'has' is always an instance method
13:02 pink_mist I think he meant object methods, as contrasted with class methods
13:03 pink_mist rather than instance methods
13:03 nic Armen: I'm not seeing the complication
13:03 nic do you have an example that's not working?
13:04 pink_mist yeah, as I said, there's no difference really, except what $_[0] refers to
13:06 nic Armen: Class attributes get a little interesting, if that's what you're thinking of
13:08 pink_mist class attributes would need to be created manually I think; doubt there's a facility in Mojo::Base for those
13:11 Armen hmm maybe I should make the bitbucket repo public to share what I'm trying to do, I'm not sure how to explain it in perlish nomenclature
13:11 Armen jabberwok: any objections if we switch the pastebeest repo to public on bitbucket?
13:12 jabberwok none
13:12 marcus sri: Any idea how erb still can do html highlighting for erb in atom?
13:15 Armen ah, we actually can't because it's part of a private project
13:15 Armen I'll look at moving it to github when I get home
13:16 nic the smaller the code example, the more chance of people looking
13:16 nic but you can also write pseudocode (eg in a pastebin or gist)
13:18 dikim joined #mojo
13:21 Armen pasteception, using pastebeest1 to paste source from pastebeest2: I want this base class: http://www.pastebeest.com/101 to make its method "find" available to this subclass: http://www.pastebeest.com/102 where the subclass should define which table to look in
13:22 Pyritic joined #mojo
13:24 dikim joined #mojo
13:24 Armen so that I might call Model::Paste::find($id); and get the row with the given id from the pastes table, using the find method inherited from Model::find
13:24 Armen this this make sense or am I trying to shove a square peg into a round hole here
13:25 nic You have Mojo::Base in there twice -- remove the one that's not helping
13:26 nic sounds fine
13:26 Armen ah, I missed that, thanks
13:26 nic so you want the tablename to be provided by a separate method
13:27 nic in the subclass, it doesn't need to mention the method that it uses from the parent, only define the method that overrides the provision of tablename
13:27 nic sub tablename { 'ThisTable' }
13:29 Armen but if I attempt to use Paste::find() it will me the method is undefined
13:29 nic (some people have it as Tablename because it's a property of the class rather than individual members)
13:30 nic it's a strong recommendation to not mix functions with methods like that
13:30 nic So you can have (tho it's v rarely seen) a class method of Paste->find
13:30 nic or a member method via Paste->new->find
13:31 nic but doing functions (note the missing arrow) will lead to trouble
13:31 Armen since find() is supposed to return a populated instance of Paste, I would have liked to treat it as a "static method"
13:31 marcus sri: Kinda looks like it works again to include the html in mojo template with current atom, just took the previous revision of the file and pasted it into your plugin source, and I have html highlighting working with the perl now.
13:32 Armen Would creating an "empty" instance and populating it with find() be a better/more perl way to achieve what I'm trying to do?
13:32 Armen so Paste->new->find as you mentioned
13:33 nic that path will lead to less insanity, yes :)
13:33 Sebbe joined #mojo
13:34 marcus but ask yourself, is less insanity really better?
13:35 PopeF joined #mojo
13:35 nic bananas
13:35 marcus Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
13:35 nic Armen: It sounds like your 'find' should be a constructor
13:36 Armen Now what if I have a second method that returns a collection of Pastes, Paste->new->findAll("user_id", 1) wastes an instance of Paste...
13:36 nic (we should have moved out of here when it became clear it's not a Mojo question)
13:37 nic Armen: I'm happy to continue, but perhaps in #perl-help or in a one-to-one?
13:38 Armen alright, moving this to #perl-help
13:42 mcsnolte joined #mojo
13:43 schelcj joined #mojo
13:46 PopeF joined #mojo
13:51 kaare_ joined #mojo
14:37 Pyritic joined #mojo
14:39 PryMar56 joined #mojo
14:40 zivester joined #mojo
15:16 klapperl joined #mojo
15:21 stryx` joined #mojo
15:49 punter joined #mojo
15:51 punter Is it possible from inside one route handler, to execute a different route handler and grab its rendered output for further processing?
15:51 punter with whatever parameters I want
15:56 punter Maybe I should use Mojo::Test?
15:56 punter or Test::Mojo
15:56 purl somebody said Test::Mojo was missing
15:56 pink_mist I don't think that's true, purl
15:56 purl pink_mist: sorry...
15:57 pink_mist punter: make the logic into a helper you call from either route handler
15:58 punter Hm
16:00 pink_mist and return the output rather than render it - then have the original route handler simply render it, and the other one do whatever it needed
16:01 pink_mist render_to_string exists
16:06 perlpilot joined #mojo
16:13 cheako joined #mojo
16:15 dod joined #mojo
16:18 dod joined #mojo
16:19 itaipu joined #mojo
16:20 sh14 joined #mojo
16:36 gizmomathboy joined #mojo
16:45 cheako joined #mojo
16:53 disputin joined #mojo
16:57 sh14|2 joined #mojo
17:01 castaway joined #mojo
17:04 disputin joined #mojo
17:28 maschine joined #mojo
18:02 gizmomathboy joined #mojo
18:17 stryx` joined #mojo
18:20 punter joined #mojo
19:05 sri marcus: odd
19:18 cheako joined #mojo
19:32 dikim joined #mojo
19:39 gizmomathboy joined #mojo
19:40 Pyritic joined #mojo
20:35 cheako joined #mojo
20:50 disputin joined #mojo
20:52 PopeF joined #mojo
21:03 stryx` joined #mojo
21:19 PopeF joined #mojo
21:53 PopeF joined #mojo
22:05 rshadow joined #mojo
22:12 gizmomathboy joined #mojo

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