我正在检修的网站目前正在使用python 2.3.7,并且使用Google App Engine进行管理,必须将其更新为2.7,并且由于新版本功能,模板部分已经过折旧。需要做出什么样的改变呢?仅供参考,我是一名高中生,为聊天室网站做这件事。当我重写app.yaml的更改时,更改.py内的代码(然后我将文件重新命名为.app),它会抛出此回溯错误。帮助
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
handler = __import__(path[0])
ImportError: No module named devchat
我的导入
import cgi
import os
import urllib
import logging
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.api import memcache
有关模板的代码部分在这里
class BaseRequestHandler(webapp.RequestHandler):
def generate(self, template_name, template_values={}):
# We check if there is a current user and generate a login or logout URL
user = users.get_current_user()
if user:
log_in_out_url = users.create_logout_url('/')
else:
log_in_out_url = users.create_login_url(self.request.path)
# We'll display the user name if available and the URL on all pages
values = {'user': user, 'log_in_out_url': log_in_out_url}
values.update(template_values)
# Construct the path to the template
directory = os.path.dirname(__file__)
path = os.path.join(directory, 'templates', template_name)
# Respond to the request by rendering the template
self.response.out.write(template.render(path, values, debug=_DEBUG))
class MainRequestHandler(BaseRequestHandler):
def get(self):
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
template_values = {
'url': url,
'url_linktext': url_linktext,
}
self.generate('index.html', template_values);
class ChatsRequestHandler(BaseRequestHandler):
def renderChats(self):
greetings_query = Greeting.all().order('date')
greetings = greetings_query.fetch(1000)
template_values = {
'greetings': greetings,
}
return self.generate('chats.html', template_values)
def getChats(self, useCache=True):
if useCache is False:
greetings = self.renderChats()
if not memcache.set("chat", greetings, 10):
logging.error("Memcache set failed:")
return greetings
greetings = memcache.get("chats")
if greetings is not None:
return greetings
else:
greetings = self.renderChats()
if not memcache.set("chat", greetings, 10):
logging.error("Memcache set failed:")
return greetings
def get(self):
self.getChats()
def post(self):
greeting = Greeting()
if users.get_current_user():
greeting.author = users.get_current_user()
greeting.content = self.request.get('content')
greeting.put()
self.getChats(False)`
答案 0 :(得分:0)
这是一个非常好的视频,它解释了如何更新应用程序:https://developers.google.com/events/io/sessions/gooio2012/300/