save SELECT result set in the session

0 views
Skip to first unread message

Collin L

unread,
Dec 11, 2006, 12:02:34 AM12/11/06
to TurboGears
>Nope. You can't put an SQLObject in the session because its data is
>considered tied to the transaction it was created in. What you *can*
>do, though, is put the ID in the session and then just do
>ClassName.get(ID) when you need the data back.

How would you save an entire result set in the session? I tried to do
that and a got the same error.

Lee McFadden

unread,
Dec 11, 2006, 7:34:54 AM12/11/06
to turbo...@googlegroups.com

Short answer: don't.

The session is not meant as a caching mechanism for db selects.
You'll fast start running into problems if you do this. The session
is meant for small amounts of *temporary* data that may need to be
stored between requests.

If you need to access the results of the select in a subsequent
request either make the select again or store a list of primary keys
for those select results and retrieve them again.

Hope this helps

Lee

--
Lee McFadden

blog: http://www.splee.co.uk
work: http://fireflisystems.com
skype: fireflisystems

wavydavy

unread,
Dec 11, 2006, 8:53:21 AM12/11/06
to TurboGears
On Dec 11, 12:34 pm, "Lee McFadden" <splee...@gmail.com> wrote:
> On 12/11/06, Collin L <collin.lou...@gmail.com> wrote:
[snip]

> > How would you save an entire result set in the session? I tried to do
> > that and a got the same error.Short answer: don't.
>
> If you need to access the results of the select in a subsequent
> request either make the select again or store a list of primary keys
> for those select results and retrieve them again.

If I've built a query of some sort, I put the SelectResults object
straight
into the session. and just retrieve and call select() on when
subsequently
needed. Works well and is pleasing to the eye, I think.

SelectResults objects are great, the biggest strength of SQLObject IMHO

HTH

wavydavy

Collin L

unread,
Dec 11, 2006, 1:09:34 PM12/11/06
to TurboGears
I will probably store the list of primary keys in the session instead.
The reason I can't just make the query again is because I am sorting by
RAND() and I don't want the results randomized again when the user
pages through the data. Thanks.

Reply all
Reply to author
Forward
0 new messages