[web2py] Re: GAE select all does not iterate

2011-08-31 Thread Massimo Di Pierro
I am not sure where you are printing to (console, logs, html page) but
one problem may be that if you view the output into an HTML document
rows are displayed as  and your browser thinks this is a
tag, does not understand it and makes it invisible.

On Aug 31, 11:19 am, Arbie Samong  wrote:
> Update: Following christian's example, it seems that looping over the
> Rows object in controller does nothing, but looping over it on the
> view is working.
>
> My controllers and models are almost exactly the same, at least the
> fields that are affected. I am testing on localhost:8080 first,
> although same results in GAE production. I print out stuff on
> localhost:8080, it works although it breaks the page and displays
> withing  tags (ala php die ;-P), so I can see variables. I can
> see the Rows object and the fetched records, but when I iterate over
> them nothing happens.
>
> # controller
> profiles =
> db(db.userprofile.created).select(orderby=~db.userprofile.created,
> limitby=(0,20))
> print profiles # no problem, I see the profiles object
> print len(profiles) # still OK
>
> for profile in profiles:
>   print profile # here nothing happens
>
> # view
> profiles
> {{for profile in profiles:}}
>   {{=profile.title}}
> {{pass}}
>
> Now I'm not sure if this is a bug, but I would appreciate a way for me
> to make it work on the controller side because I'll need to fetch
> stuff that spans a couple of tables, and that would nicely fit in the
> controller instead of the view.
>
> Thanks,
> Arbie
>
> On Aug 29, 3:24 am, howesc  wrote:
>
>
>
>
>
>
>
>
>
> > here is what i just tried:
>
> > db.define_table('menu_item',
> >   Field('created_on','datetime', default=request.now,writable=False),
> >   Field('name', length=500, notnull=True, unique=True,
> >         requires=IS_NOT_IN_DB(db, 'menu_item.name')),
> >   migrate=migrate)
>
> > then in controller:
>
> > def index():
>
> > data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on,
> > limitby=(0,20))
>
> >     data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on,
> > limitby=(0,20))
>
> >     return dict(data=data, data2=data2)
>
> > then in view:
>
> > {{=BEAUTIFY(response._vars)}}
>
> > data
> > {{for d in data:}}
> >   {{=d.name}}
> > {{pass}}
>
> > 
> > data2
> > {{for d in data2:}}
> >   {{=d.name}}
> > {{pass}}
>
> > and got exactly what i was expecting.  some things i noticed:
> >  - i don't think db(db.menu_item.created_on) is a valid query.  it needs to
> > be compared to something right?  (i know it works, but it seems wrong to me)
> >  - print doesn't work on GAE (there is no console to output to in that
> > environment) so i assumed you were either using logging or outputting in a
> > view
>
> > can you tell me more, or send me a minimal application that produces the
> > problem and i'll try it out too?  it sounds like something is up, so let's
> > get to the bottom of it and get it fixed!
>
> > christian
>
> On Aug 29, 3:24 am, howesc  wrote:
>
>
>
>
>
>
>
> > here is what i just tried:
>
> > db.define_table('menu_item',
> >   Field('created_on','datetime', default=request.now,writable=False),
> >   Field('name', length=500, notnull=True, unique=True,
> >         requires=IS_NOT_IN_DB(db, 'menu_item.name')),
> >   migrate=migrate)
>
> > then in controller:
>
> > def index():
>
> > data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on,
> > limitby=(0,20))
>
> >     data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on,
> > limitby=(0,20))
>
> >     return dict(data=data, data2=data2)
>
> > then in view:
>
> > {{=BEAUTIFY(response._vars)}}
>
> > data
> > {{for d in data:}}
> >   {{=d.name}}
> > {{pass}}
>
> > 
> > data2
> > {{for d in data2:}}
> >   {{=d.name}}
> > {{pass}}
>
> > and got exactly what i was expecting.  some things i noticed:
> >  - i don't think db(db.menu_item.created_on) is a valid query.  it needs to
> > be compared to something right?  (i know it works, but it seems wrong to me)
> >  - print doesn't work on GAE (there is no console to output to in that
> > environment) so i assumed you were either using logging or outputting in a
> > view
>
> > can you tell me more, or send me a minimal application that produces the
> > problem and i'll try it out too?  it sounds like something is up, so let's
> > get to the bottom of it and get it fixed!
>
> > christian


[web2py] Re: GAE select all does not iterate

2011-08-31 Thread Arbie Samong
Update: Following christian's example, it seems that looping over the
Rows object in controller does nothing, but looping over it on the
view is working.

My controllers and models are almost exactly the same, at least the
fields that are affected. I am testing on localhost:8080 first,
although same results in GAE production. I print out stuff on
localhost:8080, it works although it breaks the page and displays
withing  tags (ala php die ;-P), so I can see variables. I can
see the Rows object and the fetched records, but when I iterate over
them nothing happens.

# controller
profiles =
db(db.userprofile.created).select(orderby=~db.userprofile.created,
limitby=(0,20))
print profiles # no problem, I see the profiles object
print len(profiles) # still OK

for profile in profiles:
  print profile # here nothing happens

# view
profiles
{{for profile in profiles:}}
  {{=profile.title}}
{{pass}}

Now I'm not sure if this is a bug, but I would appreciate a way for me
to make it work on the controller side because I'll need to fetch
stuff that spans a couple of tables, and that would nicely fit in the
controller instead of the view.


Thanks,
Arbie

On Aug 29, 3:24 am, howesc  wrote:
> here is what i just tried:
>
> db.define_table('menu_item',
>   Field('created_on','datetime', default=request.now,writable=False),
>   Field('name', length=500, notnull=True, unique=True,
>         requires=IS_NOT_IN_DB(db, 'menu_item.name')),
>   migrate=migrate)
>
> then in controller:
>
> def index():
>
> data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     return dict(data=data, data2=data2)
>
> then in view:
>
> {{=BEAUTIFY(response._vars)}}
>
> data
> {{for d in data:}}
>   {{=d.name}}
> {{pass}}
>
> 
> data2
> {{for d in data2:}}
>   {{=d.name}}
> {{pass}}
>
> and got exactly what i was expecting.  some things i noticed:
>  - i don't think db(db.menu_item.created_on) is a valid query.  it needs to
> be compared to something right?  (i know it works, but it seems wrong to me)
>  - print doesn't work on GAE (there is no console to output to in that
> environment) so i assumed you were either using logging or outputting in a
> view
>
> can you tell me more, or send me a minimal application that produces the
> problem and i'll try it out too?  it sounds like something is up, so let's
> get to the bottom of it and get it fixed!
>
> christian

On Aug 29, 3:24 am, howesc  wrote:
> here is what i just tried:
>
> db.define_table('menu_item',
>   Field('created_on','datetime', default=request.now,writable=False),
>   Field('name', length=500, notnull=True, unique=True,
>         requires=IS_NOT_IN_DB(db, 'menu_item.name')),
>   migrate=migrate)
>
> then in controller:
>
> def index():
>
> data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     return dict(data=data, data2=data2)
>
> then in view:
>
> {{=BEAUTIFY(response._vars)}}
>
> data
> {{for d in data:}}
>   {{=d.name}}
> {{pass}}
>
> 
> data2
> {{for d in data2:}}
>   {{=d.name}}
> {{pass}}
>
> and got exactly what i was expecting.  some things i noticed:
>  - i don't think db(db.menu_item.created_on) is a valid query.  it needs to
> be compared to something right?  (i know it works, but it seems wrong to me)
>  - print doesn't work on GAE (there is no console to output to in that
> environment) so i assumed you were either using logging or outputting in a
> view
>
> can you tell me more, or send me a minimal application that produces the
> problem and i'll try it out too?  it sounds like something is up, so let's
> get to the bottom of it and get it fixed!
>
> christian


[web2py] Re: GAE select all does not iterate

2011-08-29 Thread howesc
like is not supported on GAE, and for your particular like clause there is 
no real work-around for that on GAE.  there are some tricks for a couple of 
like cases mentioned on this thread here: 
http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query


[web2py] Re: GAE select all does not iterate

2011-08-28 Thread Jarrod Cugley
Here is my actual controller, it iterates perfectly on a web2py
server, but as soon as upload the exact same files to GAE it doesn't
iterate.

***
def livesearch():
'''Auto completes the search query'''
partialstr = request.vars.partialstr
query = db.listing.title.like('%'+partialstr+'%')
titles = db(query).select(db.listing.ALL)
items = []

for title in titles:
items.append(DIV(A(title.title, _id="livesearch_item",
_href=URL('search', args=title.title.replace(' ','-')

return TAG[''](*items)
***

I just realised I'm getting this error on GAE:

def LIKE(self,first,second): raise SyntaxError, "Not supported"
SyntaxError: Not supported

Does like() not work on GAE? How do I fix this? It works fine on the
web2py server.


On Aug 29, 5:24 am, howesc  wrote:
> here is what i just tried:
>
> db.define_table('menu_item',
>   Field('created_on','datetime', default=request.now,writable=False),
>   Field('name', length=500, notnull=True, unique=True,
>         requires=IS_NOT_IN_DB(db, 'menu_item.name')),
>   migrate=migrate)
>
> then in controller:
>
> def index():
>
> data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on,
> limitby=(0,20))
>
>     return dict(data=data, data2=data2)
>
> then in view:
>
> {{=BEAUTIFY(response._vars)}}
>
> data
> {{for d in data:}}
>   {{=d.name}}
> {{pass}}
>
> 
> data2
> {{for d in data2:}}
>   {{=d.name}}
> {{pass}}
>
> and got exactly what i was expecting.  some things i noticed:
>  - i don't think db(db.menu_item.created_on) is a valid query.  it needs to
> be compared to something right?  (i know it works, but it seems wrong to me)
>  - print doesn't work on GAE (there is no console to output to in that
> environment) so i assumed you were either using logging or outputting in a
> view
>
> can you tell me more, or send me a minimal application that produces the
> problem and i'll try it out too?  it sounds like something is up, so let's
> get to the bottom of it and get it fixed!
>
> christian


[web2py] Re: GAE select all does not iterate

2011-08-28 Thread howesc
here is what i just tried:

db.define_table('menu_item',
  Field('created_on','datetime', default=request.now,writable=False),
  Field('name', length=500, notnull=True, unique=True,
requires=IS_NOT_IN_DB(db, 'menu_item.name')),
  migrate=migrate)

then in controller:

def index():

data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on, 
limitby=(0,20))

data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on, 
limitby=(0,20))

return dict(data=data, data2=data2)


then in view:

{{=BEAUTIFY(response._vars)}}

data
{{for d in data:}}
  {{=d.name}}
{{pass}}


data2
{{for d in data2:}}
  {{=d.name}}
{{pass}}

and got exactly what i was expecting.  some things i noticed:
 - i don't think db(db.menu_item.created_on) is a valid query.  it needs to 
be compared to something right?  (i know it works, but it seems wrong to me)
 - print doesn't work on GAE (there is no console to output to in that 
environment) so i assumed you were either using logging or outputting in a 
view

can you tell me more, or send me a minimal application that produces the 
problem and i'll try it out too?  it sounds like something is up, so let's 
get to the bottom of it and get it fixed!

christian



[web2py] Re: GAE select all does not iterate

2011-08-28 Thread howesc
ok, i noted one difference is that i don't use the db.table.ALL in my 
selects.  i'll do some testing and see if i can figure it out.

cfh


[web2py] Re: GAE select all does not iterate

2011-08-27 Thread Arbie Samong
same with Jarrod, up to date with web2py and GAE sdk

web2py: 1.98.2 (2011-08-04 00:47:09)
gae: 1.5.3

Yes there is data in the namespace.

Thanks,
Arbie

On Aug 28, 5:36 am, howesc  wrote:
> i do this all the time and have never had problems.
>
> what web2py version are you using?  are you certain that there is data in
> the GAE production namespace that your are querying?
>
> cfh


[web2py] Re: GAE select all does not iterate

2011-08-27 Thread Jarrod Cugley
I am actually having the same problem, my select(db.listing.ALL) is
working fine on the web2py server but as soon as I run it on GAE it
doesn't work.

I'm using the latest web2py (1.98.2) and I'm also using the latest
version of GAE Launcher (1.5.3)

On Aug 28, 7:36 am, howesc  wrote:
> i do this all the time and have never had problems.
>
> what web2py version are you using?  are you certain that there is data in
> the GAE production namespace that your are querying?
>
> cfh


[web2py] Re: GAE select all does not iterate

2011-08-27 Thread howesc
i do this all the time and have never had problems.

what web2py version are you using?  are you certain that there is data in 
the GAE production namespace that your are querying?

cfh