Massimo is correct,
I just wanted to know the more efficient way to randomize a Rows dictionary,
instead of using orderby=<random>.
Because as said on the book, orderby=<random> is not supported on GAE.

Just easy as using python random library :)

Thanks again.


On Wed, Dec 8, 2010 at 1:04 AM, mdipierro <mdipie...@cs.depaul.edu> wrote:

> He asked: "Someone knows the best way to randomize a Rows dictionary?"
>
> The proposed solution randomized the Rows object that you already
> fethed form the db. You are correct that it does not fetch random
> rows.
>
> On Dec 7, 4:41 pm, Richard <richar...@gmail.com> wrote:
> > I think he's after an database-side implementation. If you used limit
> > and random together then wouldn't you always get the same set of data,
> > rather than random?
> >
> > On Dec 8, 4:13 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >
> > > Not sure I understand our comment:
> >
> > > rows=db(...).select().sort(lambda row: random.random())
> >
> > > sorts the rows that have been already fetched at the web2py/python
> > > level. That is all. What is wrong with it?
> >
> > > On Dec 7, 9:28 am, blackthorne <francisco....@gmail.com> wrote:
> >
> > > > Seems to be 1.89.5 (2010-11-21 16:03:13)..
> >
> > > > but what about my comment of the random sorting?
> >
> > > > On Dec 7, 3:09 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >
> > > > > You have an old version. aidr is a type fixed some time ago.
> >
> > > > > On Dec 7, 7:13 am, blackthorne <francisco....@gmail.com> wrote:
> >
> > > > > > I don't see howcome this works as random sorting.
> > > > > > The only random thing I see it's the row chosen for sorting which
> will
> > > > > > only change the sorting criteria for the number of rows in the
> table.
> >
> > > > > > Am I wrong?
> >
> > > > > > P.S.:
> > > > > > I couldn't make a quick test because:
> > > > > > isco-Ribeiros-MacBook-Pro-2:web2py blackthorne$ python web2py.py
> -S
> > > > > > "test"
> > > > > > web2py Enterprise Web Framework
> > > > > > Created by Massimo Di Pierro, Copyright 2007-2010
> > > > > > Version 1.89.5 (2010-11-21 16:03:13)
> > > > > > Database drivers available: SQLite3
> > > > > > application test does not exist, create (y/n)?yes
> > > > > > Traceback (most recent call last):
> > > > > >   File "web2py.py", line 23, in <module>
> > > > > >     gluon.widget.start(cron=True)
> > > > > >   File "/Users/blackthorne/Code/web2py/gluon/widget.py", line
> 766, in
> > > > > > start
> > > > > >   File "/Users/blackthorne/Code/web2py/gluon/shell.py", line 166,
> in
> > > > > > run
> > > > > > NameError: name 'aidr' is not defined
> >
> > > > > > ?
> >
> > > > > > On Dec 6, 10:53 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >
> > > > > > > import random
> > > > > > > ...
> > > > > > > rows=db(...).select().sort(lambda row: random.random())
> >
> > > > > > > On Dec 6, 4:09 pm, Albert Abril <albert.ab...@gmail.com>
> wrote:
> >
> > > > > > > > Hi!
> >
> > > > > > > > As said on the book, in a DAL select, orderby='<random>' is
> not supported on
> > > > > > > > GAE.
> http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-...
> >
> > > > > > > > Someone knows the best way to randomize a Rows dictionary?
> > > > > > > > (thinking in GAE deployment of course)
> >
> > > > > > > > Thanks in advance.
> >
> >
>

Reply via email to