Re: [Catalyst] source out accessors to LDAP-Model

2010-12-13 Thread kevin montuori
On Mon, Dec 13, 2010 at 9:24 AM, piccard  wrote:

> I'm very new to Catalyst, so at the moment I am playing around with some
> things. I think I've got a very basic question:
> I'm not sure how to pull out more complicated queries from the controller by
> providing subroutines/accessors.

See the documentation related to the "connection_class" and
"entry_class" configuration items.  You can specify subclasses of
Catalyst::Model::LDAP::Connection and Catalyst::Model::LDAP::Entry and
use them exactly as you'd expect.


k.


-- 
kevin montuori

___
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] source out accessors to LDAP-Model

2010-12-13 Thread piccard

Hello,

I'm very new to Catalyst, so at the moment I am playing around with some 
things. I think I've got a very basic question:
I'm not sure how to pull out more complicated queries from the 
controller by providing subroutines/accessors.




I created a LDAP-Model and sourced out the connection-parameters to 
myapp.config



base   ou=TSM,ou=ABC,o=f,c=de
password   extremlysecret

verify   none

port   
start_tls   0
dn   cn=readproxytsm,ou=services,o=,c=de
host   ldaps://ldapauth..de



Then I tested it by a controller query, which works very well:

# Then, in your controller
my $mesg = $c->model('Person')->search('(uid=lu21rue)');
my @entries = $mesg->entries;
$c->stash({
   template => 'books/person.tt',
   person_uri => $entries[0]->uid,
   person => $entries[0],
});





But I don't wanna pollute my controllers, so I wanted to source out 
complicated queries in special classes which should provide accessors. 
So I extended the Model-class to use an adaptor:




package ldap::Model::Person;

use strict;
use warnings;
use base qw/Catalyst::Model::LDAP/;
use parent 'Catalyst::Model::Adaptor';


__PACKAGE__->config(
class => 'ldap::Model::Person::Utils',
args => {}
);


package ldap::Model::Person::Utils;

use Moose;
use namespace::clean -except => 'meta';
extends 'Catalyst::Model::LDAP';


sub getPerson {
my ($self, $person) = @_;

my $mesg = $self->search('(uid='.$person.')');
my @entries = $mesg->entries;

return @entries;
}


__PACKAGE__->meta->make_immutable;



But that's defnitly the wrong way, 'cause $c->model('Person') from the 
controller returns a Catalyst::Model::LDAP::Connection reference.
What's the right way to pull out these queries from the controller and 
store them in their own classes?


Thank u in advnace :-D



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