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

IRC log for #mojo, 2014-04-09

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

All times shown according to UTC.

Time Nick Message
00:16 Woz joined #mojo
00:19 Woz left #mojo
00:19 woz joined #mojo
00:21 woz_ joined #mojo
00:22 woz_ joined #mojo
00:28 shmuel joined #mojo
00:38 aggrolite joined #mojo
00:47 asarch joined #mojo
00:47 maxhq joined #mojo
00:48 asarch One very very very stupid question: What's the point of EP (Embedded Perl)?
00:48 jnbek to embed perl?
00:48 asarch I mean, the MVC paradigm is about to separate the the model from the controller (just like Catalyst with TT, for example, does)
00:49 asarch So why join model operations in the views
00:49 asarch ?
00:49 asarch Or... maybe I haven't seen the point of EP at all
00:54 punter joined #mojo
00:59 laouji joined #mojo
01:11 dabudabu asarch: Sometimes you need to display the contents of variables on web pages, e.g., $user_name
01:13 dabudabu And if your website is a little more complex, you might need to display more complex data
01:17 jberger sri: waddya mean? it announced 4.92 didn't it :-)
01:18 jberger asarch: because of ep, I didn't need to learn another templating language
01:19 jberger I don't have to put controller logic in the template, but at the same time, because of ep, I already know how to do 'if' statements, loops, access nested data structures etc
01:28 klapperl_ joined #mojo
01:35 asarch I see
01:35 asarch I though you could do some Perl operations ala $schema->resultset('DB::Students')->find(id => $some_id);
01:36 sri *can* does not mean *should*
01:37 sri writing good perl requires discipline, ep templates are no different
01:37 meshl Running a Mojolicious::Lite script without the daemon I get this when trying to use a template: Variable "$config" is not imported at template layouts/default.mail.ep - any hint to resolve that?
01:39 asarch Thank you guys
01:39 asarch Thank you very much :-)
01:44 howitdo joined #mojo
01:45 meshl $config is of course from my $config = plugin Config => { file => 'app.conf' };
01:45 meshl Why wouldn't it be defined in the template only when NOT daemoning?
01:46 hesco meshi:  see:  https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Stash-data
01:47 hesco not sure if that helps
01:49 meshl hesco: yeah, I know this, I am just trying to find out why $config is automatically defined in the templates when running as daemon, and undefined otherwise...
01:56 jberger meshl, isn't config a helper, not a stash variable?
01:56 meshl in the plugin Config.pm there is the line my $current = $app->defaults(config => $app->config)->config; <- I suspect something is executed differently there
01:59 d4rkie_ joined #mojo
01:59 meshl jberger: the code works as is in the daemonized app ($config is automatically defined in the templates). Now I just have another file where basically I do not call app->start
02:00 meshl but where everything else is the same. It's a job file, to be run once a day, that does not serve any file.
02:00 meshl Do I have a design flaw somewhere?
02:07 jberger wait, why don't you call app->start?
02:07 cmihai joined #mojo
02:07 jberger you should always call app->start even if you do not start a server
02:11 jberger meshl: what does your job do when without starting a server?
02:16 meshl The job is run by cron once a day. It performs tasks that would be too long for my app to run. Remember I am using Heroku which limits the requests duration to 30 seconds...
02:17 meshl jberger: so you're saying that even if I don't want to serve anything I should call app->start? So I would call app->start before calling my lengthy tasks?
02:27 dvinciguerra joined #mojo
02:33 meshl I tried that but that does not seem to be the answer: app->start requires daemonization (or cgi, prefork, or any other command)
02:46 meshl But yeah it seems like the stash is not containing $config when app->start isn't called
02:47 sri how do you get the stash?
02:56 jberger meshl: that sounds like you have a prime candidate for a command
02:57 jberger or at least `/myapp.pl eval 'app->do_my_slow_thing'
02:57 jberger ` #ocd
02:58 d4rkie joined #mojo
02:58 sri anyway... http://mojolicio.us/perldoc/Mojolicious#build_controller
03:02 sri better yet... http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Application_embedding
03:08 jberger yeah, I know you can do the app embedding, but why not just eval some helper? seems much more to the point
03:10 sri which would be... http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Running_code_against_your_application
03:10 jberger right
03:11 asarch How do you pass an array?
03:11 sri POST ALL THE LINKS
03:11 jberger or even: http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Adding_commands_to_Mojolicious
03:11 asarch ...to the template file?
03:11 jberger asarch: stash a reference to the array
03:12 asarch $self->render(students => [@all_students]); ?
03:12 asarch % my @students = @_;
03:13 jberger ?
03:13 asarch % foreach (@students) {
03:13 jberger is students the template?
03:13 sri \@all_students is cheaper
03:13 jberger asarch: are you rendering using the ep renderer or are you making your own Mojo::Template renderer?
03:14 asarch I am using the default template system
03:14 jberger then there is no @_
03:14 asarch D'oh!
03:14 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Stash_data
03:14 jberger $self->render( mytemplate, students => \@all_students);
03:14 jberger then in the template use @$students
03:15 asarch Oh
03:16 jberger the stash is a very central concept. I highly suggest re-reading http://mojolicio.us/perldoc/Mojolicious/Lite#Stash_and_templates
03:16 asarch % foreach (@$students) {
03:16 jberger yep
03:16 asarch * <td> <%= $_->name %> </td>
03:16 asarch ?
03:18 jberger however you want to use it, its just Perl after all :-)
03:26 zivester joined #mojo
03:27 sujithm_ joined #mojo
03:29 meshl thanks guys, it's helpful
03:34 asarch Let's see. In the module: my @students; foreach ($schema->resultset('Student')->all) {my $tmp = {id => $_->id, name => $_->name}; push(@students, $tmp);} $self->render(students => \@students);
03:35 asarch In the template: % foreach (@$students) { <%= $_->id %> ...}
03:36 asarch However, "Can't call method "id" on unblessed reference at template...", why?
03:40 omega asarch: $->{id} in the template
03:40 omega for some reason you are stashing hash refs instead of the objects themselves
03:40 omega so each element in @students is a hashref, an unblessed one, so calling methods doesn't work
03:46 asarch THANK YOU!
03:46 asarch Thank you very much :-)
03:56 disputin joined #mojo
03:59 klapperl joined #mojo
04:07 laouji joined #mojo
04:44 jhg joined #mojo
04:56 laouji joined #mojo
04:59 jhg joined #mojo
05:17 voegelas joined #mojo
05:24 Eke- joined #mojo
05:43 Gedge joined #mojo
05:50 basiliscos joined #mojo
06:03 Eke|| joined #mojo
06:10 dj_goku_ joined #mojo
06:12 sujithm joined #mojo
06:31 * tempire was accepted to attend wwdc
06:32 hummeleBop joined #mojo
06:35 dpetrov_ joined #mojo
06:46 dod joined #mojo
06:51 Adura joined #mojo
06:52 rem_lex|pivo joined #mojo
07:02 Eke- joined #mojo
07:04 fhelmber_ joined #mojo
07:07 eseyman joined #mojo
07:23 hummeleBop joined #mojo
07:32 rawler joined #mojo
07:37 Eke- joined #mojo
07:39 marty joined #mojo
07:51 laouji joined #mojo
07:52 trone joined #mojo
08:00 dod joined #mojo
08:10 dod joined #mojo
08:14 Vandal joined #mojo
08:33 cmihai joined #mojo
08:38 sujithm joined #mojo
08:47 edestler joined #mojo
08:59 jhg_ joined #mojo
09:01 jhg joined #mojo
09:10 sujithm_ joined #mojo
09:21 sujithm joined #mojo
09:32 eugen joined #mojo
09:40 marty joined #mojo
09:51 d4rkie joined #mojo
09:56 marty_ joined #mojo
10:08 cmihai_ joined #mojo
10:08 d4rkie joined #mojo
10:18 ldthien0 joined #mojo
10:24 meshl joined #mojo
10:24 Jonneh joined #mojo
10:35 denis_boyun joined #mojo
10:47 ldthien0 joined #mojo
10:52 alnewkirk joined #mojo
11:14 bjoernfan joined #mojo
11:22 dod joined #mojo
11:37 neilhwatson joined #mojo
11:39 thien joined #mojo
11:49 thien joined #mojo
12:03 HtbaaPi I'm experiencing some nasty bug in Internet Explorer. When doing an AJAX call to a PUT request I send back an empty body with http status 204 (no content)
12:03 HtbaaPi but Mojolicious actually sets a content-length header in the response
12:03 HtbaaPi IE doesn't seem to like it and can take up to about 65 seconds before it considers the request to be completed
12:04 HtbaaPi content-length header has a size bigger than 0 in this case
12:04 HtbaaPi empty response is generated in this way: $self->render(json => {}, status => 204);
12:05 HtbaaPi when inspecting the request with the developer tools in the browser (any) it says there's no response body
12:06 HtbaaPi this is with Mojolicious 1.91 by the way
12:07 bjoernfan 1.91?
12:07 HtbaaPi 4.91, sorry ;)
12:07 bjoernfan That sounds better. :)
12:07 bjoernfan Can't really help you out though.
12:11 trone joined #mojo
12:12 HtbaaPi doing $self->render(text => '', status => 204); does the right thing though. But I think it's strange that doing it with json => {} results in a content-length, but no body
12:16 HtbaaPi but if status 204 makes Mojolicious not send the body (which makes sense) then the content-length should match as well
12:34 dexteruk joined #mojo
12:36 dexteruk Hi, everyone.  Anyone here in Bulgaria, I want to start a interest group in Sofia for Mojolicious
12:38 dexteruk If anyone is interested please let me know, the plan is to share knowledge and encurage developers to look at Mojolicious
12:41 neilhwatson Do mojo Commands inherit any vars from the main app?  Can any such vars be passwd to the command?
12:42 sujithm joined #mojo
12:51 crab through $self->app?
13:00 cpan_mojo Mojolicious-Plugin-RESTRoutes 0.010007 by MAXHQ - http://metacpan.org/release/MAXHQ/Mojolicious-Plugin-RESTRoutes-0.010007
13:03 DaTa left #mojo
13:04 neilhwatson crab: Doesn't look that way, though I'm still new to mojo.
13:07 cpan_mojo Mojolicious-Plugin-RESTRoutes 0.010008 by MAXHQ - http://metacpan.org/release/MAXHQ/Mojolicious-Plugin-RESTRoutes-0.010008
13:08 dotan1 joined #mojo
13:11 neilhwatson Is 'has' a mojo thing?  I don't recognize it and it's too common to search.  e.i. has description => 'Spy on application.';
13:11 crab neilhwatson: i don't know what you mean. your command's run() sub will be called, and can access the app as $self->app, where $self is the first argument passed to run
13:11 crab the remaining arguments are what comes from the command line
13:11 crab 'has' is from Mojo::Base
13:12 mire joined #mojo
13:13 cpan_mojo Mojolicious-Plugin-RESTRoutes 0.010009 by MAXHQ - http://metacpan.org/release/MAXHQ/Mojolicious-Plugin-RESTRoutes-0.010009
13:15 neilhwatson crab: A command's section would be separate file according the docs. Run the main app ./myapp <command> <args> and the command file is called. But myapp has useful vars in it and db handles. Can the commands file access those? Am I doing it all wrong?
13:22 crab isn't that what i just said
13:23 sujithm joined #mojo
13:23 crab "your command's run() sub will be called, and can access the app as $self->app, where $self is the first argument passed to run"
13:23 crab sub run { my ($self, @args) = @_; print $self->app->yummy_variables() }
13:34 arthas joined #mojo
13:46 neilhwatson I tried that and I get Can't locate object method "record_limit" via package "Mojolicious::Lite".  Is Lite the problem?
14:01 jim joined #mojo
14:08 Akron joined #mojo
14:19 crab no idea what record_limit is
14:23 neilhwatson It's a var from the main mojo lite app.
14:26 gryphon joined #mojo
14:29 hesco Trying this from last night, again as I start work this morning -- The behavior I seek is that an invalid submission reloads the previously entered data and returns the user to the form, to correct invalid data, assisted by error messages exposed on the form. I adapted from the perldoc at: https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Form-validation  and wound up with code which looks like this:  h
14:29 hesco ttps://gist.github.com/hesco/1782d63d3b9cc8cc3894  But it still does not work for me.  Seeking clues, please.  Any pointers would be appreciated. Thanks.
14:31 btyler joined #mojo
14:32 bluescreen joined #mojo
14:47 sri someone took the whole run code in your browser thing a little further http://runnable.com/
14:48 sri (perl works if you use the bash container)
14:49 bluescreen_ joined #mojo
14:55 crab neilhwatson: what do you mean by "a var"? how is it defined?
14:56 crab it won't work unless your app "has record_limit ..."
14:56 neilhwatson Thanks for the tips. I'll explore further.
15:02 HtbaaPi sri: when doing $self->render(json => {}, status => 204). Shouldn't content-length be set at 0 in the response headers?
15:11 sh4 joined #mojo
15:17 hesco Looking at this more closely, it seems that my partial data is being passed back, but that my the error messages in my template are not being rendered; and further I thought that this was not working at all because my jquery code was hiding the form.  It was dependent on a "$('div#list_options [type=radio]:not(:checked)').change( function() {" to expose the form.  When I gave it that radio button change, the form revealed with previous dat
15:17 hesco a, but w/o error messages.
15:17 marty joined #mojo
15:19 beyondcreed joined #mojo
15:19 sujithm joined #mojo
15:19 sri HtbaaPi: if you believe it's a bug please open an issue with an explanation and links to the appropriate spec sections
15:21 HtbaaPi I'm not sure it's a bug :-). But when setting status 204 no body content is sent, but the content-length header doesn't resemble that
15:27 sugar_ joined #mojo
15:30 mire joined #mojo
15:33 hesco left #mojo
15:33 hesco joined #mojo
15:35 hesco My id does not make it out to the html source when I render this:  %= select_field 'student.facility_state' => TFC::LandingPages::get_states $self, id => 'state
15:36 hesco Any idea why?  I'm pretty sure this used to work.  but the jquery on the front end no longer finds the id it needs to function correctly.
15:41 hesco left #mojo
15:42 hesco joined #mojo
15:43 hesco This line from my template no longern seems to pass the id out to the html source, resulting in broken jquery code on the front end.  What have I gotten wrong here, please?
15:43 hesco %= select_field 'inmate.facility_state' => TFC::LandingPages::get_states $self, id => 'state
15:44 hesco hopefully I am actually connected to irc this time.  Saw no evidence of that the last time I tried to post this question a few minutes ago.
15:48 HtbaaPi you are connected :)
15:49 hesco yes, thanks.  seems to be working better now
15:49 hesco thanks HtbaaPi
15:59 tianon hesco: it looks like a list context problem ;)  try adding parenthesis to your get_states call
15:59 tianon ie, %= select_field 'inmate.facility_state' => TFC::LandingPages::get_states($self), id => ...
16:00 tianon otherwise, 'id' and friends become arguments to get_states instead of to select_field ;)
16:00 hesco tianon: thanks, will try that.
16:04 asarch joined #mojo
16:09 sri there's a link to the channel log in the topic
16:10 sri you can always check there
16:15 dotan1 What's a good namespace for a module that depends on Mojolicious but isn't quite a plugin? MojoX:: looks deprecated, Mojo:: feels presumptuous. I thought of MojoY:: (Mojo Joy, get it?), but that's a very stupid idea.
16:17 dotan1 I also have no good idea what to call my module. It's a rate-limiting wrapper for Mojo::UserAgent (sorta like jberger's URLQueue example), and the best I can come up with so far is IOUserAgent, which is terrible.
16:17 dotan1 I'll get laughed off cpan
16:22 crab yes, all modules on CPAN must have very serious, well-thought-out names
16:22 crab like Mojo::UserAgent::RateLimitingWrapper
16:23 hesco tianon: thank you sir.  those parens fixed my issue.  Thank you very much
16:31 sri Bender: trust Akron
16:31 Bender OK, sri
16:32 Akron \o/
16:34 sri Bender: trust marty
16:34 Bender OK, sri
16:35 sujithm joined #mojo
16:47 mire joined #mojo
16:55 gryphon joined #mojo
16:58 denis_boyun joined #mojo
17:00 sugar_ joined #mojo
17:06 sugar__ joined #mojo
17:08 cmihai joined #mojo
17:11 marty_ joined #mojo
17:11 beyondcreed joined #mojo
17:17 sugar joined #mojo
17:22 cfedde is there a method for decoding html entities somewhere?
17:27 beyondcreed joined #mojo
17:32 Akron cfedde: Mojo::Util and Mojo::ByteStream.
17:32 dod joined #mojo
17:33 Akron cfedde: http://search.cpan.org/~sri/Mojolicious-4.92/lib/Mojo/Util.pm#html_unescape
17:42 hesco is there an easy way to attach: <span class="error"></span> to every data validation message, w/o replicating that code throughout my templates?
17:50 lb hesco: for various values of easy, you could replace the tag_with_error helper in Mojolicious::Plugin::TagHelpers
17:55 dod joined #mojo
18:08 vmmello___ joined #mojo
18:08 cfedde Akron++ thanks
18:10 sugar joined #mojo
18:25 neilhwatson In package Mojolicious::Command::spy; where does the app expect to find spy.pm?
18:25 neilhwatson app/lib ?
18:26 dvinciguerra joined #mojo
18:39 bjoernfan neilhwatson: MyApp/lib/Command/spy.pm
18:41 neilhwatson And if your lib dirs resemble lib/Myapp/...  would it be lib/Myapp/Command/spy.pm?
18:44 bjoernfan ... yes, sorry, of course. :P
18:47 mire joined #mojo
18:47 bjoernfan neilhwatson: https://github.com/bjoernfan/Mojochrome here's one of my projects if you want to have a look, I use a few simple commands there.
18:48 neilhwatson Does that change the package name from Command::spy to Command::Myapp::spy ?  I can't get it to load.  Thanks will loook.
18:49 bjoernfan Did you do the push in startup?
18:52 neilhwatson That was it.  Thank you.
18:53 bjoernfan Wow... startssl.com, that nice free cert agency... want $25 to revoke a certificate.
18:56 bjoernfan "Class 1 subscribers may use a different sub domain in order to create additional certificates without the need to revoke a previously created certificate" hmm
18:59 bjoernfan https://twitter.com/startssl I'm not the first one I guess
19:01 crab no
19:01 crab lib/Mojolicious/Command/spy.pm, not lib/Command/spy.pm
19:02 crab not lib/Myapp/Command/spy.pm
19:02 crab a package named X::Y::Z must (a) have a "package X::Y::Z;" in it, and (b) live in $LIBDIR/X/Y/Z.pm
19:03 neilhwatson Yeah figures that out.  The example confused me.
19:09 bjoernfan crab: Hm. Isn't mine fulfilling those requirements?
19:09 rj11 Is it somehow possible to tell Mojolicious to send specific headers when serving a static file of type X?
19:10 bjoernfan crab: Sure I might have it wrong for other reasons. :)
19:10 rj11 I want Access-Control-Allow-Origin: * to be included when serving font files.
19:10 neilhwatson bjoernfan: I think you are OK. I think the example should show something other than Mojolicious to show that the choise is arbitriary and not static.
19:11 bjoernfan neilhwatson: Oh, I thought you meant my code by "example", but you're thinking of the docs?
19:12 neilhwatson Yes.  Your code showed that it could be arbitrary, but the doc's use of Mojolicious lead me to believe it was static.
19:12 bjoernfan ah
19:15 neilhwatson I'm not up on OO Perl and still new to Mojo.  Can "has" be explained as a way to share variables between components?
19:15 neilhwatson rj11: Perhas something in then renderer page: http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering
19:16 good_news_everyone joined #mojo
19:16 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/O7ngHg
19:16 good_news_everyone mojo/master ea714cc Sebastian Riedel: link to attribute
19:16 good_news_everyone left #mojo
19:16 rj11 neilhwatson: Yeah, I can do it with $c->render() but then I have to implement a specific controller/action for serving those files instead of relying on Mojolicious::Static.
19:21 crab bjoernfan: don't know, didn't look
19:21 crab (at your code)
19:22 crab rj11: no, you can't, but you can implement your own static dispatcher by inheriting from the default one
19:22 crab rj11: and then do app->static(Rj11Static->new)
19:22 sri crab: actually not quite correct
19:22 crab you can't implement your own static dispatcher?
19:22 sri http://mojolicio.us/perldoc/Mojolicious#after_static
19:23 sri the hook should do
19:23 crab oh, sorry. of course it should do.
19:23 rj11 Nice! Thanks guys! :)
19:23 sri in fact, there's an example here too http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Hooks
19:23 ua_ joined #mojo
19:24 marty joined #mojo
19:26 sri actually reminds me that i was thinking about a Mojo::Path::ext method that extracts and normalizes the file extension
19:27 sri $c->res->headers->cache_control(...) if $c->req->url->path->ext eq 'png';
19:31 crab i wish it were possible to tell the static dispatcher "DefaultType text/html".
19:31 crab but it seems... well, not the most useful thing to do in general.
19:32 sri actually... i think i'l try not to add new stuff before mojoconf
19:33 vmmello joined #mojo
19:38 genio How do you accurately determine the extension.  I mean with .tar.gz  you could just call it a gzipped container, but it's a gzipped tarball.  files with no extension? do you rely on the mime type?    Sorry, a lot of curiosity pouring out all at once.
19:43 davido_ joined #mojo
19:43 good_news_everyone joined #mojo
19:43 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/0tewtw
19:43 good_news_everyone mojo/master 2734ce6 Sebastian Riedel: fixed bug where Mojolicious::Static would not use the correct default MIME type
19:43 good_news_everyone left #mojo
19:52 good_news_everyone joined #mojo
19:52 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/zGycpg
19:52 good_news_everyone mojo/master 6a98983 Sebastian Riedel: fixed another MIME type bug in Mojolicious::Static
19:52 good_news_everyone left #mojo
19:58 sri wow... what a mess... https://bugzilla.mozilla.org/show_bug.cgi?id=994033
20:00 crab hah, now i can just redefine 'txt' to 'text/html' and it'll work :-)
20:01 crab but would i be able to live with myself if i did that?
20:08 bjoernfan sri: ... wow... I just created new (free) certs for my private domains (from startssl), not sure what to do about my old ones though. They expire "soon enough", but... yeah... doesn't feel too good.
20:08 bjoernfan Was looking into paying them, but even if you upgrade they want you to pay for revoking the old certs, which I don't really like.
20:09 denis_boyun joined #mojo
20:11 bjoernfan And I'm very suprised browsers don't check revocation lists...
20:36 vmmello___ joined #mojo
20:49 punter joined #mojo
20:59 espent joined #mojo
21:36 disputin joined #mojo
22:10 disputin joined #mojo
22:36 d4rkie joined #mojo
22:37 disputin joined #mojo
22:42 davido_ joined #mojo
22:52 disputin joined #mojo
22:53 disputin joined #mojo
22:56 phips joined #mojo
23:01 disputin joined #mojo
23:38 asarch joined #mojo

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