def _canvas_route(self, *args, **kwargs):
def outer(view_fn):<EOL><INDENT>@self.route(*args, **kwargs)<EOL>def inner(*args, **kwargs):<EOL><INDENT>fn_args = getargspec(view_fn)<EOL>try:<EOL><INDENT>idx = fn_args.args.index(_ARG_KEY)<EOL><DEDENT>except ValueError:<EOL><INDENT>idx = -<NUM_LIT:1><EOL><DEDENT>if idx > -<NUM_LIT:1>:<EOL><INDENT>if '<STR_LIT:error>' in flask_request.args:<EOL><INDENT>return redirect('<STR_LIT>' % (<EOL>self.config.get('<STR_LIT>', '<STR_LIT:/>'),<EOL>flask_request.args.get('<STR_LIT:error>')))<EOL><DEDENT>if '<STR_LIT>' not in flask_request.form:<EOL><INDENT>self.logger.error('<STR_LIT>')<EOL>abort(<NUM_LIT>)<EOL><DEDENT>try:<EOL><INDENT>_, decoded_data = _decode_signed_user(<EOL>*flask_request.form['<STR_LIT>'].split('<STR_LIT:.>'))<EOL><DEDENT>except ValueError as e:<EOL><INDENT>self.logger.error(e.message)<EOL>abort(<NUM_LIT>)<EOL><DEDENT>if '<STR_LIT>' not in decoded_data:<EOL><INDENT>app.logger.info('<STR_LIT>')<EOL>return _authorize()<EOL><DEDENT>user = User(**decoded_data)<EOL>if not app.config.get('<STR_LIT>', False)and not user.has_permissions():<EOL><INDENT>self.logger.info(<EOL>'<STR_LIT>')<EOL>return _authorize()<EOL><DEDENT>self.logger.info('<STR_LIT>')<EOL>args = args[:idx - <NUM_LIT:1>] + (user,) + args[idx:]<EOL><DEDENT>return view_fn(*args, **kwargs)<EOL><DEDENT>return inner<EOL><DEDENT>return outer<EOL>
Decorator for canvas route