two problems with this:
will not work on GAE (because id is not sequential) and may conflict
with a table called "first" or "last".
I really like the idea though.

perhaps _first and _last and use a auth.signature.created_on instead
of id?

On Aug 11, 5:08 pm, Michael Toomim <[email protected]> wrote:
> Often I'm at the shell and want to quickly pull up the most recent
> entry in a table. I wrote a couple of helpers for this.
>
> For instance, in a blog app:
>
>   db.posts.last()
>
> ...will get the most recent post.
>
> By putting this code at the bottom of db.py, it'll automatically
> create a first() and last() method for each table in your app.
>
> for table in db.tables:
>     def first(self):
>         return db(self.id>0).select(orderby=self.id,
> limitby=(0,1)).first()
>     def last(self):
>         return db(self.id>0).select(orderby=~self.id,
> limitby=(0,1)).first()
>     t = db[table]
>     t.first = types.MethodType(first, t)
>     t.last = types.MethodType(last, t)

Reply via email to