Traceback (most recent call last):
File "C:Program Files (x86)JetBrainsPyCharm Community Edition 4.5.2helperspydevpydevd.py", line 2357, in
globals = debugger.run(setup['file'], None, None, is_module)
File "C:Program Files (x86)JetBrainsPyCharm Community Edition 4.5.2helperspydevpydevd.py", line 1777, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:/Users/Liu_100/PycharmProjects/flask/flaskr/manage.py", line 13, in
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
File "C:/Users/Liu_100/PycharmProjects/flask/flaskrapp_init__.py", line 43, in createapp
app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0')
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflaskapp.py", line 65, in wrapper_func
return f(self, *args, **kwargs)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflaskapp.py", line 968, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflasklueprints.py", line 154, in register
deferred(state)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflasklueprints.py", line 129, in wrapper
func(state)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflasklueprints.py", line 400, in
self.name, code_or_exception, f))
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflaskapp.py", line 65, in wrapper_func
return f(self, *args, **kwargs)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflaskapp.py", line 1201, in registererror_handler
exc_class, code = self.getexc_class_and_code(code_or_exception)
File "C:UsersLiu_100AppDataRoamingPythonPython27site-packagesflaskapp.py", line 1125, in getexc_class_and_code
assert issubclass(exc_class, Exception)
TypeError: issubclass() arg 1 must be a class
问题出在createapp里app.register_blueprint
api = Blueprint('api', __name__)
from . import authentication, posts, users, comments, errors
在.errors里调用了一个exception.py里的ValidationError,错误声明为了def(应该是class)
api.errorhandler(ValidationError)
def validation_error(e):
return bad_request(e.args[0])
)