+ 2.7에 파이썬에서 GAE 마이그레이션 이후 자동으로 다시로드되지 내가 뛰어 때 self.redirect ('/')을 통해 메인 클래스에 연결하면 페이지가 자동으로 다시로드되지 않습니다. MakeGuestbookEntry 클래스에서 수행 된 최신 방명록 항목을 보려면 수동으로 브라우저 창을 다시로드해야합니다 (예 : F5를 통해).웹 응용 프로그램 내가이 구글 GAE 튜토리얼 비디오에서 좋은 오래된 방명록 예를 마이그레이션하려고 2.5.2 + 웹 애플리케이션 webapp2
파이썬 2.5.2 + webapp에서는이 문제가 존재하지 않았습니다.
#!/usr/bin/env python
Import OS, says
import wsgiref.handlers
import webapp2
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
class guestbook(db.Model):
message = db.StringProperty(required=True)
when = db.DateTimeProperty(auto_now_add=True)
who = db.StringProperty()
class ShowGuestbookPage(webapp2.RequestHandler):
def get(self):
# Read from the Datastore
shouts = db.GqlQuery('SELECT * FROM guestbook ORDER BY when DESC')
values = {'shouts': shouts}
self.response.out.write(template.render('main.html', values))
class MakeGuestbookEntry(webapp2.RequestHandler):
def post(self):
shout = guestbook(message=self.request.get('message'), who=self.request.get('who'))
# Write into the datastore
shout.put()
self.redirect('/')
app = webapp2.WSGIApplication([('/', ShowGuestbookPage),
('/make_entry', MakeGuestbookEntry),
debug=True)
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()
이것은 HTML 페이지의 main.html에게 어떤 도움
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple Guestbook with the Google App Engine</title>
</head>
<body>
<h3>Simple Guestbook with the Google App Engine</h3>
{% for shout in shouts %}
<div>
{% if shout.who %}
<b>{{shout.who}}</b>
{% else %}
<b>Anonymous</b>
{% endif %}
sagt:
<b>{{shout.message}}</b>
</div>
{% endfor %}
<p>
<form action="make_entry" method="post" accept-charset="utf-8">
Name: <input type="text" size="20" name="who" value="" if="who">
Nachricht: <input type="text" size="20" name="message" value="" if="message">
<input type="submit" value="Absenden">
</form>
</body>
</html>
감사입니다 :
이
는 파이썬 코드 파일 main.py입니다. 최고 감사합니다
감사합니다. 이로 인해 "문제"가 발생합니다. 설계대로 작동하기 때문에 실제 문제는 아닙니다. 그러나 제 생각에 이것은 이전의 시스템을 사용하기가 간단 해졌습니다. 소스 코드를 많이 변경하지 않고 강력한 일관성을 사용하도록하는 방법을 알고 있습니까? Google의 설명을 이해하려고했지만 코드가 작동하는 방식으로 코드를 변경할 수 없었습니다. – Neverland
내가 알고있는 유일한 방법은 조상 쿼리를 사용하는 것입니다. 예를 들어 특정 방명록의 각 인사말은 해당 방명록을 부모로 사용합니다. 그리고 예, 그것이 귀찮다는 것에 동의합니다. 몇 달 전에 같은 문제가 발생했습니다 ... Google이 GAE 애플리케이션에서이 사실을 숨기지 않는 것은 멍청한 일입니다. –