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

IRC log for #mojo, 2016-06-25

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

All times shown according to UTC.

Time Nick Message
00:01 user_7801 Tie::IxHash is just fine
00:01 user_7801 I just was playing around
00:01 user_7801 I can't get it to work anyway right now
00:01 bpmedley user_7801++
00:02 bpmedley Is this a user request, or something you think they might want?
00:08 jberger user_7801: you might want to ask in a more general channel
00:08 jberger Otherwise just use what works
00:23 kid51 joined #mojo
00:24 genio Mr. Robot's back!
00:24 kid51 A question on installing Mojolicious for the first time ...
00:24 genio kid51: What's up?
00:24 kid51 If I follow the instructions from the website and say:
00:24 kid51 curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Mojolicious
00:25 kid51 And if my 'perl' is installed via perlbrew underneath my home directory, then will all of Mojo (executables as well as source) be installed there as well?
00:26 kid51 Also, assuming I customarily use 'cpanm' to install Perl libraries in this perlbrewed environment, would 'cpanm Mojolicious' work just as well as the command above?
00:26 genio yes
00:26 * sri is too depressed to even enjoy mr robot
00:27 kid51 genio: "yes" to both questions?
00:27 genio kid51: Yes.  You can verify where the mojo app is installed with    which mojo     or     which morbo     etc
00:29 kid51 Success.
00:29 kid51 $ which mojo
00:29 kid51 /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin/mojo
00:29 kid51 $ which morbo
00:29 kid51 /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin/morbo
00:29 kid51 Thank you very much.
00:29 bpmedley kid51++
00:30 bpmedley kid51: If you have time, would you consider reading this: http://bmedley.org/mojo.pdf ?
00:30 genio no problem.  glad you have things setup, now get to learning some Perl and Mojo!  :)
00:30 kid51 genio: Umm, the Perl I know (for 17 years) ;-)
00:31 kid51 Trying Mojo based on gabor's talk in Orlando
00:31 kid51 at YAPC::NA ... errr TPC 2016
00:31 bpmedley kid51: Have you seen the tutorial?
00:31 genio kid51: Oops. Sorry, I assumed you were new to Perl.  Well, then... get to learning some Mojo!
00:32 bpmedley kid51: http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial
00:32 genio sri: take a good, long run on your treadmill and enjoy Mr. Robot.  That might make you feel less depressed
00:33 kid51 bpmedley: Can I assume that that's the same as 'perldoc Mojolicious::Guides::Tutorial'?
00:34 bpmedley kid51: I would make that assumption.  I'm not 100% sure tho.
00:35 kid51 bpmedley: I'll probably start with M:G:Tutorial, M:G:FAQ and then take a look at that PDF.  Thanks.
00:37 genio sri: Have you been watching Preacher?
00:42 * kid51 starts with https://developer.mozilla.org/en-US/docs/Web/HTTP as recommended in the docs
00:43 jberger kid51: the curl script just uses cpanm under the hood
00:43 jberger just the same thing
00:43 jberger just look at: http://get.mojolicious.org/
00:44 jberger also, welcome!
00:44 bpmedley kid51: That may be a lot of reading initially.  If it was me, I'd want results I could iterate over quickly.  I'd recommend typing the "Hello World" example, getting that working in the browser, and going from there.
00:45 jberger kid51: yes those are the same documents
00:46 jberger mojolicious.org/perldoc is just a pod renderer (which defaults to the doc for Mojolicious::Guides incidentally)
00:46 jberger we highly recommend you read the guides in the order shown on that page as well
00:49 jberger kid51: if you are already familiar with the web (as I suspect you are, though I can't remember for sure (you are/were at mediamath right?)) then you won't learn anything from the MDN on HTTP
00:49 jberger it is a great reference though
00:53 kid51 The discussion of safe vs. idempotent vs. other methods is very clarifying.
00:53 jberger that is good stuff
00:54 sri genio: yea, didn't like it much, not really into the religious stuff
01:02 sri ok, the brexit breakup jokes on reddit do make me smile though
01:02 sri "UK is going to find all its stuff in the English Channel."
01:30 Grinnz um, to earlier discussion, mojo sorts the json output automatically on recent versions
01:30 Grinnz I should probably apply the canonical option to Mojo::JSON::MaybeXS
01:31 disputin joined #mojo
01:31 bpmedley Grinnz: Didn't the user want the order as entered?  Which was not sorted..
01:31 Grinnz ah, ok, wasn't clear
01:46 leejo joined #mojo
02:03 leejo joined #mojo
02:08 leejo_ joined #mojo
02:16 noganex joined #mojo
02:17 thowe joined #mojo
02:40 Lee joined #mojo
03:17 kid511 joined #mojo
03:18 PryMar56 joined #mojo
04:38 iamb joined #mojo
04:45 jberger can I trouble people for a little love on https://www.reddit.com/r/perl/comments/4pozv6/yapcna_2016_getting_started_with_modern_web/
05:11 disputin joined #mojo
06:01 indianOwl joined #mojo
06:01 indianOwl Hi all
06:01 indianOwl is there any tutorial how to deploy mojo app on heroku?
06:06 bpmedley indianOwl: https://github.com/tempire/mojolicious-command-deploy-heroku
06:07 bpmedley May be helpful
06:18 sri genio: mr robot is still 3 weeks away :(
06:18 sri more disappointment!
06:21 indianOwl thanks
06:54 dod joined #mojo
06:59 dod joined #mojo
07:20 Vandal joined #mojo
07:21 jberger bpmedley / indianOwl : it is possible that that maybe be somewhat out of date
07:22 jberger Let us know if it is and we will ping tempire
07:22 jberger sri: man you really can't catch a break today can you?
09:12 mpapec jberger: I just noticed that nonblocking blog series don't cover Mojo::IOLoop->delay()->catch() pattern
09:12 mpapec http://blogs.perl.org/users/joel_berger/2014/01/writing-non-blocking-applications-with-mojolicious-part-3.html
09:14 mpapec it may be also helpful that hashref could be used when throwing exception
09:15 mpapec ie. die {internal => $@, userErr => "genericError"}
09:17 jkrizansky joined #mojo
09:18 jkrizansky hi folks
09:18 jkrizansky first time here
09:18 jkrizansky dealing with weird issue I couldn't find a solution to online
09:18 jkrizansky is this a good place to ask? :)
09:22 mishanti1 jkrizansky: It is usually yes. Just remember to not paste code here in the channel.
09:23 jkrizansky oh, ok
09:23 mishanti1 jkrizansky: http://pastie.org/ is pretty ok.
09:23 jkrizansky so I've got a simple app with Mojo 6.66 and Apache
09:24 jkrizansky got a simple route that links to one controller
09:25 jkrizansky and the weird thing is that the router randomly chooses to either look for controller "TreeMng::Main"  or controller "TreeMng::Controller::Main"
09:26 jkrizansky when it searches for the second one, it works, when it searches for the first one, it throws an error:
09:26 jkrizansky Controller "TreeMng::Main" does not exist
09:27 jkrizansky so you keep hitting F5 on the browser and in about 10% of the cases it works (the page / gets routed to TreeMng::Controller::Main) and in 90% it doesn't (TreeMng::Main)
09:27 jkrizansky after apache restart the first hit allways works
09:28 jkrizansky and the following ones don't
09:32 jkrizansky this is my whole routing table http://pastie.org/10889750
09:34 mishanti1 Oh. That's pretty neat.
09:34 jkrizansky and this is apache error log: http://pastie.org/10889753
09:34 jkrizansky you can see that for the same route "/" only the second hit worked
09:35 mishanti1 jkrizansky: What happens if you hit the app directly?
09:35 mishanti1 I mean not going through apache.
09:38 pink_mist how have you configured apache to serve the app?
09:38 jkrizansky how do I run it directly?
09:39 pink_mist ./app.pl daemon
09:41 dod joined #mojo
09:42 jkrizansky hmm, directly it works like a charm
09:42 jkrizansky here's the apache vhost: http://pastie.org/10889762
09:42 jkrizansky (a little messy now because of debugging)
09:45 pink_mist I'd suggest running the app via hypnotoad and simply getting apache to proxy to it instead of using plack
09:46 pink_mist hypnotoad is the built in Mojolicious production webserver
09:46 pink_mist the config should look something like: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Apache-mod_proxy
09:46 jkrizansky cool, thx
09:46 jkrizansky let me try that
09:47 pink_mist but instead of :8080, it'd be whatever port you configured hypnotoad to run on
09:49 jkrizansky sure
09:50 pink_mist the ProxyPass /echo line can be completely removed unless you need websocket support
10:01 jkrizansky awesome... works like a charm
10:01 jkrizansky thank you both
10:26 ncham joined #mojo
10:29 salva joined #mojo
11:20 tchaves joined #mojo
11:27 tinita joined #mojo
11:43 meshl joined #mojo
11:51 kid51 joined #mojo
12:07 leejo joined #mojo
12:16 lluad joined #mojo
12:23 genio sri: Yea, apparently what I thought was the first episode in my DVR was, in fact, a recap and talk about the show.  it was useless. :(
12:31 jkrizansky joined #mojo
12:34 dod joined #mojo
12:47 Vitrifur joined #mojo
12:47 Vitrifur left #mojo
12:56 gizmomathboy joined #mojo
13:20 pink_mist joined #mojo
13:28 leejo joined #mojo
13:53 jkrizansky joined #mojo
14:09 ipunter joined #mojo
14:12 jkrizansky joined #mojo
14:18 kaare joined #mojo
14:22 kaare joined #mojo
15:29 kid51 Working my way through http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial, I come to the section on HTTP methods.
15:29 kid51 I understand the concept of "[restricting] specific request methods with different keywords" -- but how do I test them out?
15:30 kid51 I understand how I would manipulate a browser URL for a GET, but not for PUT, POST, etc.
15:30 kid51 E.g., in a browser, 'http://localhost:3000/bye', produces visible results.
15:36 leejo joined #mojo
15:37 lluad kid51: A browser sends GET, except when it's sending a form when it'll often use POST.
15:38 lluad The other verbs tend to get used from client code (including in-browser javascript, I guess).
15:38 kid51 So, something like the PUT in that section can only be tested from a program or from the command-line?
15:39 lluad Pretty much, yes.
15:39 kid51 Is there a pastebot for this channel?
15:41 genio not that I'm aware of, but any old paste site will work (preferably not pastebin or other ad-laden ones)
15:43 kid51 http://pastie.org/10889957
15:43 genio kid51: as lluad said, I normally test these things with actual test scripts or CLI apps like cURL ( curl -X POST     curl -X PUT   etc)
15:44 kid51 http://pastie.org/10889958
15:44 genio The growing guide walks you through some of the testing
15:45 genio http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Testing
15:48 kid51 $ curl -X PUT http://localhost:3000/hello
15:48 kid51 You uploaded 0 bytes to /hello.
15:48 kid51 $ curl -X POST http://localhost:3000/bye
15:48 kid51 Bye World!
15:48 kid51 Both DWIM.  Thanks.
15:58 dod joined #mojo
16:02 kes joined #mojo
16:15 PryMar56 joined #mojo
16:40 jberger kid51: you might also try the mojo command system here
16:40 jberger Your application can do more things than just serving a page
16:41 jberger One of the other things is tying a useragent to your application and making a request directly to it
16:42 jberger ./http_methods.pl get -M PUT /hello
16:42 jberger You can see more options by running
16:43 jberger ./http_methods.pl help get
16:43 jberger Personally i use the get command all the time while developing
16:44 kid51 In the discussion of 'group', I see:
16:44 kid51 return 1 if $c->req->headers->header('X-Bender');
16:45 jberger mpapec: Thanks, yeah I don't do great error handling in there
16:45 kid51 So how do I issue a command that says I'm Bender.
16:45 kid51 (I'm assuming that the code in each example is supposed to be self-sufficient.)
16:46 kid51 Can that be set in a browser call or only from CLI/program?
16:46 jberger mpapec: some of that is addressed in this post
16:46 jberger http://blogs.perl.org/users/joel_berger/2014/07/non-blocking-mojolicious-apps-are-even-easier-now.html
16:47 jberger Though IIRC we eventually removed the inside out storage by fixing the likely cycle elsewhere
16:53 kid51 curl -X GET http://localhost:3000 -H "X-Bender:"
16:53 kid51 does not seem to DWIM
17:00 * kid51 afk
17:00 jberger kid51: Oh sorry, i missed your recent messages as i was reading the scrollback
17:01 jberger kid51: you have passed the header but given it an empty (read false) value
17:01 jberger So it still does not return 1
17:03 jberger Try X-Bender:martini
17:19 jberger oh and that example requires two headers to get to /admin
17:19 jberger both X-Bender and X-Awesome
17:30 cuechan joined #mojo
17:31 jberger hmmm it brings me to an interesting question though
17:31 jberger sri: is it correct that the get command doesn't use a header if its value has no length?
17:31 jberger perl -Mojo -E 'a("/" => sub { $_->render(text => $_->req->headers->header("X-Bender") // "Nada") })->start' get -v -H "X-Bender:" /
17:31 jberger notice that X-Bender isn't even in the request without a value
17:32 jberger there is a (.*+) here which at least seems to cause it: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Command/get.pm#L32
17:32 jberger I'd have to see if it would get ignored later on though
17:37 jberger when I build up a script that sends {'X-Bender' => ''} the empty header is passed forward
17:38 jberger so I'm going to say that I think that's a bug in the get command header parser
17:38 jberger I'll make a patch after breakfast, the wife is waiting for portuguese sausage and eggs :D (ok I am too)
18:33 jberger interesting that curl has this same problem! https://curl.haxx.se/mail/lib-2010-08/0174.html
18:33 jberger kid51: ^^
18:37 good_news_everyon joined #mojo
18:37 good_news_everyon [mojo] jberger created zero_length_header_value (+1 new commit): https://git.io/vo9V4
18:37 good_news_everyon mojo/zero_length_header_value 1ef8a57 Joel Berger: fix zero length header value bug in Mojolicious::Command::get
18:37 good_news_everyon left #mojo
18:41 jberger sri: since I wasn't confident enough to just push the fix to master, I opened at PR: https://github.com/kraih/mojo/pull/976
18:41 jkrizansky joined #mojo
18:55 cfedde joined #mojo
18:59 kes joined #mojo
20:05 user_7801 joined #mojo
20:10 indianOwl joined #mojo
20:12 indianOwl Hi All .. I am trying to develop newbie to perl web development ... trying to learn mojo for app development .. have seen all the cast and read the guide .. need help where to start for writing a small blog app that uses DB
20:12 indianOwl to understand flow of the framework
20:16 user_7801 For mysql you could use mojo::mysql, it supports non-blocking calling style.
20:20 indianOwl that fine ... as in ror we have different dir for Controller , View and Model
20:21 indianOwl Here I unable to know where should I keep the model
20:21 indianOwl or View or Controller
20:22 indianOwl lite app https://github.com/ovntatar/MicroCMS/blob/master/MicroCMS.pl
20:22 indianOwl are easy to follow ...
20:22 indianOwl but what If I am writting a huge app
20:25 pink_mist indianOwl: there's already an example blog app in the Mojo::Pg distribution
20:26 pink_mist indianOwl: https://metacpan.org/source/SRI/Mojo-Pg-2.28/examples/blog
20:40 jberger indianOwl: i agree with pink_mist, check out the blog example
20:40 jberger I also generally recommend postgres if possible
20:43 user_7801 joined #mojo
20:44 punter joined #mojo
20:45 dod joined #mojo
20:50 user_7801 is there any soap client for mojolicious that supports non-blocking?
20:50 user_7801 or am i supposed to post the soap request as raw string content with $self->ua->post
20:52 jberger user_7801: i see this but haven't used it
20:52 jberger https://metacpan.org/release/XML-Compile-SOAP-Mojolicious
20:52 jberger Otherwise yeah I'd probably just do as you say
20:58 user_7801 OK Thx.
20:58 user_7801 Btw: Hash::Ordered with JSON::XS still needs tie()   http://stackoverflow.com/questions/38028559/hashordered-versus-tieixhash-with-jsonxs-encode
21:51 jberger user_7801: good to know, thanks for investigating and for sharing your findings
21:58 zivester joined #mojo
23:01 user_7801 print $tx->res->dom;
23:01 user_7801 It prints all output in small letters?
23:27 bpmedley user_7801: Do you have an example?
23:31 user_7801 Yeah hold on
23:38 user_7801 http://nopaste.linux-dev.org/?1119062
23:39 user_7801 getting values with xpath will fail with $self->res->dom, unless I adjust all pathes to small letters
23:47 user_7801 Ok, I think its normal  due to the encoding for DOM. https://www.w3.org/TR/xml/#charencoding  case-insensitive
23:48 user_7801 but im not sure tho
23:48 bpmedley user_7801: http://pastie.org/10890431 <-- Is this a similar situation for what you're doing?
23:49 user_7801 yep
23:49 user_7801 it will print index.html in small letters
23:49 user_7801 or should
23:50 bpmedley I'm getting a mixture of upper and lower case.  Some things are converted (such as soap:envelope) and others are not.. such as BAC140107
23:51 bpmedley Perhaps you could run the pastie and see if you get all lower case as output?
23:51 user_7801 oh, yeah I think it's my mistake
23:51 user_7801 BAC and stuff is big
23:51 user_7801 but
23:51 user_7801 <af:ortsteil>Wifling</af:ortsteil>
23:52 user_7801 is printed in $tx->res->body as <af:Ortsteil>Wifling</af:Ortsteil>
23:52 bpmedley user_7801: Is Ortsteil a namespace?
23:52 user_7801 yes
23:52 user_7801 I mean af is the namespace
23:53 user_7801 Ortsteil is an element, i think

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