首页 > 代码库 > Debug
Debug
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.2\helpers\pydev\pydevd.py", line 2357, in
globals = debugger.run(setup[‘file‘], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.2\helpers\pydev\pydevd.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/flaskr\app_init__.py", line 43, in createapp
app.register_blueprint(api_1_0_blueprint, url_prefix=‘/api/v1.0‘)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\app.py", line 65, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\app.py", line 968, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\blueprints.py", line 154, in register
deferred(state)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\blueprints.py", line 129, in wrapper
func(state)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\blueprints.py", line 400, in
self.name, code_or_exception, f))
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\app.py", line 65, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\app.py", line 1201, in registererror_handler
exc_class, code = self.getexc_class_and_code(code_or_exception)
File "C:\Users\Liu_100\AppData\Roaming\Python\Python27\site-packages\flask\app.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])
)
Debug