[Catalyst] Checking if I can visit a URL
Hi! I'm using Catalyst::ActionRole::ACL successfully - thanks for a great addition to Catalyst. In my templates, I'd like to check if I can get to a specific action because I only want to show links where you can go to. At the moment, I am using the equivalent role information (eg, $c- user-can_access_role(VIEW)), but this means I am not DRY because the /objects is already blocked with VIEW role. Is there a way I can say $c-can_visit(/objects) instead? Looking in Catalyst::ActionRole::ACL there is a can_visit method, but I don't understand how I can invoke that from my own code. Is this possible? Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Catalyst needs Advent Calendar Volunteers!
On 17 Nov 2010, at 18:01, Devin Austin wrote: It's that time again. Catalyst needs volunteers for the Advent Calendar, so we need both article authors and cat herders to make sure we have articles for each day. I'll commit to writing one re: how Opsview does i18n with Catalyst (which I said I would ages ago - just reminding! ) Do you have any notes about where and what format? Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] I18N with variables
On 6 Aug 2010, at 15:57, Bill Moseley wrote: I've been arguing with work about how to key our text. So far we continue to use the English in the loc() tags in the templates, and then the I18N team uses a script to pull out this text which gets sent to translation services. For Opsview (http://opsview.com), we decided early on to use message ids. I'm very glad of this decision (after pain in my work on the Nagios Plugins using English text as the key). After chatting to a Java guy who already implemented i18n in his app, we went with a dotted notation like: [% c.loc(ui.admin.host.edit.label.hostaddress) %] The dotted notation is good because it gives a pretty good idea where in the app this text will be found. The last part can be as complex as you like to describe the content. Variables work with: [% c.loc(ui.admin.host.edit.label.numberOfAddresses [_1], num_addresses) %] Obviously, there needs to be an English translation. This is when I spent about 10 hours of my life trying to work out how Locale::Maketext::Simple was not doing a fallback as I expected. A patch was made and thankfully this works properly now if you set your .po file to be called i_default.po: http://cpansearch.perl.org/src/JESSE/Locale-Maketext-Simple-0.19/Changes I run a make gettext in my cat app that calls xgettext.pl and some other perl code to check for missing strings in i_default.po. It also updates all our language files with any new msgids but sets msgstr to . This is good because: (1) Locale::Maketext::Simple will now fallback to i_default.po and (2) anyone translating the .po files can easily see which strings still need translating. So overall I think our workflow is pretty good. I can write a Cat advent calendar entry for this if interested. Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] I18N with variables
On 2 Aug 2010, at 06:08, Julien Sobrier wrote: Hello, I've started to translate my website using Catalyst::Plugin::I18N. It works fine for static text. Bu I can't make it work for variables. For example, I need to a translation for [% foo %] where for can take a set of values defined in a database. I'm sot sure what is the best way to translate such variables, and what is possible: * add a msgid for each possible value in messages.po = those gets removed every time I run xgettext.pl * Make the translation in my Database layer = unfortunately I use the old Class::DBI, and could not find a plugin for it * any other option? What I do is use the variable to work out the dynamic name, and then in a dummy template file, have the possible options. Eg: [% menu_name=Configuration; c.loc(menu_name) %] Then in a dummy template file, have: [% c.loc(Configuration) %] This way xgettext.pl will always find it to put into messages.po. It means having to write in the dummy template all the possibilities, but it would have to be captured somewhere, so it might as well be in something that xgettext.pl can process. Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Trapping exceptions in Catalyst.pm
On 2 Aug 2010, at 07:49, Bill Moseley wrote: In execute() there's this code: eval { $c-state( $code-execute( $class, $c, @{ $c-req- args } ) || 0 ) }; $c-_stats_finish_execute( $stats_info ) if $c-use_stats and $stats_info; my $last = pop( @{ $c-stack } ); if ( my $error = $@ ) { The problem is that it's possible for the eval to fail but $@ is not set. An example is where Locale::Maketext localizes $@ so that exceptions come back with $@ undefined (for some odd reason). In general, it's better to test the return value from eval directly instead of depend on $...@. Something like: my $has_exception; eval { $c-state( $code-execute( $class, $c, @{ $c-req-args } ) || 0 ); 1; } || $has_exception++; ... if ( $has_exception ) { Or use the eval {; 1 } || do { my $msg = $@; ...}; style. I did a bit of work in DBIx::Class where I changed all the eval statements to using Try::Tiny instead. Not sure if it got into trunk yet. A similar conversion here would work. Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] I18N with quotation marks
On 2 Jul 2009, at 09:35, Ton Voon wrote: Does everyone agree this makes sense? If so, any objections if I add this to http://dev.catalystframework.org/wiki/best_practices? I've added a section at http://dev.catalystframework.org/wiki/best_practices now. This includes Jose Luis Martinez's suggestions for the escape_js_string routine, implemented as a TT filter. Final question: How do you internationalise a bit of text that does want some markup within it? For instance, I want something that outputs: Click a href=/abouthere/a for the about page. If I do something like: link = 'a href=/about' _ c.loc(here) _ '/a'; c.loc(Click %1 for the about page, link) Then I cannot filter through html for the 2nd loc output. Is there a nicer way? Ton___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] I18N with quotation marks
Hi! I wanted to find out how other people are handling this problem. I am localising our app, which consists of strings in html and in dynamic javascript snippets. However, if the translated value contains quotations (such as: s'il vous plait), then it could break the HTML: select value='[% c.loc(Please select one) %]' or the javascript: alert('[% c.loc(Please select one) %]'); We also sometimes use double quotes for attributes instead of single quotes. What is the best practise? Always run c.loc() through a filter to convert to HTML entities? (Although in FF3.0 alert('Impossible d#39;exécuter snmpget pour tester la connexion'); does not give the single quote). I was considering creating methods of c.hloc() (for a html environment) and c.jloc() (for a javascript environment), but then the xgettext.pl helper does not look for these method names. Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Killing the standalone perl server programatically
On 12 Jun 2009, at 15:31, Stefan Washietl wrote: Kieren Diment wrote: sub quit : Local { exit 1; } This is exactly what I tried and would be the prefered solution. Sorry if I only implicitely mentioned that I use the -fork option. In that case it does not work, or more specifically, does not shut down the server as I had expected. In fact nothing happens, I don't get any feedback in the debug output and and I get an empty response from the server. You've set the fork option. That means every request to the dev server is forked. So the exit statement means the forked process is finished. The main one, listening on port 3000, is still running. It is possible to set a method to do a RESTART on the main process (see the C::E::HTTP.pm code), so I guess a new method of EXIT might do the trick here. You would want to limit which clients can send this method though. Ton ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] using Catalyst with legacy cgi scripts
On 7 Dec 2007, at 19:53, Ashley Pond V wrote: Please do put this up. I can definitely see using it (maybe on something right now) and I think many others would end up using it in a Registry.pm-like way to segue into a shinier codebase. Any new trails on the migration path to Cat help everyone eventually b/c it will build up the community. OK. Can someone bootstrap the Catalyst way of testing Controller code please? I can add the code specific testing, but I don't really know how to test a controller properly. I'm happy to add documentation, the Module::Install and maybe even an advent entry. Can I have a commit bit for this portion of the svn tree? Ton http://www.altinity.com UK: +44 (0)870 787 9243 US: +1 866 879 9184 Fax: +44 (0)845 280 1725 Skype: tonvoon ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] using Catalyst with legacy cgi scripts
Hi Gerda, On 7 Dec 2007, at 16:27, Gerda Shank wrote: I'm developing some new parts of our web application in Catalyst, but when it comes time to deploy it will have to coexist with a bunch of legacy Perl cgi scripts. Eventually I'd like to replace them all, but it will have to be done piece by piece. The current system runs on Apache, with just CGI, and we will be switching to FastCGI (probably). Some parts of it (the help system) are purely static, but most of it is dynamically constructed (lists of today's papers, etc.) What would be best practice for deploying this mess together? It seems like I would have to skip the Catalyst routing altogether for the cgi scripts, right? One approach is to get Apache to serve your CGIs directly and use a different path for the Catalyst app. Another, is to get Catalyst to deliver the CGIs. For Opsview (http://opsview.org ), we wanted to wrap Nagios' CGIs to make it work like normal Catalyst pages (with sidenavs, footers and ajax updates). So we used this wrapping technique which runs the CGI, grabs the output, puts it back into the stash for us to then manipulate before rendering it in the view. I would say to use this wrapping technique if there is something special you want to do to the CGIs and you don't have much control over the original CGI code. This was originally written for us by Shadowcat, but we've agreed to publishing it and Matt has placed it as CatalystX::Controller::WrapCGI on the Catalyst svn tree: http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Controller-WrapCGI/ I've offered to Matt, offlist, that I'd be willing to spend the time on polishing this module up for CPAN release. If there's interest here, that will sway the decision. Ton http://www.altinity.com UK: +44 (0)870 787 9243 US: +1 866 879 9184 Fax: +44 (0)845 280 1725 Skype: tonvoon ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/