Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm writing a quite simple web application based on Google's Application Engine. It's the first time I'm working with Python and Google's datastore.

The application should display some questions on its home page. Those questions are stored in a table named Question.

class Question(db.Model):
  question_id = db.IntegerProperty()
  question = db.StringProperty()

The following code selects all entries of this table and commits the data to the template.

questions = db.GqlQuery('SELECT * FROM Question ORDER BY question_id')

# debugging loop
for question in questions:
  logging.info(questions.question_id)

template_values = {
  'questions' : questions
}

And finally, the template displays the questions on the index.html.

{% for question in questions %}
  // HTML-CODE
  {{ question.question }}
  // HTML-CODE
{% endfor %}

Actually, those (very basic) operations are running well but the program skips or adds questions to the list twice. This happens completely random. I even thought it might be disappeared when it didn't pop up for hours. The error must occur immediately after the GqlQuery statement as the debugging loop already indicates wrong ids.

Which question gets skipped or added is randomly as well, I can't see a pattern here. The only thing is, that it's either one question more or less than expected. It never appears that one question gets skipped and another is added twice at the same time. The table Question only contains five entries at the moment, so it's very manageable.

I hope this isn't just a result of my lack of experience. I spent days on this issue.

Thank you in advance.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.