Hi, Tobias...

On Dienstag, 29. April 2008, Saibot wrote:
> I am using paginate and have some problems with it.
>
> Thats my controller code:
>
> items = meta.metadata.tables.get(table).select().order_by(column)

I'm no SQLAlchemy guru. But with SQLAlchemy 0.4.* that should just be:

        items = sqlalchemy.select([yourtable])

At least I've tested the module with that syntax.

> c.page = paginate.Page(items, sqlalchemy_session=meta.Session,
> current_page=current_page)
> return render('/databrowse/table.html')
>
> executing this an error occurs:
>
> File 'c:\\TTL\\ttl\\controllers\\databrowse.py', line 22 in table
>   c.page = paginate.Page(items, sqlalchemy_session=meta.Session,
> current_page=current_page)
> File 'C:\\Python25\\lib\\site-packages\\paginate-0.3.2-py2.5.egg\
> \paginate\\__init__.py', line 251 in __init__
>   self.item_count = len(self.collection)
> ValueError: __len__() should return >= 0
>
>
> this happens, when calulating the length of the _SQLAlechemySelect
> Collection:
>
>     def __len__(self):
>         return self.sqlalchemy_session.execute(self.obj).rowcount
> which returns -1. What am I doing wrong?

What do you get if you run

        meta.Session.execute(sqlalchemy.select([yourtable])).rowcount

?

Cheers
 Christoph

P.S.: Help by other SQLAlchemy enthusiasts welcome here.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to