def cross_domain(origin_check=is_trusted_origin, **options):
 def cross_domain_wrap(fn):
  cors_perms = {'origin_check': origin_check, 'allow_credentials': bool(options.get('allow_credentials'))}
  @wraps(fn)
  def cross_domain_handler(self, *args, **kwargs):
   if (request.params.get('hoist') == 'cookie'):
    if cors_perms['origin_check'](g.origin):
     name = request.environ['pylons.routes_dict']['action_name']
     resp = fn(self, *args, **kwargs)
     c.cookies.add(('hoist_%s' % name), ''.join(tup(resp)))
     response.content_type = 'text/html'
     return ''
    else:
     abort(403)
   else:
    self.check_cors()
    return fn(self, *args, **kwargs)
  cross_domain_handler.cors_perms = cors_perms
  return cross_domain_handler
 return cross_domain_wrap

def cross_domain ( origin_check = is_trusted_origin , ** options ) : def cross_domain_wrap ( fn ) : cors_perms = { 'origin_check' : origin_check , 'allow_credentials' : bool ( options . get ( 'allow_credentials' ) ) } @ wraps ( fn ) def cross_domain_handler ( self , * args , ** kwargs ) : if ( request . params . get ( 'hoist' ) == 'cookie' ) : if cors_perms [ 'origin_check' ] ( g . origin ) : name = request . environ [ 'pylons.routes_dict' ] [ 'action_name' ] resp = fn ( self , * args , ** kwargs ) c . cookies . add ( ( 'hoist_%s' % name ) , '' . join ( tup ( resp ) ) ) response . content_type = 'text/html' return '' else : abort ( 403 ) else : self . check_cors ( ) return fn ( self , * args , ** kwargs ) cross_domain_handler . cors_perms = cors_perms return cross_domain_handler return cross_domain_wrap
set up cross domain validation and hoisting for a request handler .