views:

42

answers:

3

Hey, I'm having some trouble with stuff that work locally and dont work on the app engine python environment:

Basically, i want to get a program from an epg between ranges of date and time. i know i cannot do two where > < so i saw a suggestion to save the dates as list as datetime.datetime which i did.

[datetime.datetime(2010, 5, 10, 14, 25), datetime.datetime(2010, 5, 10, 15, 0)]

This is ok. but when i try to compare to it:

progranon = get_object(Programs2Channel, 
                           'channel_id =', channelobj.key(),
                           'endstartdate >', programstart_minex, 
                           'endstartdate <', programstart_minex
                           )

This for some reason works locally, but fails to retrieve the data on the app engine.

*Im using Google app engine django patch which uses the get_object to retrieve data in transactions.

Please help.

Here are more details:

this is the LIST:

[datetime.datetime(2010, 5, 13, 10, 45), datetime.datetime(2010, 5, 13, 11, 30)]

#this is the query:

programstart = ""+year+"-"+month+"-"+day+" "+hour+":"+minute
programstart_minex = datetime.strptime(programstart, "%Y-%m-%d %H:%M")

progranon = Programs2Channel.gql('WHERE channel_id = :channelid AND endstartdate > :programstartx AND endstartdate < :programstartx',channelid = channelobj.key(),programstartx=programstart_minex).get()
A: 

Unfortunately, this is a known issue with the dev_appserver and querying on lists.

However, the dev_appserver now includes an experimental sqlite stub, which doesn't have this issue. Try running it with --use_sqlite, and see if that helps - it should!

Nick Johnson
It does work locally on the dev server, so i should trust if it works on the local dev server?
Alon Carmel
I don't understand the question, sorry. Can you rephrase?
Nick Johnson
A: 

How about querying just querying for programs that start after mindate (just the > query) and then filtering in memory? If its a TV Guide, we're not talking thousand of possible entities right? probably ~100 tops?

Eran Kampf
A: 

could this be the issue?

From: http://code.google.com/appengine/docs/python/datastore/gqlreference.html

a datetime, date, or time literal, with either numeric values or a string representation, in the following forms: DATETIME(year, month, day, hour, minute, second) DATETIME('YYYY-MM-DD HH:MM:SS')

my local server dev saves the datetime as numerical YYYY-MM-DD while the app engine saves datetime.datetime(2010, 5, 10, 14, 25),

LOCAL datetime list:

2010-05-09 08:30:00,2010-05-09 09:00:00

APP ENGINE LIST:

[datetime.datetime(2010, 5, 13, 10, 45), datetime.datetime(2010, 5, 13, 11, 30)]

maybe this is the issue?

Alon Carmel
i came to a conclusion that you cannot compare > < to list anymore on the app engine. can someone confirm this?
Alon Carmel
I think you'd better ask on the Google AppEngine discussion board...
Eran Kampf