Re: Pagers and Iterators

[prev] [thread] [next] [Date index for 2005/02/25]

From: Simon Wistow
Subject: Re: Pagers and Iterators
Date: 16:34 on 25 Feb 2005
On Fri, Feb 25, 2005 at 03:37:56PM +0000, Simon Wistow said:
> Instantiating my own Iterator looks like the righthing to do.

and lo! it was - much easier than I thought as well :/

Formatted for 72 cols - here it is for posterity.

	
my $pager = __PACKAGE__->do_pager($r);
$r->{template_args}{items} = [ $pager->get_sorted_items ];

#
# ... call template here
#


sub do_pager {
    my ($self, $r) = @_;
    if ( my $rows = $r->config->{rows_per_page}) {
        return $r->{template_args}{pager} = 
          $self->pager($rows, $r->query->{page});
    } else { 
		return $self 
	}
}

sub get_sorted_items {
    my $self = shift;
    my @stuff = sort { 
                       lc($a->get_price) 
                       cmp 
					   lc($b->get_price 
                     }  $self->retrieve_all;

    return Class::DBI::Iterator->new('Email::Store::Entity', 
                                      \@stuff );
}

(message missing)

Pagers and Iterators
Simon Wistow 11:30 on 25 Feb 2005

Re: Pagers and Iterators
Daniel Wijnands 11:34 on 25 Feb 2005

Re: Pagers and Iterators
Simon Wistow 11:47 on 25 Feb 2005

Re: Pagers and Iterators
Sean Davis 11:55 on 25 Feb 2005

Re: Pagers and Iterators
Simon Wistow 12:14 on 25 Feb 2005

Re: Pagers and Iterators
Carl Johnstone 13:23 on 25 Feb 2005

Re: Pagers and Iterators
Cees Hek 14:18 on 25 Feb 2005

Re: Pagers and Iterators
Matt S Trout 14:35 on 25 Feb 2005

Re: Pagers and Iterators
William Ross 12:15 on 25 Feb 2005

Re: Pagers and Iterators
William Ross 14:04 on 25 Feb 2005

Re: Pagers and Iterators
Simon Wistow 15:37 on 25 Feb 2005

Re: Pagers and Iterators
Simon Wistow 16:34 on 25 Feb 2005

Re: Pagers and Iterators
Ofer Nave 20:52 on 25 Feb 2005

Re: Pagers and Iterators
Cees Hek 16:41 on 25 Feb 2005

Re: Pagers and Iterators
Carl Johnstone 17:09 on 25 Feb 2005

Generated at 17:56 on 01 Mar 2005 by mariachi v0.52