Hi all,

I'm running into a strange issue with the Python datastore API where
using a ">" or "<" operator to filter a DateTimeProperty property
gives me an "Error: Server Error".

Here is the working code (using the "=" operator on the "created"
property):

class Session(db.Model):
  fcid = db.StringProperty()
  name = db.StringProperty()
  #authenticated = 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 is the code that results in the error (the only difference is
using a ">" or "<" filter operator on the "created" property):

class Session(db.Model):
  fcid = db.StringProperty()
  name = db.StringProperty()
  #authenticated = 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 the underlying issue would be appreciated!

Cheers,
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to