Re: [Catalyst] Best practice: How to build app parts reusable?
On Sun, May 31, 2009 at 6:06 PM, Matthias Dietrich mdietr...@cpan.org wrote: Hi, in one of my Catalyst apps I'm building application parts that I want to reuse in other Catalyst apps where possible. What's the best practice to do that? I mean the complete parts from controller, to model, DBIC schema classes and templates. Let's assume one part is a guestbook (no, it's not but it's a funny example ;)). The integration of the controller class is very easy. I just would build a new controller inside the app which uses the guestbook controller as base class and sets the correct namespace, where the guestbook should appear. A similar procedure would get me the model and schemes into my app, but it requires a wrapper class for each class the guestbook brings with. And the templates? The only way I know of is to copy and paste them into the 'root' folder of the app. Just one idea - in the TT view there is a http://search.cpan.org/~mramberg/Catalyst-View-TT-0.29/lib/Catalyst/View/TT.pm#DYNAMIC_INCLUDE_PATH option. I have never eventually used that - but when I was adding it what I had in mind was something like template inheritance. By splitting the templates into separate files you can use it to override those individual templates just like you can override methods in a class. The difference is that a class is a file and method is a part of that file - here the the corresponding things are a directory and an individual template. There has to be a better way. But which? I'm also thinking about whole reusable applications. For example a shopping system which can be extended and modified by overwriting methods while the base system can be upgraded seamlessly. (I know MojoMojo as a standalone Catalyst app, but it's only standalone and not to be extended locally.) There is Handel - I have never explored it but I think the design goal was to make it extendable. -- Zbigniew Lukasiak http://brudnopis.blogspot.com/ http://perlalchemy.blogspot.com/ ___ 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] error when using Authentication::Store::Minimal
Could anyone provide some insight on why this might be failing? I'm trying to use Authentication::Store::Minimal just to test authentication, following along with the examples in the Catalyst book by Jon Rockway. $c-login continues to fail. Instead I get this error from the debug server: [debug] User 'HASH(0x2460d20)' doesn't exist in the default store. My login controller's relevant code is thus: \\\ start code sub index : Private { my ( $self, $c ) = @_; my $username = $c-request-param('username') || ''; my $password = $c-request-param('password') || ''; if ($username $password) { # attempt to log user in if ($c-login({ username = $username, password = $password, })) { $c-response-redirect($c-uri_for('/portal')); return } else { # set an error message $c-stash-{error} = 'Bad username or password'; } } # if either of the above don't work out, send back to login page $c-stash-{message} .= 'Welcome, User. Please Log In.'; $c-stash-{username} = $c-request-param('username'); $c-stash-{template} = 'login.tt'; } /// end code I am expecting that my login would succeed, but this is not the case. Bear in mind that Sessions appear to be working perfectly. Any insights? The relevant parts of my primary application file is as shown below: \\\ start code use Catalyst qw/ -Debug ConfigLoader Static::Simple StackTrace Session Session::State::Cookie Session::Store::DBIC Authentication Authentication::Store::Minimal Authentication::Credential::Password /; our $VERSION = '0.01'; __PACKAGE__-config( name = 'ABCweb' ); __PACKAGE__-config( session = { flash_to_stash= 1, dbic_class= 'DB::Sessions', }, ); __PACKAGE__-config-{authentication}{users} = { 'tommy' = { password = 'password' } }; /// end code signature.asc Description: OpenPGP digital signature ___ 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] Re: error when using Authentication::Store::Minimal
I found my own answer by looking at the source code for the MVC plugin. So much for the book. The login method expects two strings: a username and a password. Kudos to the author who also made the method able to detect a username and password based on best-guess, common sense logic of what they MIGHT be based on the $c-request form parameter input. Sadly, this was still no match for the misinformation I was up against. The login method doesn't want a hashref at all, as we observe here in the source: http://cpansearch.perl.org/src/JROBINSON/Catalyst-Plugin-Authentication-0.10007_01/lib/Catalyst/Authentication/Credential/Password.pm Tommy Butler wrote: Could anyone provide some insight on why this might be failing? I'm trying to use Authentication::Store::Minimal just to test authentication, following along with the examples in the Catalyst book by Jon Rockway. $c-login continues to fail. Instead I get this error from the debug server: [debug] User 'HASH(0x2460d20)' doesn't exist in the default store. My login controller's relevant code is thus: \\\ start code sub index : Private { my ( $self, $c ) = @_; my $username = $c-request-param('username') || ''; my $password = $c-request-param('password') || ''; if ($username $password) { # attempt to log user in if ($c-login({ username = $username, password = $password, })) { $c-response-redirect($c-uri_for('/portal')); return } else { # set an error message $c-stash-{error} = 'Bad username or password'; } } # if either of the above don't work out, send back to login page $c-stash-{message} .= 'Welcome, User. Please Log In.'; $c-stash-{username} = $c-request-param('username'); $c-stash-{template} = 'login.tt'; } /// end code I am expecting that my login would succeed, but this is not the case. Bear in mind that Sessions appear to be working perfectly. Any insights? The relevant parts of my primary application file is as shown below: \\\ start code use Catalyst qw/ -Debug ConfigLoader Static::Simple StackTrace Session Session::State::Cookie Session::Store::DBIC Authentication Authentication::Store::Minimal Authentication::Credential::Password /; our $VERSION = '0.01'; __PACKAGE__-config( name = 'ABCweb' ); __PACKAGE__-config( session = { flash_to_stash= 1, dbic_class= 'DB::Sessions', }, ); __PACKAGE__-config-{authentication}{users} = { 'tommy' = { password = 'password' } }; /// end code ___ 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] Re: error when using Authentication::Store::Minimal
You shouldn't be using the login method to begin with, you want authenticate. Pay less attention to the book (which has very little to do with anything) and more to the docs. Andrew ___ 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] ACL Error: deny_access_unless
On 30 May 2009, at 23:17, Gordon Stewart wrote: Tom I tried to fix this, but something in the dependency stack of DBIx::Class::HTMLWidget fails to install for me. I have removed this Ok, that wasn't much better: , Makefile.PL in your tarball is still fucked (i.e. missing most of your dependencies). . The config you've shipped with the app is pointed at your local mysql, not at sqlite. . Your password credential config is asking for cleartext passwords, but the passwords in the sqlite DB (which is what the app was configured for) was encrypted. . There are failing tests which aren't ever going to pass, like t/ controller_Admin.t which checks for /admin without logging in.. . The tests in t/live_app01.t fail incorrectly, and don't actually test the issue you described. I have fixed all of this and got your app working, but I can't reproduce the bug you originally described. http://omni.state51.co.uk/~t0m/MyApp.tgz - there is your tarball back, with git history of everything I did for your perusal. However, I think I may have guessed what your issue is.. Going back to your original email: The access control section: __PACKAGE__-deny_access_unless( /admin/user, [ 'Admin' ] ); And in your template, you had: User has admin : % $c-check_user_roles('Admin') %br However, your sqlite DB looked like this: sqlite3 myapp.db SQLite version 3.6.11 Enter .help for instructions Enter SQL statements terminated with a ; sqlite select * from roles; 1|user 2|admin sqlite The cases don't match, and I had to correct these before things would work. Do you have a real issue which you can replicate by flicking backwards and forwards between Catalyst 5.80 and 5.70, or did you just break things around the same time as upgrading? I am happy to help out if their is a genuine bug here, but given I'm having to wade in and make loads of changes to any code you give me to make it work at all, I'm not confident you're not just getting yourself confused, or that I haven't stomped on your bug on the way past. If there is still an issue, please try for a *working*, *self contained* app, with *correct dependencies* and tests which *fail on 5.80 and pass on 5.7X*. Cheers t0m ___ 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] Re: error when using Authentication::Store::Minimal
On 2 Jun 2009, at 23:51, Tommy Butler wrote: I found my own answer by looking at the source code for the MVC plugin. The MVC plugin? Huh? You mean the authentication plugin? So much for the book. Yeah, the book hasn't aged well, which is unfortunate. http://dev.catalyst.perl.org/wiki/TheBookErrata http://cpansearch.perl.org/src/JROBINSON/Catalyst-Plugin- Authentication-0.10007_01/lib/Catalyst/Authentication/Credential/ Password.pm Note that you're looking at the docs and source code for a development release which is a year old here.. Cheers t0m ___ 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/