def require_mime(*mimes):
 @decorator
 def wrap(f, self, request, *args, **kwargs):
  m = Mimer(request)
  realmimes = set()
  rewrite = {'json': 'application/json', 'yaml': 'application/x-yaml', 'xml': 'text/xml', 'pickle': 'application/python-pickle'}
  for (idx, mime) in enumerate(mimes):
   realmimes.add(rewrite.get(mime, mime))
  if (not (m.content_type() in realmimes)):
   return rc.BAD_REQUEST
  return f(self, request, *args, **kwargs)
 return wrap

def require_mime ( * mimes ) : @ decorator def wrap ( f , self , request , * args , ** kwargs ) : m = Mimer ( request ) realmimes = set ( ) rewrite = { 'json' : 'application/json' , 'yaml' : 'application/x-yaml' , 'xml' : 'text/xml' , 'pickle' : 'application/python-pickle' } for ( idx , mime ) in enumerate ( mimes ) : realmimes . add ( rewrite . get ( mime , mime ) ) if ( not ( m . content_type ( ) in realmimes ) ) : return rc . BAD_REQUEST return f ( self , request , * args , ** kwargs ) return wrap
decorator requiring a certain mimetype .