taskLogs is a db.GqlQuery. The only way it will be None is if the db.GqlQuery() constructor fails horribly.
to count rows returned, use count(). On May 19, 4:05 pm, Neal <[email protected]> wrote: > I switched the GQL Query to the following. > Now the GQL Query no longer gives 500 severe error, but almost > anything I code after that does give the 500 severe error. > I need to test if I returned any rows or not, ideally one. > > taskLogs = db.GqlQuery("SELECT * FROM TaskLog where taskCode = : > 1 " + > " and workerEmail = :2 " + > " and eventStartedDateTime = :3", > taskCode, > users.get_current_user().email(), > startedTime); > #if taskLogs is None: > # DebugText = "No rows returned" > ###if len(taskLogs) <> 1: > ### DebugText = " Error: more than one matching row found " > #else: > #DebugText = DebugText + " len(taskLogs) = " + > len(taskLogs); > #for taskLog in taskLogs: > # taskLog1.eventStartedDateTime = datetime.datetime.now > (); > # taskLog1.put(); #save to BigTable database > # DebugText = DebugText + " Updated Row " > > If I un-comment these two statements, I get the 500 severe error: > #if taskLogs is None: > # DebugText = "No rows returned" > > So why don't I get some kind of trapped error? I'm finding the only > way to code this is to keep commenting out lines, and adding them back > in, and taking them out until something seems to work. > > Even when I remove the date/time test, the following code runs: > > taskLogs = db.GqlQuery("SELECT * FROM TaskLog where taskCode = : > 1 " + > " and workerEmail = :2 ", > taskCode, > users.get_current_user().email() > ); > > if taskLogs is None: > DebugText = "No rows returned;" > ###if len(taskLogs) <> 1: > ### DebugText = " Error: more than one matching row found " > else: > DebugText = DebugText + "Rows Returned" > #DebugText = DebugText + " len(taskLogs) = " + > len(taskLogs); > for taskLog in taskLogs: > taskLog.eventCompletedDateTime = datetime.datetime.now > (); > taskLog.put(); #save to BigTable database > DebugText = DebugText + " Updated Row; " > > What is the proper way to test the number of rows returned? > > Thanks again, > Neal Walters --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
