[albatross-users] Having trouble implementing pagination

Sheila King sheila at thinkspot.net
Tue Sep 30 23:53:59 EST 2003


--On Tuesday, September 30, 2003 5:47 PM +1000 Damien Elmes 
<alb-users at repose.cx> wrote:

> Sheila King <sheila at thinkspot.net> writes:
>
>> I tried this:
>>
>> class myclass(list):
>>     def __getitem__(self, x):
>>         return self[x]
>
> If you're inheriting from list, getitem should be defined already. ie:
>
>>>> class mylist(list):
> ...     pass
> ...
>>>> m = mylist([1,2,3])
>>>> m[2]
> 3

Actually, that is what I tried initially. Well, not as you have shown, but 
I created an empty list and then appended items to it. But Albatross later 
complained that my object had no __getitem__ method.

I must've had something else wrong with my code. I will have to go back and 
look at it again tonight.

> If you really wanted to do getitem manually, you'd want to call the
> super function - ie,
>
> list.__getitem__(self, x)
>
> If you were only creating a custom class for the purposes of
> providing those methods, you can probably skip it and just use a
> standard list (but I haven't played with albatross's pagination
> support before).

Yes, I would think so, too. Which is why I tried that first.

Oh well, will try again later tonight...

Thanks for the sanity check.

-- 
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org







More information about the Albatross-users mailing list