由于某种原因,loaders.py 的第 171行将文件对象解释为FakeFile
Type(f) 返回“google.appengine.tools.devappserver2.python.stubs.FakeFile”类型的类
代码
appengine_config.py
import os, sys
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
sys.path.insert(0, 'lib.zip')
vendor.add('lib')
else:
vendor.add('C:\Code\App-Engine\cfc-melbourne-website\lib')
if os.name == 'nt':
os.name = None
sys.platform = ''
import re
from google.appengine.tools.devappserver2.python import stubs
re_ = stubs.FakeFile._skip_files.pattern.replace('|^lib/.*', '')
re_ = re.compile(re_)
stubs.FakeFile._skip_files = re_
sys.path.insert(0, 'lib')
sys.path.insert(0, 'lib')
管理路线
from flask import Blueprint
from flask import render_template
from app.decorators.authentication import authenticate_admin
from app.admin.routes.conference_forms_routes import init_conference_forms
def admin_blueprints(app):
admin_routes = Blueprint("admin", __name__, template_folder='../../templates', static_folder='../../static')
init_conference_forms(admin_routes)
@admin_routes.route('/xxxx')
def admin_landing():
return render_template('admin/admin_landing.html')
app.register_blueprint(admin_routes)
运行 Flask 应用程序给我以下错误。
AttributeError: 'FakeFile' object has no attribute 'read_given_key'
File "lib\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "lib\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "lib\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "lib\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "lib\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Code\App-Engine\cfc-melbourne-website\app\main\routes\home_routes.py", line 22, in main
return render_template('main.html')
File "lib\flask\templating.py", line 133, in render_template
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "lib\jinja2\environment.py", line 869, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "lib\jinja2\environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "lib\jinja2\environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "lib\jinja2\loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "lib\flask\templating.py", line 57, in get_source
return self._get_source_fast(environment, template)
File "lib\flask\templating.py", line 82, in _get_source_fast
return loader.get_source(environment, template)
File "lib\jinja2\loaders.py", line 175, in get_source
contents = f.read_given_key().decode(self.encoding)
不知道为什么会这样。
loaders.py 函数在哪里轰炸
def get_source(self, environment, template):
pieces = split_template_path(template)
for searchpath in self.searchpath:
filename = path.join(searchpath, *pieces)
f = open_if_exists(filename)
if f is None:
continue
try:
contents = f.read_given_key().decode(self.encoding)
finally:
f.close()
mtime = path.getmtime(filename)
def uptodate():
try:
return path.getmtime(filename) == mtime
except OSError:
return False
return contents, filename, uptodate
raise TemplateNotFound(template)
app.yaml 的内容
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?.*/node_modules/.*$
- ^(.*/)?.*/client_libs/.*$
- ^(.*/)?\.bowerrc$
- ^(.*/)?\.bower.json$
- ^(.*/)?\.gulpfile.js$
- ^(.*/)?\.package.json$
- ^(.*/)?\.requirements.txt$
- ^(.*/)?\.upload.bat$