[albatross-users] al-for firstpage, nextpage, and gotopage

Michael C. Neel neel at mediapulse.com
Thu Mar 11 05:26:05 EST 2004


Just wanted to say thanks for this, I'm currently working with the code
for ideas on intergrating into albatross.  I don't really consider this
*the* solution; it wouldn't be odd for us to need this type of paging
20+ times on one site and things would be messy.  Also, this currently
needs a session stored on the server to work, trying to make it work
under SimpleApp is proving a catch-22; can't set the page until the
template is run, but setting the page after the template is run won't do
anything (obviously).

Between this and our internal discussions though, I think I've got a
good idea of a solution, though it may be a bit before I can post a
patch.

Mike


> -----Original Message-----
> From: Greg Hamilton [mailto:gregh at object-craft.com.au] 
> Sent: Monday, March 08, 2004 7:45 PM
> To: Michael C. Neel
> Cc: albatross-users at object-craft.com.au
> Subject: Re: [albatross-users] al-for firstpage, nextpage, 
> and gotopage
> 
> 
> I revisited the code this morning and, after a little 
> head-scratching,  
> I pulled out the relevant bits and created a little example 
> app which  
> you can see in action here:
> 
> http://www.object-craft.com.au/cgi-bin/paged-example/app.cgi
> 
> or download the source tarball here:
> 
> http://www.object-craft.com.au/paged-example.tar.gz
> 
> The example app navigates a table off 500 rows of 20 elements 
> of random  
> numbers. I limit the number of rows per page to 15 which 
> gives you 34  
> pages to peruse.
> 
> The Albatross <al-for> tag uses the Albatross ListIterator class and  
> already supports pagination. I've written a subclass of 
> ListIterator,  
> called PagedListIterator, which adds methods for getting and setting  
> the current page or range of pages.
> 
> Note, normally Albatross will automagically create a ListIterator  
> instance when it encounters an <al-for> loop in a template. To force  
> Albatross to use a PagedListIterator instead you need to add the  
> iterator instance to ctx.locals before the template is processed.
> 
> In the 'page_enter' method of 'page.py' I create the iterator 
> and add  
> it to the session vars, something like this:
> 
> 	def page_enter(ctx):
>      		ctx.locals.rows_iter = PagedListIterator()
>     		ctx.add_session_vars('rows_iter', )
> 
> In the template 'page.html' the <al-for> loop which uses  
> 'iter="rows_iter"' will use this PagedListIterator instance.
> 
> Greg
> 
> 
> On 06/03/2004, at 6:16 AM, Michael C. Neel wrote:
> 
> > Dave said a while back that Greg(?) had implemented these without
> > extending/altering Albatross, and that he could post some 
> code showing
> > how it was done.  Can we get that code? =p
> >
> > Mike
> > _______________________________________________
> > Albatross-users mailing list
> > Albatross-users at object-craft.com.au
> > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross- 
> > users
> >
> 
> 



More information about the Albatross-users mailing list