Re: [Catalyst] Advent Calendar
On 28/12/06, Jon [EMAIL PROTECTED] wrote: On Wed, 2006-12-27 at 11:30 -0500, Kenny Gatdula wrote: Hi, I agree with you that a table of contents would be useful. Maybe next year? In the meantime, this will work. http://dev.catalyst.perl.org/wiki/DocLinks/AdventCalendar2006 That's great, thanks. Also, you can just use the RSS feed. We'll edit this stuff up into something a bit more polished at some point in 2007 as well, hopefully. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] What to use ? HTML::Widget ? Data::FormValidator ? etc...
Hello dear list, I'm currently in the early stage of writing a Catalyst application (in fact redesigning a non-Catalyst one) and I'm wondering what plugins to use. I've already written Catalyst applications successfully but for this one I've decided those constraints : - Use TT as view - Use a form validator - Not necessarily use a widget creation plugin - I18n - Reuse the most possible code / templates and be very modular In fact I have some precise questions, but advices are welcome: 1) I've searched the HTML::Widget docs and ML archives to look for i18n stuff but found nothing :-( I subscribed to the ML but before asking them the question, can you tell me if HTML::Widget is the Right Plugin (new TM) for my application? 2) Doesn't HTML::Widget break the MVC model by putting part of the view creation in the code? 3) If HTML::Widget is not the Right Plugin to use, what other plugin should I use? 4) And, more generally, what is the best practice to use i18n with the constraints above? What could you counsel me? I understand that some questions could seem OT but this is really a Catalyst design problem. Thanks! -- -- \^/-- ---/ O \----- -- | |/ \| Alexandre (Midnite) Jousset | -- ---|___|----- ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] What to use ? HTML::Widget ? Data::FormValidator ? etc...
Alexandre Jousset wrote: Hello dear list, I'm currently in the early stage of writing a Catalyst application (in fact redesigning a non-Catalyst one) and I'm wondering what plugins to use. I've already written Catalyst applications successfully but for this one I've decided those constraints : - Use TT as view - Use a form validator - Not necessarily use a widget creation plugin - I18n - Reuse the most possible code / templates and be very modular In fact I have some precise questions, but advices are welcome: 1) I've searched the HTML::Widget docs and ML archives to look for i18n stuff but found nothing :-( I subscribed to the ML but before asking them the question, can you tell me if HTML::Widget is the Right Plugin (new TM) for my application? If its possible to localize strings in a controller: $c-loc('foo') then you can localize labels/constraints etc. 2) Doesn't HTML::Widget break the MVC model by putting part of the view creation in the code? Yes, basically. (Saying that i still use it cos I only use it in a few places and its not annoyed me enough to replace it) 3) If HTML::Widget is not the Right Plugin to use, what other plugin should I use? You should also look at Data::FormValidator (i think thats the name) and Catalyst::Controller::FormBuilder (its a base class for you controllers, not a plugin) 4) And, more generally, what is the best practice to use i18n with the constraints above? What could you counsel me? Pass - I've not had to do any L10n yet I understand that some questions could seem OT but this is really a Catalyst design problem. Thanks! Ash ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] What to use ? HTML::Widget ? Data::FormValidator ? etc...
Alexandre Jousset wrote: - Use TT as view - Use a form validator - Not necessarily use a widget creation plugin - I18n - Reuse the most possible code / templates and be very modular Catalyst::Controller::FormBuilder does all that. It also auto-generates client-side validation logic for you, so you can save poor typists a roundtrip. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] What to use ? HTML::Widget ? Data::FormValidator ? etc...
Jonathan Rockway wrote: Alexandre Jousset wrote: - Use TT as view - Use a form validator - Not necessarily use a widget creation plugin - I18n - Reuse the most possible code / templates and be very modular Catalyst::Controller::FormBuilder does all that. It also auto-generates client-side validation logic for you, so you can save poor typists a roundtrip. Great, this is exactly what I was looking for. Thank you! -- -- \^/-- ---/ O \----- -- | |/ \| Alexandre (Midnite) Jousset | -- ---|___|----- ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
RE: [Catalyst] debugging the login
From: Octavian Rasnita [mailto:[EMAIL PROTECTED] Sent: Thursday, December 28, 2006 04:19 Subject: [Catalyst] debugging the login Hi, Is there a way to see what's happening when doing: $c-login($username, $password); I found that each time the login is ok (the username and the password are valid), the application gives a 404 Not Found error, and I want to see what's happening. I guess something's wrong when saving the local session files, or the cookies, or something like this. Thanks. Octavian Are you using IE? Run your test server with the -k switch (i.e. script/myapp_server.pl -k). You can read in previous Catalyst threads that IE has a cookie setting problem and won't login properly if you don't enable keep-alive connections. Leandro ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] accessing the name of the logged user
Hi, Can you tell me how can I access the name of the currently logged user for printing it in a TT template? I have tried: if ($c-user_exists) { $c-stash-{user} = $c-user; } But it gives the following error: Coldn't render template undef error - Can't call method from_session on an undefined value at D:/usr/site/lib/Catalyst\Plugin\Authentication.pm line 122. I have spent a lot of time for finding that this is the problem, and I even found some threads on the list about this issue, but the only solution I have seen was to downgrade from C::P::Authentication 0.08 to 0.007, or to upgrade to 0.09. I am already using the version 0.09 though. If I use the following static text, it works: if ($c-user_exists) { $c-stash-{user} = Gigi; } So the issue is using $c-user. How can I access the user in another way that doesn't give errors? I have also tried (in the code and templates): $c-user-name $c-user-username [% c.user %] But all of them use in fact $c-user, so of course they didn't work. Thank you very much for any solution. Octavian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] debugging the login
From: Hermida, Leandro [EMAIL PROTECTED] Are you using IE? Run your test server with the -k switch (i.e. script/myapp_server.pl -k). You can read in previous Catalyst threads that IE has a cookie setting problem and won't login properly if you don't enable keep-alive connections. Leandro Finally I have solved that issue, but I have another one that might because Of Catalyst::Plugin::Authentication bug, or something else, because if I have [% c.user %] in a template, the application gives an error, even though there is a logged user. (I've verified that using $c-user_exists). Thank you. Octavian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] accessing the name of the logged user
I hope this help you: sub login_sc : Local { my ( $self, $c ) = @_; $c-login( $c-req-params-{username}, $c-req-params-{password} ); my $u = $c-session-{__user}; if ($u $c-user_object-roles) { my $rol = $c-user_object-roles-next; etc... if($c-user_exists) { my $u = $c-session-{__user}; etc... --vb On 12/28/06, Octavian Rasnita [EMAIL PROTECTED] wrote: Hi, Can you tell me how can I access the name of the currently logged user for printing it in a TT template? I have tried: if ($c-user_exists) { $c-stash-{user} = $c-user; } But it gives the following error: Coldn't render template undef error - Can't call method from_session on an undefined value at D:/usr/site/lib/Catalyst\Plugin\Authentication.pm line 122. I have spent a lot of time for finding that this is the problem, and I even found some threads on the list about this issue, but the only solution I have seen was to downgrade from C::P::Authentication 0.08 to 0.007, or to upgrade to 0.09. I am already using the version 0.09 though. If I use the following static text, it works: if ($c-user_exists) { $c-stash-{user} = Gigi; } So the issue is using $c-user. How can I access the user in another way that doesn't give errors? I have also tried (in the code and templates): $c-user-name $c-user-username [% c.user %] But all of them use in fact $c-user, so of course they didn't work. Thank you very much for any solution. Octavian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
RE: [Catalyst] debugging the login
From: Hermida, Leandro [EMAIL PROTECTED] Are you using IE? Run your test server with the -k switch (i.e. script/myapp_server.pl -k). You can read in previous Catalyst threads that IE has a cookie setting problem and won't login properly if you don't enable keep-alive connections. Leandro Finally I have solved that issue, but I have another one that Hi Octavian, I am really curious how you solved this issue. I still have exactly the same problem as you described but was not able to solve it. The only thing that helps in my case is to manually delete the cookie. Also, it happens not only with the myapp_server, but deployed in apache as well. What did you do to make it work for IE ??? Regards, Marc ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] accessing the name of the logged user
Thank you very much. I've tested and it works fine this way. But why is not working $c-user? It is not recommended to use it, or it may conflict with another part of my program? If $c-user should not be used in some cases, I think it is a good idea to specify this in the Catalyst docs, and present some alternatives. Thank you for help. Octavian - Original Message - From: vb To: The elegant MVC web framework Sent: Thursday, December 28, 2006 11:09 PM Subject: Re: [Catalyst] accessing the name of the logged user I hope this help you: sub login_sc : Local { my ( $self, $c ) = @_; $c-login( $c-req-params-{username}, $c-req-params-{password} ); my $u = $c-session-{__user}; if ($u $c-user_object-roles) { my $rol = $c-user_object-roles-next; etc... if($c-user_exists) { my $u = $c-session-{__user}; etc... --vb On 12/28/06, Octavian Rasnita [EMAIL PROTECTED] wrote: Hi, Can you tell me how can I access the name of the currently logged user for printing it in a TT template? I have tried: if ($c-user_exists) { $c-stash-{user} = $c-user; } But it gives the following error: Coldn't render template undef error - Can't call method from_session on an undefined value at D:/usr/site/lib/Catalyst\Plugin\Authentication.pm line 122. I have spent a lot of time for finding that this is the problem, and I even found some threads on the list about this issue, but the only solution I have seen was to downgrade from C::P::Authentication 0.08 to 0.007, or to upgrade to 0.09. I am already using the version 0.09 though. If I use the following static text, it works: if ($c-user_exists) { $c-stash-{user} = Gigi; } So the issue is using $c-user. How can I access the user in another way that doesn't give errors? I have also tried (in the code and templates): $c-user-name $c-user-username [% c.user %] But all of them use in fact $c-user, so of course they didn't work. Thank you very much for any solution. Octavian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ -- ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] debugging the login
Octavian Rasnita wrote: From: Hermida, Leandro [EMAIL PROTECTED] Are you using IE? Run your test server with the -k switch (i.e. script/myapp_server.pl -k). You can read in previous Catalyst threads that IE has a cookie setting problem and won't login properly if you don't enable keep-alive connections. Leandro Finally I have solved that issue, but I have another one that might because Of Catalyst::Plugin::Authentication bug, or something else, because if I have [% c.user %] in a template, the application gives an error, even though there is a logged user. (I've verified that using $c-user_exists). Thank you. Octavian Something else is the case here. If you try $c-user; in a controller I suspect it will give you same error as from the template. As to the exact cause, hard to say, but its something to do with authentication setup. Ash ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Anyone with PHP / Smarty Background
Hi, I've been programming in PHP for about 6 years, and using the Smarty template engine for about 3 years, so I've gotten pretty proficient at them. I can see the need for something like Catalyst or Ruby on Rails, but it's a big shift. Anyone here with a background in PHP / Smarty that can share their perspective and whether the switch has been worth it? How does the speed and stability compare? Can you develop faster in Catalyst than you could in PHP / Smarty? Thanks! Brian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone with PHP / Smarty Background
Thanks for the quick reply. Very helpful and encouraging. What is the best way to go from PHP to Catalyst? I used to program in Perl, so I'll learn / remember that fast. Are there any open source applications running on Catalyst / TT that I could install and poke around in to get a feel for it? Any tutorials or introductions that were helpful for you, or that you wish you had when you made the transition? I really appreciate the feedback and direction. Thanks, Brian Christopher Heschong wrote: Hi Brian, I spent years as a successful PHP programmer with some pretty complicated apps out there. I've found that with Catalyst I can write much cleaner code in a few lines that do what I used to do with pages and pages of PHP. Plus, with Perl you get all the great libraries from CPAN available to you. Stability is great, I've handled hundreds of thousands of hits in a day with no issues (mod_perl). I haven't had any problems with speed, although I would say that raw PHP is probably faster if you were to benchmark it on simple things. The things to get used to are: - The MVC pattern isn't how most PHP apps are constructed. It takes some major getting used to, but is worth it in the long run. - Everything is Object Oriented (or should be) in Catalyst. This is a big shift if you haven't been living that life in PHP. Database access is nicer with things like DBIx::Class or Class::DBI, but different somewhat than what you may be used to. Ends up being more elegant, imho. - If you're using mod_perl on Apache it takes a while to get used to the fact that you can't just copy some files into some directory somewhere, you have to actually *install* (or add the libs to your path). This is more of a PHP vs Perl thing, and maybe fastcgi addresses this. - Mapping URLs to actions and subroutines in Catalyst is SO EASY, it's like falling down. Grabbing stuff from the database is SO EASY. Session management is SO EASY, etc. You'll end up wondering how your apps got so small and took such a short time to create. Template Toolkit (TT) has a lot of the same feel as Smarty. Instead of: {$something} You would write: [% something %] Also, TT allows plugins like Smarty does, so extending it is pretty easy to do if you like that. On Dec 28, 2006, at 10:12 PM, Brian wrote: Hi, I've been programming in PHP for about 6 years, and using the Smarty template engine for about 3 years, so I've gotten pretty proficient at them. I can see the need for something like Catalyst or Ruby on Rails, but it's a big shift. Anyone here with a background in PHP / Smarty that can share their perspective and whether the switch has been worth it? How does the speed and stability compare? Can you develop faster in Catalyst than you could in PHP / Smarty? Thanks! Brian ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone with PHP / Smarty Background
Yep. The one thing that confused me and has confused every new developer on my team is the View in Catalyst's Model/View/ Controller. They always expect that's where they'll generate the HTML or whatever, ala PHP. This isn't exactly the case. 99% of the time you'll have Catalyst create a Template Toolkit view for you, which will basically be empty. That's the only code (usually) that will go in your Yourapp/lib/Yourapp/View/ directory. What you're likely to expect the View part to be is really the template files you put in the Yourapp/root/ directory, and that's not always clear at the start. These template files are to some extent the View, but they don't sit in the View directory. Getting a good grasp of the MVC structure of Catalyst is key. Basically most of the actual perl code you write won't display anything, it will just set variables in the stash, and your template files (in root) will display those variables. The Intro in the Catalyst manual is pretty good: http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/ Intro.pod Tons of info on the Catalyst Wiki (some of it out of date): http://dev.catalystframework.org/wiki Tons of example code here: http://dev.catalystframework.org/browser/trunk/examples Another handy example: http://www.herlpacker.co.uk/tech/development/projects/parley/ And this is fun: http://search.cpan.org/search?m=allq=Catalyst+Plugin When I was learning TT, it took me a while to realize that the docs weren't in the Template pod, it was in the Template::Manual::* pod docs: http://search.cpan.org/dist/Template-Toolkit/lib/Template/Manual/ Intro.pod http://search.cpan.org/dist/Template-Toolkit/lib/Template/Manual/ Syntax.pod For PHP-style parameter arrays, take a look at Catalyst::Plugin::Params::Nested: input name=search[name] / input name=search[address] / turn into a hashref you can pass around, or access directly: my $foo = $c-req-param('search'); $foo-{name}; $foo-{address}; This is really nice when you want to do something like this: sub search : Local { my ($self, $c) = @_; $c-stash-{results} = $c-model('Something')-search( $c-req-param('search') ); } which will basically connect to the database, do a SELECT * FROM some_table WHERE name = 'form input' AND address = 'form input', grab the results, stick them in the stash, and then it's off to your template (named search.tt by default since the sub is called search) to display. Of course, in the real world you probably want to check the input a little more stringently, but DBIx::Class does prevent quite a few SQL-injection type attacks by using something called binding... anyway, I'm getting off the subject. Hope that helps you get started. On Dec 29, 2006, at 12:06 AM, Brian wrote: Thanks for the quick reply. Very helpful and encouraging. What is the best way to go from PHP to Catalyst? I used to program in Perl, so I'll learn / remember that fast. Are there any open source applications running on Catalyst / TT that I could install and poke around in to get a feel for it? Any tutorials or introductions that were helpful for you, or that you wish you had when you made the transition? I really appreciate the feedback and direction. Thanks, Brian smime.p7s Description: S/MIME cryptographic signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone with PHP / Smarty Background
Thank you! That is exactly the information and head start I was after. Now I have to name my first born son Christopher. 3 daughters so far, so you may have to settle for Christina. Thanks again, Brian Christopher Heschong wrote: Yep. The one thing that confused me and has confused every new developer on my team is the View in Catalyst's Model/View/Controller. They always expect that's where they'll generate the HTML or whatever, ala PHP. This isn't exactly the case. 99% of the time you'll have Catalyst create a Template Toolkit view for you, which will basically be empty. That's the only code (usually) that will go in your Yourapp/lib/Yourapp/View/ directory. What you're likely to expect the View part to be is really the template files you put in the Yourapp/root/ directory, and that's not always clear at the start. These template files are to some extent the View, but they don't sit in the View directory. Getting a good grasp of the MVC structure of Catalyst is key. Basically most of the actual perl code you write won't display anything, it will just set variables in the stash, and your template files (in root) will display those variables. The Intro in the Catalyst manual is pretty good: http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Intro.pod Tons of info on the Catalyst Wiki (some of it out of date): http://dev.catalystframework.org/wiki Tons of example code here: http://dev.catalystframework.org/browser/trunk/examples Another handy example: http://www.herlpacker.co.uk/tech/development/projects/parley/ And this is fun: http://search.cpan.org/search?m=allq=Catalyst+Plugin http://search.cpan.org/search?m=allq=Catalyst+Plugin When I was learning TT, it took me a while to realize that the docs weren't in the Template pod, it was in the Template::Manual::* pod docs: http://search.cpan.org/dist/Template-Toolkit/lib/Template/Manual/Intro.pod http://search.cpan.org/dist/Template-Toolkit/lib/Template/Manual/Syntax.pod For PHP-style parameter arrays, take a look at Catalyst::Plugin::Params::Nested: input name=search[name] / input name=search[address] / turn into a hashref you can pass around, or access directly: my $foo = $c-req-param('search'); $foo-{name}; $foo-{address}; This is really nice when you want to do something like this: sub search : Local { my ($self, $c) = @_; $c-stash-{results} = $c-model('Something')-search( $c-req-param('search') ); } which will basically connect to the database, do a SELECT * FROM some_table WHERE name = 'form input' AND address = 'form input', grab the results, stick them in the stash, and then it's off to your template (named search.tt by default since the sub is called search) to display. Of course, in the real world you probably want to check the input a little more stringently, but DBIx::Class does prevent quite a few SQL-injection type attacks by using something called binding... anyway, I'm getting off the subject. Hope that helps you get started. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/