On Fri, Nov 25, 2011 at 11:46 PM, howesc wrote:
> looks like the exception there is because your query has an OR condition
> in it, which is not supported on GAE. that sort should be in-memory and
> should work fine.
>
I found, the error was because of the use of contains() in query
--
Brun
looks like the exception there is because your query has an OR condition in
it, which is not supported on GAE. that sort should be in-memory and
should work fine.
Isn't random sort suported in GAE ?
* rows = db(query).select().sort(lambda row: random.random())
> File
> "/base/data/home/apps/s~movucahq/0-1.354917246392574252/gluon/dal.py", line
> 5789, in select
> return self.db._adapter.select(self.query,fields,attributes)
> File
> "/base/data/home/apps/s~
as far as i know you would have to write some custom big table queries
(not using web2py dal). but in theory you could:
- write a direct query to get all the keys of a table (and no data)
- cache those keys
- randomly choose a set of keys from the full list
- write a google key query.
google is no
ah OK.
Anyway, how could this be done server-side when also using limit? I
want to show some random records without querying all the data.
Massimo is correct,
I just wanted to know the more efficient way to randomize a Rows dictionary,
instead of using orderby=.
Because as said on the book, orderby= is not supported on GAE.
Just easy as using python random library :)
Thanks again.
On Wed, Dec 8, 2010 at 1:04 AM, mdipierro 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 wrote:
> I think he's after an database-side implementation.
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 wrote:
> Not sure I understand our comment:
>
> rows=db(...).select().sort(lambda row: random.random())
>
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 wrote:
> Seems to be 1.89.5 (2010-11-21 16:03:13)..
>
> but wh
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 wrote:
> You have an old version. aidr is a type fixed some time ago.
>
> On Dec 7, 7:13 am, blackthorne wrote:
>
>
>
> > I don't see howcome this works as random sorting.
>
You have an old version. aidr is a type fixed some time ago.
On Dec 7, 7:13 am, blackthorne 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.
>
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$ py
On Dec 7, 1:16 am, Albert Abril wrote:
> I didn't know i could use imports in GAE
> Thank you Massimo.
Book updated to reflect Massimo's answer. I thought it best to
emphasize the technique of using imports in these situations.
and you can put your own modules in web2py/site-packages and they will
be deployed with your app.
On Dec 6, 5:16 pm, Albert Abril wrote:
> I didn't know i could use imports in GAE
> Thank you Massimo.
>
> On Mon, Dec 6, 2010 at 11:53 PM, mdipierro wrote:
> > import random
> > ...
> > rows=db(...
I didn't know i could use imports in GAE
Thank you Massimo.
On Mon, Dec 6, 2010 at 11:53 PM, mdipierro wrote:
> import random
> ...
> rows=db(...).select().sort(lambda row: random.random())
>
> On Dec 6, 4:09 pm, Albert Abril wrote:
> > Hi!
> >
> > As said on the book, in a DAL select, orderby
import random
...
rows=db(...).select().sort(lambda row: random.random())
On Dec 6, 4:09 pm, Albert Abril wrote:
> Hi!
>
> As said on the book, in a DAL select, orderby='' is not supported on
> GAE.http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-...
>
> Someone knows the best
16 matches
Mail list logo