<s> """<STR_LIT>""" <EOL> from functools import update_wrapper <EOL> from google . appengine . api import users <EOL> from werkzeug import redirect <EOL> from werkzeug . exceptions import Forbidden <EOL> from kay . utils import ( <EOL> create_login_url , create_logout_url <EOL> ) <EOL> from kay . utils . decorators import auto_adapt_to_methods <EOL> def login_required ( func ) : <EOL> def inner ( request , * args , ** kwargs ) : <EOL> if request . user . is_anonymous ( ) : <EOL> if request . is_xhr : <EOL> return Forbidden ( ) <EOL> else : <EOL> return redirect ( create_login_url ( request . url ) ) <EOL> return func ( request , * args , ** kwargs ) <EOL> update_wrapper ( inner , func ) <EOL> return inner <EOL> login_required = auto_adapt_to_methods ( login_required ) <EOL> def admin_required ( func ) : <EOL> def inner ( request , * args , ** kwargs ) : <EOL> if not request . user . is_admin : <EOL> if request . user . is_anonymous ( ) : <EOL> return redirect ( create_login_url ( request . url ) ) <EOL> else : <EOL> raise Forbidden ( <EOL> description = <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> create_logout_url ( request . url ) <EOL> ) <EOL> return func ( request , * args , ** kwargs ) <EOL> update_wrapper ( inner , func ) <EOL> return inner <EOL> admin_required = auto_adapt_to_methods ( admin_required ) </s>
