Re: [Catalyst] Jason Kohles' tutorial on ExtJs editable data gridsandCatalyst

2009-05-11 Thread jagdish eashwar
Hi,

I think I need help again.

Some days ago, i had worked through Jason Kohles' tutorial on the ExtJS Grid
with help from several people on the mailing list. I was then on Ubuntu
8.04. I have now upgraded to Ubuntu 9.04 and along with it Catalyst also got
upgraded to 5.0715. I don't remember the version number of the previous
Catalyst, but it used yaml instead of Config::General for the config file.

Now when I am trying to work through the tutorial again after a short break,
I am unable to get things working fully. In the new MyExtGrid app, the grid
is displayed in the browser, but it is not populated with data. My old
AdventAjaxGrid app, however, still works fine with Ubuntu 9.04 and Catalyst
5.0715. I have compared the code in the two Apps several times, but I don't
seem to be able to find anything wrong or different there. I think, in
MyExtGrid app, the people_data sub in Root.pm is just not picking up data
from the database. So I am pasting relevant snippets of code.

Controller Code in Old App:
---
sub people_data : Local {
my ($self,$c) = @_;

my $rs = $c-model ('AdventAjaxGridDB::People');
my @people = ();
while (my $people = $rs-next) {
push (@people, {
id = $people-id,
name = $people-name,
occupation = $people-occupation,
});
$c-log-debug(what's this - .$people-name.\n);
}
$c-stash-{'people'} = \...@people;
$c-detach ($c-view('JSON'));
}


Messages that I get from Catalyst
-
[info] AdventAjaxGrid powered by Catalyst 5.7015
You can connect to your server at http://ubuntu-office:3000
[info] *** Request 1 (0.100/s) [11666] [Mon May 11 14:47:20 2009] ***
[debug] GET request for / from 127.0.0.1
[debug] Rendering template index.tt2
[debug] Applying HTML page layout wrappers to index.tt2
[info] Request took 0.206001s (4.854/s)
.+---.
| Action | Time
|
++---+
| /index | 0.000655s
|
| /end   | 0.155815s
|
|  - AdventAjaxGrid::View::TT-process  | 0.151578s
|
'+---'

[info] *** Request 2 (0.154/s) [11666] [Mon May 11 14:47:23 2009] ***
[debug] Query Parameters are:
.-+--.
| Parameter   | Value
|
+-+--+
| _dc | 1242033443165
|
'-+--'
[debug] GET request for people_data from 127.0.0.1
[debug] Path is people_data
[debug] what's this - jagdish eashwar
[debug] what's this - sushama marathe
[debug] what's this - manasi
[debug] what's this - ninad
[info] Request took 0.058423s (17.117/s)
.+---.
| Action | Time
|
++---+
| /people_data   | 0.046012s
|
|  - AdventAjaxGrid::View::JSON-process| 0.001213s
|
| /end   | 0.001242s
|
'+---'


Controller Code in New App:
---
sub people_data : Local {
my ($self,$c) = @_;

my $rs = $c-model ('MyExtGridDB::People');
my @people = ();
while (my $people = $rs-next) {
push (@people, {
id = $people-id,
name = $people-name,
occupation = $people-occupation,
});
$c-log-debug(What's this - .$people-name.\n);
}
$c-stash-{'people'} = \...@people;
$c-detach ($c-view('JSON'));
}


Messages that I get from Catalyst
-

[info] MyExtGrid powered by Catalyst 5.7015
You can connect to your server at http://ubuntu-office:3000
[info] *** Request 1 (0.143/s) [11987] [Mon May 11 15:08:51 2009] ***
[debug] GET request for / from 127.0.0.1
[debug] Rendering template index.tt2
[info] Request took 0.169082s (5.914/s)
.+---.
| Action | Time
|
++---+
| /index | 0.000573s
|
| /end   | 0.151973s
|
|  - 

Re: [Catalyst] Howto Catalyst::Plugin::Captcha ?

2009-05-11 Thread Matt S Trout
On Fri, May 08, 2009 at 03:33:52PM +0200, t...@dix.cz wrote:
 
 Hello catalysters,
 
 I'm trying to use  Catalyst::Plugin::Captcha

Don't. Controller::reCAPTCHA is far saner.

This, as with many things, should never have been a plugin, and as such it's
kinda fragile, sorry.

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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] Forward to view question

2009-05-11 Thread Matt S Trout
On Tue, May 05, 2009 at 10:54:17AM -0400, Dennis Daupert wrote:
 I've created a view that's intended to write a couple of files to the file
 system.
 
 The output filename needs to be dynamically set. I'm having a bit of a go
 figuring out how to do that.
 
 The TT configuration documentation speaks of an output subroutine:
 
 OUTPUT = \output,
 
 Later on in the view base class...
 
 sub output {
   my $filename = shift;
   # do stuff
 }
 
 Here's my question:
 How do I get the $filename into sub output when I forward to the view?

Screw that.

sub write_file {
  my ($self, $c, $filename) = @_;
  my $data = $self-render($c, ...); # look at how process calls render
  write data
}

then do:

$c-view('Foo')-write_file($c, $filename);

Having to pass $c along like that is a little bit annoying, but this approach
is -way- simpler.

Of course if you were feeling truly insane you could do

  $self-template-{OUTPUT} = sub { capture $filename here };
  $self-render(...);

but I don't really see that it would gain you anything.

*wonders if write_file should be a role that applies to any view that supplies
render* ...

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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] Authorization Failure

2009-05-11 Thread Matt S Trout
On Fri, May 08, 2009 at 04:08:29PM +0400, Oleg Pronin wrote:
 Catalyst and controllers are the same. Catalyst imho is _not only web_
 framework.

You can beat a nail in with a screwdriver too.

More seriously, I'd really like to split out the bits of Catalyst that are
application framework rather than web so that those parts can be shared
and you basically subclass it.

But that's a fucktonne of code I don't have time to write just yet. If anybody
wants to experiment with this idea, I'd be more than happy to help bikeshed
out the design.

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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] Handling of keywords for controller methods

2009-05-11 Thread Matt S Trout
On Mon, May 11, 2009 at 02:08:40AM +0200, Roland Lammel wrote:
 Hi all,
 
 I was bitten by the naming of one of my controller methods. After digging a
 little into that I found that the method name actions was not the best
 idea to use. It is in catalyst terms a keyword (actually an attribute) of
 Catalyst::Controller where also my controller inherits from.

That's a bug, the attribute should -not- be called 'actions'.

Can somebody do up a patch that renames it to something sensible? (_actions
seems reasonably safe to me ...)

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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] Handling of keywords for controller methods

2009-05-11 Thread Hans Dieter Pearcey
On Mon, May 11, 2009 at 06:13:19PM +0100, Matt S Trout wrote:
 That's a bug, the attribute should -not- be called 'actions'.

Or, at least, its accessor shouldn't.  (Naming the attribute itself 'actions'
vs. '_actions' is a matter of taste.)

hdp.

___
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] Who wants to be rid of the Unknown Error w/attributes bug on 5.10?

2009-05-11 Thread Matt S Trout
Because I know you guys all hate it. Certainly the ones using Catalyst heavily.

Well, it's been fixed in bleadperl for a while, but in order to get that out
we require a 5.10.1 - and to get a 5.10.1 we needed to fix all the bugs that
were in smartmatch in 5.10.0 because not enough of us tested the dev releases.

So, rgs has updated the smartmatch POD, and the code, and the tests.

Because rgs is wonderful.

But given how much trouble we had with the 5.10.0 version it almost certainly
wants more tests and the time for being sure of 5.10.1 features draw nigh. So.

http://github.com/rjbs/perl-smartmatch-tests/tree/master

Here is a repo. Fork it. Try and break it. If you succeed, note how that break
departs from the spec. Send pull requests to rjbs as often as you're sure is
a good idea so he can keep everybody in sync.

Go on. Go! GO GO GO GO GO!

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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] FormFu edit form problem

2009-05-11 Thread Steve Rippl

Hi,

Very new to Catalyst, I think it's great but I'm groping about a bit 
here!  I started using FromBuilder as per the book, but as everyone 
points out the book is dated and FormBuilder doesn't seem to be used 
much now, so I'm having a go with FormFu.  Following along with the 
AdvancedCrud tutorial I have a simple edit action in Staff.pm and 
everything works fine.  Now, my staff table has a foreign key 
relationship to locationid in the Location table (I'll put both models 
at the bottom of this), I build a drop box with ids and locations but 
when I call $form-model-update($person); (where $person = 
$c-model('DB::Staff')-find($id);) I get


|Caught exception in WsdSis::Controller::Staff-edit The primary key and the 
foreign key may not be the same column in class WsdSis::Schema::Result::Location at 
/srv/WsdSis/script/../lib/WsdSis/Controller/Staff.pm line 80
|

Where line 80 is the call to update.  It actually updates the Staff 
table correctly, but then throws this before continuing.  I'm confused 
why it's telling me that the primary and foreign keys are on the same 
column when it's primary in one table and foreign in the other.  I got 
this working with FormBuilder so I'm thinking I can't be too far off base?!!


Many thanks in advanced!

Steve


package WsdSis::Schema::Result::Location;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__-load_components(InflateColumn::DateTime, Core);
__PACKAGE__-table(location);
__PACKAGE__-add_columns(
 locationid,
 { data_type = INT, default_value = undef, is_nullable = 0, size 
= 4 },

 name,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 128,
 },
 code,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 1,
   size = 32,
 },
);
__PACKAGE__-set_primary_key(locationid);
__PACKAGE__-has_many(
 courses,
 WsdSis::Schema::Result::Course,
 { foreign.locationid = self.locationid },
);
__PACKAGE__-has_many(
 staffs,
 WsdSis::Schema::Result::Staff,
 { foreign.locationid = self.locationid },
);
__PACKAGE__-has_many(
 students,
 WsdSis::Schema::Result::Student,
 { foreign.locationid = self.locationid },
);

# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-05-08 08:53:55
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IaDVNVK3kG3NwXKnqV3baA

# You can replace this text with custom content, and it will be 
preserved on regeneration

1;

package WsdSis::Schema::Result::Staff;

use strict;
use warnings;

use base 'DBIx::Class';

__PACKAGE__-load_components(InflateColumn::DateTime, Core);
__PACKAGE__-table(staff);
__PACKAGE__-add_columns(
 staffid,
 { data_type = INT, default_value = undef, is_nullable = 0, size 
= 11 },

 name_first,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 64,
 },
 name_last,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 64,
 },
 name_middle,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 1,
   size = 64,
 },
 username,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 32,
 },
 password,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 32,
 },
locationid,
 { data_type = INT, default_value = undef, is_nullable = 1, size 
= 4 },

 room,
 {
   data_type = VARCHAR,
   default_value = undef,
   is_nullable = 0,
   size = 32,
 },
 grade,
 { data_type = VARCHAR, default_value = undef, is_nullable = 1, 
size = 2 },

);
__PACKAGE__-set_primary_key(staffid);
__PACKAGE__-add_unique_constraint(username, [username]);
__PACKAGE__-has_many(
 sections,
 WsdSis::Schema::Result::Section,
 { foreign.staffid = self.staffid },
);
__PACKAGE__-belongs_to(
 locationid,
 WsdSis::Schema::Result::Location,
 { locationid = locationid },
);
__PACKAGE__-has_many(
 staff_role_staffids,
 WsdSis::Schema::Result::StaffRole,
 { foreign.staffid = self.staffid },
);
__PACKAGE__-has_many(
 staff_role_staffids,
 WsdSis::Schema::Result::StaffRole,
 { foreign.staffid = self.staffid },
);

# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-05-08 08:53:55
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nHqMzIfDb+60wdQoinx79Q

# many_to_many():
#   args:
# 1) Name of relationship, DBIC will create accessor with this name
# 2) Name of has_many() relationship this many_to_many() is shortcut for
# 3) Name of belongs_to() relationship in model class of has_many() 
above

#   You must already have the has_many() defined to use a many_to_many().
__PACKAGE__-many_to_many(roles = 'staff_role_staffids', 'roleid');



#
# Helper methods
#
sub name_full {
   my ($self) = @_;

   return $self-name_last . ', ' . $self-name_first;
}

1;

--
Steve Rippl
Technology Director
Woodland School District
360 225 9451 x326


___
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: 

Re: [Catalyst] Handling of keywords for controller methods

2009-05-11 Thread Roland Lammel
Ok, I'll do a patch renaming it to _controller_actions that *should* be
sensible enough to not clash in the future.

+rl

On Mon, May 11, 2009 at 19:22, Hans Dieter Pearcey 
hdp.perl.catalyst.us...@weftsoar.net wrote:

 On Mon, May 11, 2009 at 06:13:19PM +0100, Matt S Trout wrote:
  That's a bug, the attribute should -not- be called 'actions'.

 Or, at least, its accessor shouldn't.  (Naming the attribute itself
 'actions'
 vs. '_actions' is a matter of taste.)

 hdp.

 ___
 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/




-- 
Roland Lammel
QuikIT - IT Lösungen - flexibel und schnell
Web: http://www.quikit.at
Email: i...@quikit.at

Enjoy your job, make lots of money, work within the law. Choose any two.
___
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] Handling of keywords for controller methods

2009-05-11 Thread Roland Lammel
Here is the very simplistic patch, which only renames the actions
attribute to _controller_actions in Catalyst::Controller. Test suite still
passes with the patch and my app that originally showed that error, is now
also working like a charm.

Cheers

+rl

On Tue, May 12, 2009 at 00:07, Roland Lammel roland.lam...@gmail.comwrote:

 Ok, I'll do a patch renaming it to _controller_actions that *should* be
 sensible enough to not clash in the future.

 +rl


 On Mon, May 11, 2009 at 19:22, Hans Dieter Pearcey 
 hdp.perl.catalyst.us...@weftsoar.net wrote:

 On Mon, May 11, 2009 at 06:13:19PM +0100, Matt S Trout wrote:
  That's a bug, the attribute should -not- be called 'actions'.

 Or, at least, its accessor shouldn't.  (Naming the attribute itself
 'actions'
 vs. '_actions' is a matter of taste.)

 hdp.

 ___
 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/




 --
 Roland Lammel
 QuikIT - IT Lösungen - flexibel und schnell
 Web: http://www.quikit.at
 Email: i...@quikit.at

 Enjoy your job, make lots of money, work within the law. Choose any two.




-- 
Roland Lammel
QuikIT - IT Lösungen - flexibel und schnell
Web: http://www.quikit.at
Email: i...@quikit.at

Enjoy your job, make lots of money, work within the law. Choose any two.
diff -u -r Catalyst-Runtime-5.80003/lib/Catalyst/Controller.pm Catalyst-Runtime-5.80003-fix-actions-keyword/lib/Catalyst/Controller.pm
--- Catalyst-Runtime-5.80003/lib/Catalyst/Controller.pm	2009-04-27 14:22:54.0 +0200
+++ Catalyst-Runtime-5.80003-fix-actions-keyword/lib/Catalyst/Controller.pm	2009-05-12 00:18:37.0 +0200
@@ -29,7 +29,7 @@
  predicate = 'has_action_namespace',
 );
 
-has actions =
+has _controller_actions =
 (
  is = 'rw',
  isa = 'HashRef',
@@ -41,7 +41,7 @@
 my $action  = delete $args-{action}  || {};
 my $actions = delete $args-{actions} || {};
 my $attr_value = $self-merge_config_hashes($actions, $action);
-$self-actions($attr_value);
+$self-_controller_actions($attr_value);
 }
 
 =head1 NAME
@@ -260,7 +260,7 @@
 # superior while mantaining really high degree of compat
 my $actions;
 if( ref($self) ) {
-$actions = $self-actions;
+$actions = $self-_controller_actions;
 } else {
 my $cfg = $self-config;
 $actions = $self-merge_config_hashes($cfg-{actions}, $cfg-{action});
___
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] Who wants to be rid of the Unknown Error w/attributes bug on 5.10?

2009-05-11 Thread Jonathan Rockway
* On Mon, May 11 2009, Matt S Trout wrote:
 Because I know you guys all hate it. Certainly the ones using Catalyst 
 heavily.

 Well, it's been fixed in bleadperl for a while, but in order to get that out
 we require a 5.10.1 - and to get a 5.10.1 we needed to fix all the bugs that
 were in smartmatch in 5.10.0 because not enough of us tested the dev
 releases.

Or, you can use Debian, which fixed this bug in its Perl a while ago:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488088

Regards,
Jonathan Rockway

--
print just = another = perl = hacker = if $,=$

___
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] New restarter code in Catalyst::Devel 1.14_01

2009-05-11 Thread Jonathan Rockway
* On Sun, May 10 2009, Dave Rolsky wrote:
 I recently did some work to rewrite the Catalyst restarter code and
 make it both simpler and less fragile.

 [snip]

Hi Dave,

This is really wonderful.  Thanks!

I have begun porting this concept to MooseX::Runnable, so hopefully all
Perl applications will have access to this functionality soon.

(As an aside, someone mentioned factoring out Catalyst stuff into
separate components in another mail earlier today.  MooseX::Runnable is
the 0th step in this process.  It's actually being used by a few people
in production now, so it's almost time for step 1 -- building a
reusable, componentized (not-necessarily-web) application framework.  I
have started this in a project called Eventful, although most of the
Real Work has happened in my current $work_app.  The step after that is
to make Eventful speak HTTP (which it does already, via HTTP::Engine).
Finally, on top of those components, we can add the Catalyst stuff as
Yet Another Component.  I talked about this on my blog a few weeks ago,
so if you want more details, read that, and bug me on IRC.

The code in the Eventful repo does work, but it doesn't have the
component loading stuff, arguably the most critical part, working
correctly yet... but it will soon, as I finally figured it out this
morning. :)

Regards,
Jonathan Rockway

--
print just = another = perl = hacker = if $,=$

___
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] Who wants to be rid of the Unknown Error w/attributes bug on 5.10?

2009-05-11 Thread Andrew Rodland
On Monday 11 May 2009 05:45:01 pm Jonathan Rockway wrote:
 Or, you can use Debian, which fixed this bug in its Perl a while ago:

 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488088

Not everyone uses Debian, and I, for one, would much rather be able to tell 
people get 5.10.1 than to have to explain what patch is or try to convince 
them to switch their operating system. A fix from upstream is long overdue. :)

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/


[Catalyst] Need some help with Authorization setup

2009-05-11 Thread kakimoto

hi, guys,


 I got some concerns about the Autorization modules for Catalyst.


What I have checked:


1) Looked at the tutes for Authentication and  Authorization:

   
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Tutorial/Authentication.pod
   
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Tutorial/Authorization.pod

2) looked at the cookbook:
   
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Cookbook.pod#___top

3) Looked at the perldoc for
Catalyst::Authentication::Store::DBIx::Class

   
http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class-0.1082/lib/Catalyst/Authentication/Store/DBIx/Class.pm


Any calls made to 'check_user_roles' doesn't work in my application. I
followed the tute with some minor changes




Questions:
==

Referring to the perldoc for
Catalyst::Authentication::Store::DBIx::Class


*)   'user_role_user_field' = 'user'

 That doesn't come with any description. Is that meant for a
authentication 
 authorisation similar to the tute (as in there are 3 database
tables: User,
 Role and UserRole ) ?


Referring to the cookbook on 'Role-based Authorization
(configuration section)


-Extract from configuration section - START
--
__PACKAGE__-config-{authentication} =
{
default_realm = 'members',
realms = {
members = {
credential = {
# ...
},
store = {
class = 'DBIx::Class',
user_model = 'MyApp::User',
role_relation = 'roles',
role_field = 'rolename',
ignore_fields_in_find = [
'remote_name' ],
use_userdata_from_session = 1,
}
}
}
};
-Extract from configuration section - END
--
Assuming the following databases, I find myself lost.

Database table: Users
=
 Table public.users
   Column   |Type |
Modifiers
   
+-+
 id | integer | not null
default nextval('users_id_seq'::regclass)
 password   | text| not null
 first_name | text|
 last_name  | text|
 active | integer |
 main_contact_id| integer |
 company_name   | text|
 billing_details_id | integer |
 billing_address_id | integer |
 created_by | character varying(12)   |
 updated_by | character varying(12)   |
 created_on | timestamp without time zone |
 updated_on | timestamp without time zone |
 login_id   | character varying(20)   | not null
 abn| text|
Indexes:
users_pkey PRIMARY KEY, btree (id)
unique_login_id UNIQUE, btree (login_id)


Relationships:
==

__PACKAGE__-has_many( 'map_user_role' =
'myApp::Schema::UserRoles', 'user_id');

Database table: user_roles
==

   Table public.user_roles
 Column  |  Type   | Modifiers
-+-+---
 user_id | integer | not null
 role_id | integer | not null
Indexes:
user_roles_pkey PRIMARY KEY, btree (user_id, role_id)

Relationships:
==

__PACKAGE__-belongs_to( 'user' = 'myApp::Schema::Users',
'user_id');
__PACKAGE__-belongs_to( 'role' = 'myApp::Schema::Roles',
'role_id');


Database table: roles
===
 Table public.roles
 Column |  Type   | Modifiers
   
+-+
 id | integer | not null default
nextval('roles_id_seq'::regclass)
 role   | text|
Indexes:
roles_pkey PRIMARY KEY, btree (id)


[Catalyst] My experience porting to CataMoose

2009-05-11 Thread Daisuke Maki
Hi,

I've switched an application of mine to CataMoose. Thanks for the hard
work, it's seems surprisingly stable for such a massive overhaul.

I've observed a few glitches / gotchas, they seem like things that
probably should be documented, but I'd like to share with the list
before writing them up:

1. MyApp-config-{home} and Catalyst::Upgrading

Catalyst::Upgrading suggests that the following is possible:

  package MyApp;
  use Moose;

  extends 'Catalyst';

  __PACKAGE__-setup( ... );

This is fine, but things gets a bit hairy when you mix this with calls
MyApp-config-{home} BEFORE setup(), for example:

  package MyApp;
  use Moose;

  extends 'Catalyst';

  __PACKAGE__-config(
 'View::TT' = {
 INCLUDE_PATH = __PACKAGE__-path_to('whatever')
 }
  );

  __PACKAGE__-setup(  );

path_to will return something like /whatever instead of
/path/to/MyApp/whatever, because home isn't set. to get around it, you
 would need to force setup_home() to be called, or say

  package MyApp;
  use Moose;
  use Catalyst; # so import() gets called

  extends 'Catalyst';

  __PACKAGE__-config(...);
  __PACKAGE__-setup(...);

2. Hooking to methods that Plugins use via method modifiers breaks
method dispatch

I got bit by this while depending on Catalyst::Plugin::Unicode, and
trying to hook a custom error handling mechanism at finalize().

I was doing this in MyApp.pm:

  before finalize = sub {
  my $c = shift;
  $c-handle_exception if @{ $c-error };
  };

At that moment, Catalyst::Plugin::Unicode's finalize() stopped from
being called. I fully expected MyApp-finalize() to trigger all the
plugins' finalize(), then Catalyst::finalize(), but it only called
MyApp::finalize() and Catalyst::finalize().

I never got exactly why this happens, but it seems to me like Moose's
Method object interacts oddly with the method dispatch. My fix was to do

  override finalize = sub {
 my $c = shift;
 $c-handle_exception if @{ $c-error };
 $c-next::method(@_); # doing super() didn't work here.
  };



regards,
--d

P.S. MST: yes, this has been blogged:
http://mt.endeworks.jp/d-6/2009/05/moosification-catalyst-58.html


___
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/