Subject: | More documentation bugs |
More documentation bugs in the module. Now you'll understand why I wanted to be able to grep the mailing list properly.
The pod says: "Most administration is performed using normal Maypole actions and templates such as list, search, addnew, view, edit and delete." but the relationships needed to be able to do this are not described in the docs or the source code.
While trying to get my head around the way that these relationships should be described I came across a post to the mailing list :
From: dhoworth@mrc-lmb.cam.ac.uk (Dave Howorth)
Date: Wed, 12 Jan 2005 15:46:50 +0000
Subject: [Maypole] Maypole::Plugin::Authorization
The relationships and untaint rules for the BeerDB are described as a part of a code sample in the post. I've separated the relationships and the untaint rules out for clarity. It makes logical sense for the relationships to appear first then the other rules. I have not tested these to see if they work properly I am afraid.
Final thing. As it's promoted in the docs, it might be a good idea to present how to create these relationships using Class::DBI::Loader::Relationship as that's a method that's promoted in Maypole::Manual::* . I had a quick stab at it, but got rather confused.
# --- Documentation patch. Please test first [! - sorry.]
# relationships
BeerDB::Permissions->has_a(auth_role_id => 'BeerDB::AuthRoles');
BeerDB::RoleAssignments->has_a(user_id => 'BeerDB::Users');
BeerDB::RoleAssignments->has_a(auth_role_id => 'BeerDB::AuthRoles');
BeerDB::AuthRoles->has_many(users => [ 'BeerDB::RoleAssignments' => 'user_id' ]);
BeerDB::Users->has_many(auth_roles =>
[ 'BeerDB::RoleAssignments' => 'auth_role_id' ]);
# display rules
BeerDB::Users->untaint_columns( printable => [qw/name password/]);
BeerDB::AuthRoles->untaint_columns( printable => [qw/name/]);
BeerDB::Permissions->untaint_columns(
printable => [qw/auth_role_id model_class method/]);
BeerDB::RoleAssignments->untaint_columns(
printable => [qw/user_id auth_role_id/]);
##-- end docs
Sorry all this is untested - fixing this should improve things twofold. Firstly it clarifies the way Authorization is implemented in an application and secondly it improves the documentation on implementing relationships in Maypole.
Cheers
Kieren