google app engine - NDB Query not returning most recently added object -
i have gae website. home page displays list of project objects , form adding more projects. when submit button pressed, ajax request made runs 'create_userstoryproject()' method. method adds new project , returns list of projects, including 1 added. reason, query in 'create_userstoryproject()' method not return project added. however, if refresh page, causing 'get()' method run, newly added project shows fine. haven't simplified code--it's cut , pasted. have idea why newly created project doesn't show until refresh page?
class home(baseapp): #baseapp derived webapp2.requesthandler def get(self): self.context['userstoryprojects'] = userstoryproject.query().order(userstoryproject.order) self.context['userstorystatuses'] = userstorystatus.query().order(userstorystatus.order) self.render('/userstories') def create_userstoryproject(self): description = self.request.get('userstoryproject[description]', default_value=none) if description: userstoryproject = userstoryproject() userstoryproject.description = description userstoryproject.put() self.context['userstoryprojects'] = userstoryproject.query().order(userstoryproject.order) self.render('/userstoryprojects') else: self.write("fail.")
this because of eventual consistency.
Comments
Post a Comment