/[A3C]/lib/A3C/LDAP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/LDAP.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 46 by dpavlin, Sun Mar 30 22:29:42 2008 UTC revision 47 by dpavlin, Mon Mar 31 21:11:45 2008 UTC
# Line 104  sub count { Line 104  sub count {
104    
105  =head2 as_collection_of  =head2 as_collection_of
106    
107    my $connection = $ldap->collection('Organization', $limit);    my $connection = $ldap->collection(
108            # name of model to use
109            'Organization',
110            # optional params
111            limit => $limit,
112      );
113    
114  =cut  =cut
115    
# Line 114  my $collection2filter = { Line 119  my $collection2filter = {
119  };  };
120    
121  sub collection {  sub collection {
122          my ( $self, $model, $limit ) = @_;          my $self = shift;
123            my $model = shift or die "no model?";
124            my $args = {@_};
125    
126          $limit ||= 0;   # unlimited by default          $args->{limit} ||= 0;   # unlimited by default
127    
128          my $filter = $collection2filter->{$model};          my $filter = $collection2filter->{$model};
129          die "unknown model $model" unless $filter;          die "unknown model $model" unless $filter;
# Line 124  sub collection { Line 131  sub collection {
131          $self->search(          $self->search(
132                  base => $self->base,                  base => $self->base,
133                  filter => $filter,                  filter => $filter,
134                  sizelimit => $limit,                  sizelimit => $args->{limit},
135          );          );
136    
137          Jifty->log->info("searching LDAP for $model with $filter limit $limit returned ", $self->count, " results");          Jifty->log->info(
138                    "searching LDAP for $model with $filter ",
139                    $args->{limit} ? 'limit ' . $args->{limit} : '',
140                    'returned ', $self->count, ' results'
141            );
142    
143          my $class = Jifty->app_class('Model', $model . 'Collection' ) or die "can't create ${model}Collection";          my $class = Jifty->app_class('Model', $model . 'Collection' ) or die "can't create ${model}Collection";
144          my $collection = $class->new() or die "can't $class->new";          my $collection = $class->new() or die "can't $class->new";

Legend:
Removed from v.46  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26