I've got a weird problem where if I filter a DateTimeProperty with
either a "<" or ">" I get a 500 server error, but if I filter with "="
I don't get the error. Any advice would be welcome!
Here's the code that *doesn't* result in the error:
class Session(db.Model):
fcid = db.StringProperty()
name = db.StringProperty()
created = db.DateTimeProperty(auto_now_add=True)
def test_case():
# kill existing sessions
q = db.GqlQuery("SELECT __key__ FROM Session")
results = q.fetch(10)
db.delete(results)
# make new session
session = Session()
session.fcid = 'mike'
session.name = 'Mike Cantelon'
session.put()
# so now if we get all sessions with a created greater than an hour
ago
# we should get one
hour = datetime.timedelta(hours=1)
date_hour_ago = datetime.datetime.today() - hour
sessions = Session.all()
sessions.filter("fcid =", 'mike')
sessions.filter("created =", date_hour_ago)
for session in sessions:
print session.name
print session.created
Here's the code that *does* result in the error (identical except for
the comparison operator):
class Session(db.Model):
fcid = db.StringProperty()
name = db.StringProperty()
created = db.DateTimeProperty(auto_now_add=True)
def test_case():
# kill existing sessions
q = db.GqlQuery("SELECT __key__ FROM Session")
results = q.fetch(10)
db.delete(results)
# make new session
session = Session()
session.fcid = 'mike'
session.name = 'Mike Cantelon'
session.put()
# so now if we get all sessions with a created greater than an hour
ago
# we should get one
hour = datetime.timedelta(hours=1)
date_hour_ago = datetime.datetime.today() - hour
sessions = Session.all()
sessions.filter("fcid =", 'mike')
sessions.filter("created >", date_hour_ago)
for session in sessions:
print session.name
print session.created
Any advice on what is causing this would be welcome!
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---