Camelia, the Perl 6 bug

IRC log for #mojo, 2012-12-26

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

All times shown according to UTC.

Time Nick Message
00:01 marty wow.  I just learned what pjax is.  Looks like a refined version of history.js to me.
00:02 marty I've been using history.js for quite a while, works well
00:05 sinkovsky joined #mojo
00:13 Molaf_ joined #mojo
00:48 egopro joined #mojo
00:50 rem_lex|pivo joined #mojo
00:55 sinkovsky joined #mojo
01:06 hlin joined #mojo
01:10 ka2u joined #mojo
01:12 Mike-PerlRecruiter_ joined #mojo
01:17 rem_lex|pivo joined #mojo
01:47 d4rkie joined #mojo
02:01 Miked joined #mojo
02:08 sinkovsky joined #mojo
02:43 Averna joined #mojo
02:54 rhaen joined #mojo
03:01 jnbek^dt joined #mojo
03:20 sinkovsky joined #mojo
03:35 noganex_ joined #mojo
03:50 kryptonite joined #mojo
03:53 rhaen joined #mojo
04:33 sinkovsky joined #mojo
04:36 rhaen joined #mojo
04:50 rhaen joined #mojo
05:04 rhaen joined #mojo
05:04 ka2u joined #mojo
05:43 rhaen joined #mojo
05:46 sinkovsky joined #mojo
06:00 rhaen joined #mojo
06:10 spleenjack joined #mojo
06:21 egopro joined #mojo
06:58 sinkovsky joined #mojo
07:08 rhaen joined #mojo
07:25 Vandal joined #mojo
07:40 ver joined #mojo
07:50 ObseLeTe joined #mojo
07:56 rhaen joined #mojo
08:11 sinkovsky joined #mojo
08:14 yakudza joined #mojo
08:22 dod joined #mojo
08:30 alnewkirk joined #mojo
08:31 dod joined #mojo
09:08 Miked joined #mojo
09:54 SmokeMachine joined #mojo
09:54 rhaen joined #mojo
10:10 sinkovsky joined #mojo
10:16 basic6 joined #mojo
10:17 mojo-quest joined #mojo
10:17 dvinciguerra joined #mojo
10:18 mojo-quest hello!
10:18 mojo-quest help me please
10:18 mojo-quest I want use Mojo::Server::Hypnotoad
10:19 mojo-quest require Mojo::Server::Hypnotoad;
10:19 mojo-quest my $h = Mojo::Server::Hypnotoad->new(%config);
10:19 mojo-quest print "Obj: $h\n";
10:19 mojo-quest $h->run($app);
10:19 mojo-quest I sow that it runs twice
10:19 mojo-quest why this?
10:20 alexeiras joined #mojo
10:27 mojo-quest output:
10:27 mojo-quest Mojo::Server::Hypnotoad=HASH(0x1728030)
10:27 mojo-quest Mojo::Server::Hypnotoad=HASH(0x9efcc0)
10:28 mojo-quest why twice invoked script?
10:30 tempire mojo-quest: why are you using hypnotoad in that manner?
10:31 mojo-quest because I want advanced config
10:34 mojo-quest which way for configure hypnotoad?
10:37 ryozi joined #mojo
10:38 tempire use a configuration file
10:38 tempire mojo-quest: http://mojolicio.us/perldoc/Mojol​icious/Guides/Cookbook#Hypnotoad
10:38 ObseLeTe joined #mojo
10:40 mojo-quest yes, thanks, but why I can't use Mojo::Server::Hypnotoad as normal module?
10:40 ObseLeTe joined #mojo
10:42 rhaen joined #mojo
11:04 Guest-ru joined #mojo
11:05 Guest-ru left #mojo
11:25 ObseLeTe joined #mojo
11:32 sinkovsky joined #mojo
11:37 kitt_vl joined #mojo
11:43 marty joined #mojo
11:55 egopro joined #mojo
12:11 ObseLeTe joined #mojo
12:16 zdk_ joined #mojo
12:19 vervain joined #mojo
12:42 d4rkie joined #mojo
12:55 basic6 how do i properly use "my favorite template system" HTML::Template in a "real" (not Mojolicious::Lite, unfortunately all the docs only describe how to do things in Mojo Lite)?
12:55 basic6 http://search.cpan.org/~sri/Mojolicious-​3.69/lib/Mojolicious/Guides/Rendering.po​d#Adding_your_favorite_template_system
12:55 basic6 I have added that handler code to my startup subroutine and adjusted it so that it would return the file path of the template as output (that's working). so i could at this point read that file, create an HTML::Template object, set a couple of variables and return $template->output BUT this is all in my startup method. The problem (and that's obviously different in a Mojo Lite app) is that I create the dynamic content in the controller method (lib
12:55 basic6 /MyApp/News.pm or something) so that's where I have to set the variables on the template object (but i still need the template object in the custom helper method). as you can see, i'm relatively new to mojo, so please don't get mad. what's the proper way to solve this?
12:57 basic6 Unlike in a Lite app, the startup method is in my app module lib/MyApp.pm, one of several controllers is in lib/MyApp/News.pm, a template could be in templates/News/list.html.tpl (if tpl is the name of my custom helper).
13:00 basic6 That one sentence below the code (link above) sounds promising -- but what/where are those helping methods?
13:00 basic6 "Since most template systems don't support templates in the DATA section, the renderer provides methods to help you with that."
13:13 Mike-PerlRecruiter_ joined #mojo
13:18 bc547 joined #mojo
13:51 nic basic6: Is there a reason you want templates from DATA in a full app (rather than the usual files)?
13:52 nic objects/data global to your app should be stored... in your app, which is accessible in a controller from $self->app
13:55 inokenty joined #mojo
13:56 memowe \o/
13:57 basic6 nic you're probably asking because i quoted that last sentence... but i am obviously not using the __DATA__ section used in mojo lite apps. i should rephrase my question...
14:01 basic6 consider this example: startup method in app class = lib/MyApp.pm, controller for news seciton in list method in lib/MyApp/News.pm, template for that page in templates/News/list.html.tpl
14:01 basic6 i've added a helper method "tpl" in the startup method (for code see link above). and it works, i get the path of the template file and can freely modify the output. but i only need to create and call output() of the template (HTML::Template) object in that method. the actual modifying (setting the vars on that object) takes places in my contorller method lib/Myapp/News.pm. so in that method i already need to have a template object somewhere, just
14:01 basic6 set some vars on it, and in the render method (which is called afterwards) i call the output() method of the template object
14:02 ka2u joined #mojo
14:02 basic6 i need to create the template object before the controller method is called and put it somewhere. then i need to be able to access that object in the render method (object->output()). how do i create the object?
14:04 basic6 http://search.cpan.org/~samtregar/HT​ML-Template-2.6/Template.pm#SYNOPSIS
14:05 nic basic6: and you can't create the object in the controller?
14:06 basic6 1. there are lots of controller methods, because there are lots of different dynamic pages that would be duplictae code
14:06 basic6 2. there are some static pages without any controller method
14:06 basic6 so no
14:06 basic6 but do you see what my problem is or did i describe it poorly?
14:08 basic6 that helper method i inserted into the startup subroutine reminds me of a post hook script, which is called after the controller emthod (if any) has been executed), hence "post"
14:08 basic6 so i'm probabl looking for a pre hook, which is executed *before* the controller method, in which i would new HTML::Template ( file->templatefile) ... you know?
14:10 yakudza joined #mojo
14:12 nic It's a long time since I worked with H::T; do you need a new template object per request hit?
14:13 nic if so, then yes, create it in the pre hook, cache it in the stash
14:13 ryozi joined #mojo
14:18 basic6 yes, it's a 3 step process.
14:18 basic6 1: create new t::t object (filename=>templatefile) 2: set
14:18 basic6 1 is in the pre hook
14:18 basic6 2 set vars
14:18 basic6 3 call output()
14:19 basic6 2 is in the contorller method and output in the helper method (startup)
14:19 basic6 so where is the pre hook, how do i set a pre hook in mojo?
14:21 basic6 oh looks like $self->hook(after_disptach => sub {...}) might be the right place to new the template...
14:24 gryphon joined #mojo
14:40 Miked joined #mojo
14:54 jberger has anyone opened my xmas gift? https://gist.github.com/4380740
14:55 jberger I think it can be really useful, especially for feedback for things like logging in, form submission etc where you don't want to add lots of code, but want to tell the user a little something extra
15:00 basic6 ... i still don't get it. how do i set a stash value in my pre hook?
15:00 basic6 the docs say my $c = shift; ... so i tried $c->stash(test => "TEST"); but that doesn't do anything
15:01 wircus jberger: I don't get it.
15:02 wircus Humane?
15:02 jberger its a browser notification library
15:02 jberger http://wavded.github.com/humane-js/
15:02 wircus yeah, bothered to read your docs on cpan now, it helped :)
15:02 wircus neat
15:04 ObseLeTe joined #mojo
15:05 basic6 if anyone cares, "after_dispatch" is the wrong hook, i need to use before_dispatch, to be able to use the stash
15:05 jberger basic6, what is it you are trying to do?
15:05 jberger set the default template handler?
15:08 wircus__ joined #mojo
15:08 batman____ joined #mojo
15:09 basic6 jberger i'm trying to use HTML::Template with my mojo app and i'm having some problems with the docs every now and then because they're all written for mojo lite apps it seems. anyway it's a 3 step process, i first need to create a new HT template object (filename=> templatefile (templates/News/list.html.tpl) step 2 is to set the dynamic content (controller method lib/MyApp/News.pm) to that template and step 3 is to get the parsed template output
15:09 basic6 back to mojo (that's in the helper method i linked somewhere above and it works). i'm looking for the right place for step 1.
15:09 batman____ joined #mojo
15:09 wircus__ joined #mojo
15:09 basic6 and yeah, step 1 needs to be executed before the controller method because the latter needs to set the vars on that template.
15:10 wircus joined #mojo
15:10 wircus joined #mojo
15:10 basic6 so i'm now trying to get the template path in the before_dispatch hook so i can create the template object. i now know how to put it on the stash. i can then access it from the controller method to set the vars and access it from the handler to get the output.
15:10 basic6 i think.
15:13 * jberger is reading up
15:18 jberger why not put the step 1 stuff in the app startup method?
15:18 jberger you can put it into a plugin, then load that first
15:20 basic6 jberger interesting i haven't thought of putting it into the startup method ... but i don't see how i would get the template file path in the startup method (too early, the routes are defined there but not called yet). the filename is the argument to the ctor of the HTML::Template class
15:22 basic6 but you know. .. looks like i have to write my own wrapper class (for html::template) anyway. i'll write it in a way that it does NOT need to know the file name of the template when it is constructed
15:23 jberger if I'm understanding the rendering doc correctly, you should add your template path to the list of template paths as usual (push @{ $app->renderer->paths }, $my_path)
15:23 basic6 i'll just create the object in the before_disptach hook and put that empty template on the stash.
15:23 basic6 in the controller method i'll set the vars on the template using my wrapper methods (prepare_var)
15:23 basic6 in the template handler i'll get the template file name (from mojo) and then actually set the vars and pass back the output
15:23 jberger then use the $r->template_path to find the template relative to that in your rendering handler
15:24 basic6 no i'm using the default template path. and that works, i can get the real path of my template file in the handler, just not in the pre hook...
15:25 basic6 at this point i'll try to write my wrapper class for the templates. i know where to store its object (stash).
15:25 basic6 i'll get back here as soon as i'm done with that... thanks, this channel is great
15:27 jberger I'm glad you think so, but I'm still not sure why you need the before hook
15:27 jberger can't you create the HT object in the handler?
15:28 jberger and if you want a persistent object, you can store it in a helper
15:30 basic6 jberger in the controller method (let's call it list, in lib/MyApp/News.pm), after generating the dyn content (the list of news entries for example), i need to set that content in the template $template->param(title => ...
15:30 basic6 in order to be able to do that - i need a template object which already needs to exist before the controller method is called. hence the "pre hook" idea
15:34 jberger I guess I'm just not grasping the problem, thats my fault, if you think you've got it, then give it a go
15:38 vervain Anyone got a valid nginx reverse proxy + mojo setup where Mojolicious is under non-root path?
15:39 vervain I've been twiddling for a while and the closes I can get is http://localhost/app works and http://localhost/app/ gives a 404 'None of your routes matched your GET request for //...'
15:42 jberger sri: is there a typo in http://mojolicio.us/perldoc/Mojolicious/Guides/​Rendering#Adding_your_favorite_template_system, where is $r coming from?
15:43 jberger basic6, make up something small and post it somewhere, I'm curious
15:43 basic6 i'm probably just describing it poorly. but in the meantime i've already written the basic skeleton of my template wrapper class, which is working fine so far. just need to add the param methods i'm done (because all the work is done by H::T).
15:43 basic6 i though mojo must have a better way to use external templating engines (and it's stil possible that it has and i haven't found it yet)...
15:43 basic6 i'll try to point out the problem in another way:
15:43 basic6 http://search.cpan.org/~sri/Mojolicious-​3.69/lib/Mojolicious/Guides/Rendering.po​d#Adding_your_favorite_template_system
15:43 basic6 describes how to add a custom template handler (e.g. "tpl") in the startup method (lib/MyApp.pm). i could create a HTML::Template object there. but that's the wrong place to fill my template object with content.
15:43 basic6 the dynamic content is generated in the controller method (like lib/MyApp/News.pm). so we have one startup method with a tpl handler subroutine containing the custom template and we have a controller method (somewhere else) which generates the content that goes into the template object. of course it's all in the same file in a mojo lite app, but i'm not working on a lite app. so my problem is/was that i didn't know how to get the dynamic content f
15:43 basic6 rom the controller method into the template object in the tpl helper
15:45 basic6 so leaving out all the details of the template engine being used - the contents are always generated in the controller method. and the tpl handler is in the startup method. and those need to work with each other. that's what i was unable to find in the docs
15:46 ka2u joined #mojo
15:48 basic6 i'm certainly not an expert in putting things into words
15:52 basic6 it all comes down to one question: in the controller method, after generating the dynamic content (like news entries and page title and stuff) - if one is using an external templating engine, how does one send the generated content to the template engine (?->setParam(title => $generatedtitlefromdb) )?
15:54 jberger pass it as an option to render, then in the hander pull it out of $options
15:54 jberger ?
15:55 basic6 that would be indirect, no direct access to the template object. and i'd need to call render in that case (which i'm not calling at all right now in most cases)
15:56 jberger shouldn't your handler be the thing that interacts with your template object?
15:56 basic6 correct. but the handler is in a completely different file than the controller method.
15:56 basic6 you see the trouble?
15:57 basic6 controller method: dynamic content, to be sent to template
15:57 jberger no, the renderer dispatches to the handler
15:57 basic6 handler: thing that creates template afterwords
15:58 jberger the controller shouldn't be generating the content (in pure MVC terms)
15:58 jberger it should be delegating to other methods/templates that do
15:58 basic6 yes it doesn't and that's my problem
15:59 basic6 the controller method may be in lib/MyApp/News.pm sub list, IT creates the content
15:59 basic6 then after that controller method is done, the handler is called automatically, right?
15:59 jberger the handler is called on ->render
16:00 jberger which I believe happens implicitly if you don't explicitly call it
16:00 basic6 that's also true. but i don't call that -> it's called automatically after the controller method
16:00 basic6 so without any custom template handler, mojo would then be rendering some ep template like templates/News/list.html.ep
16:01 jberger yeah
16:01 basic6 instead, with the handler, my handler is called, which uses the HTML::TEmplate thingyu
16:01 jberger so setup your new handler and make it the default
16:01 basic6 so THAT handler method i wrote needs to know the dynamic content previously created by the controller method
16:02 basic6 i have my handler and the handler itself is working (becaue thats the only thing described in the docs)
16:03 basic6 but do you see how there's a "connection problem" - the controller method only generates and therefore knows the content, but the handler method, called afterwords, has to know this content to pass it to the template engine?
16:07 jberger again, you either pass your dynamic content to the render method (which you now call explicitly) or perhaps stash it and pull it out of the controller argument to the handler callback
16:07 jberger $c in the guide recipe
16:09 basic6 if i'd go that route - how would i know in the handler what to pull from the stash and send to the template object?
16:09 basic6 i mean one controller method may set 7 values/params, another one 3, another one 23, another one 0
16:11 basic6 and i'm sure it would theoretically be possible to create something like a hashref in the stash, only used to cache those params, put all the values in that hashref in the controller method and in the handler get all the values out there and put them (in a loop) onto the template object ... but that sounds like not pretty and also overheadish
16:11 basic6 i just thought the most elegant way would be to directly access the template object from within the controller method
16:15 marty basic6:  Not sure if this will help...   http://search.cpan.org/~bfaist/Mojoliciou​s-Plugin-HTMLTemplateRenderer-0.03/lib/Mo​jolicious/Plugin/HTMLTemplateRenderer.pm
16:19 jberger I would look at the code for Mojolicious::Plugin::EPLRenderer
16:20 jberger the main template handlers are done exactly the same as any other handler would be
16:20 jberger EP is a wrapper for EPL, so look at epl first
16:20 mire joined #mojo
16:21 ka2u joined #mojo
16:21 jberger but yes, creating a hashref in the stash is where I would go first
16:23 basic6 i'm not so sure if you could compare ep templates with html::template templates. the main thing about ep templates is that you're (your desginer / content management guy) just writing perl in the template itself, and of course you can access a stash variable that way... this is why i want to use html::template, so the content guy does not even get to see any perl code
16:24 jberger first of all I don't think the stash is exposed in EPL (note the L) and second its the handler for EP that does it. Mojo::Template is a completely seperate module that knows nothing about a stash
16:25 jberger which is why I suggest you see how the EP and EPL handlers do there thing, because they do some cool things :-)
16:26 jberger *their thing (facepalm)
16:27 basic6 jberger okay thanks for the tip, i'll look into it sometime (not now though, at the moment i just want to get going)
16:27 basic6 marty looks very interesting, maybe this should be referenced in the docs. however at htis point im already almost done with my own template wrapper class, so i don't need it anymore
16:39 ObseLeTe joined #mojo
17:04 xaka joined #mojo
17:30 mattastrophe joined #mojo
17:31 good_news_everyone joined #mojo
17:31 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/oIhrKQ
17:31 good_news_everyone mojo/master cdbf89a Sebastian Riedel: fixed typo in handler example
17:31 good_news_everyone left #mojo
17:34 sri jberger++
17:34 sri marcus++ # closing issues
17:42 sri https://github.com/kraih/mojo/issues/425 # btw. this issue seems silly, html_escape is horribly slow and the html5 spec does not require more entities than xml_escape provides
17:43 sri i would close the issue if i wasn't so tired of being the bad guy :)
17:47 sri just do whatever you like with issues that are inactive for over a week, if i cared i would have answered/resolved it by then ;)
18:10 dwierenga joined #mojo
18:20 Adura joined #mojo
19:18 human39 joined #mojo
19:38 sh4 joined #mojo
19:40 mattastrophe joined #mojo
20:15 basic6 i've just added a few routes and worked on templates, but other than that, and suddenly no route works anymore - i always just get the 404 error (as in the not_found template). i feel stupid for asking, but is there a way to increase the debug level? i see the correct get command in the log, followed by "routing to a callback". then rendering not found... but no reason given
20:25 labrown joined #mojo
20:28 basic6 oh found it, bridge returned 0, i was just confused by the log message, sorry...
20:44 perlite_ joined #mojo
20:44 basic6 how could i have my mojo app called without requiring the user to append "myapp.pl" to the url?
20:59 ObseLeTe joined #mojo
21:02 mattastrophe joined #mojo
21:10 rem_lex joined #mojo
21:11 buu basic6: How are you running your mojo ap?
21:11 buu app*
21:27 sinkovsky joined #mojo
21:45 vervain I've had to use http://pastebin.com/JNhBAX6P to get around unexpected behavior in the recipe at http://mojolicio.us/perldoc/Mojol​icious/Guides/Cookbook#Rewriting
21:46 vervain But my adjustment just feels dirty, have I missed something?
22:17 wircus__ weird
22:17 wircus weird
22:20 wircus joined #mojo
22:20 batman____ joined #mojo
22:26 basic6 buu http://baseurl/myapp.pl and http://baseurl/myapp.pl/Category/somepage
22:27 buu That doesn't exactly answer the question, but do you mean you're running it as a cgi?
22:27 basic6 yes
22:27 basic6 not in a cgi-bin directory though
22:28 buu Then your choices are limited to mod-rewrite, basically.
22:29 buu basic6: Typically people don't run mojo apps as cgi though.
22:29 basic6 ... do people use the internal websevrer instead or what's more common then?
22:29 wircus buu: better than running Catalyst apps as cgi at least.
22:29 buu Well, yeah.
22:30 wircus basic6: http://mojolicio.us/perldoc/Moj​olicious/Guides/Cookbook#Nginx
22:30 basic6 i don't have that choice
22:30 buu basic6: I think a lot of people deploy via hypnotoad + reverse proxy
22:30 buu Well, what choices do you have?
22:30 wircus basic6: fastcgi is fine too.
22:30 wircus over psgi
22:30 wircus if you're not doing real time stuff at least.
22:30 basic6 i could do all those great things on my own servers, and in fact i already do that. but not on the target server for my project
22:31 wircus basic6: what's the target?
22:31 basic6 there's just an apache running, i can't even read the apache conf, all i can do is a little bit of tweaking using htaccess
22:32 buu Can you do mod-rewrite rules via the htaccess?
22:32 basic6 yes i can do that.
22:32 buu Well then
22:32 basic6 do you have ideas for rewriterules?
22:32 wircus basic6: but no fastcgi?
22:33 buu The documentation is pretty explicit.
22:33 buu http://httpd.apache.org/docs/​current/mod/mod_rewrite.html
22:33 basic6 RewriteRule ^.*$ myapp.pl/$1 [L] something like that i guess
22:34 * tempire shakes fist at apache
22:36 basic6 wircus honestly i'm not sure, is fastcgi the one that loads the application only once on startup?
22:36 wircus basic6: yes
22:37 basic6 so a webserver restart is required after every change?
22:37 wircus basic6: no, it's not running in the apache process.
22:38 wircus I see dreamhost supports fastcgi at least http://wiki.dreamhost.com/FastCGI
22:38 basic6 i'm trying to figure out a working rewriterule pattern now, that gotta work
22:39 basic6 basically i want everyhting (.*) rewritten to my app script (myapp.pl/$1)
22:40 wircus basic6: that really has nothing to do with mojolicious, tbh.
22:41 basic6 right, technically it doesnt, i was asking here because i thought there would be a common solution from mojo devs
22:45 mire joined #mojo
22:58 rem_lex|pivo joined #mojo
23:04 basic6 does mojolicious use $ENV{PATH_INFO} to know what route to call (e.g. /script.pl/test -> /test) ?
23:09 cfedde basic6: probably not.
23:11 basic6 maybe request_uri ,,,?
23:14 basic6 i'm actually asking because i've tried FallbackResource /myapp.pl and routes aren't working. the only difference when comparing ENV in this case with ENV when calling the actual url /myapp.pl/test was path_info ...
23:15 cfedde what do I know.
23:15 cfedde ?
23:16 basic6 i was hoping someone around here would know mojos router well enough to say if that missing header is the problem or if it's something else
23:17 cfedde this channel is pretty hit or miss to find someone that can answer questions.
23:20 vervain and will :-)
23:20 cfedde that too.
23:38 cfedde how do I adjust the Inactivity timeout?
23:50 xaka cfedde: either --inactivity_timeout option or MOJO_INACTIVITY_TIMEOUT env variable
23:52 * cfedde tries
23:53 cfedde MOJO_INACTIVITY_TIMEOUT seems to work as expected for morbo.
23:53 cfedde xaka: thanks!
23:53 xaka cfedde: i'd use command line option though
23:54 cfedde xaka: the command line option did not work for morbo.   At least not in the obvious way.
23:55 xaka cfedde: my bad, it's called "--inactivity" :)
23:56 cfedde xaka: If I wanted to find that in the doc where would I look?
23:57 cfedde the faq discusses the issue.
23:58 cfedde but does not propose a solution or a pointer to the doc.
23:59 xaka cfedde: well, everything is in docs (plus you have "--help" for morbo/hypno), but the problem is that there is no index so i prefer to grep in sources

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