#NEWLINE# def match( self , url , environ = None , sub_domains = False , sub_domains_ignore = None , domain_match = '' ) : #NEWLINE# #INDENT# "Match a url to our regexp.\n\n        While the regexp might match, this operation isn't\n        guaranteed as there's other factors that can cause a match to\n        fail even though the regexp succeeds (Default that was relied\n        on wasn't given, requirement regexp doesn't pass, etc.).\n\n        Therefore the calling function shouldn't assume this will\n        return a valid dict, the other possible return is False if a\n        match doesn't work out.\n\n        " #NEWLINE# if self . static : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# match = self . regmatch . match ( url ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# sub_domain = None #NEWLINE# if ( sub_domains and environ and ( 'HTTP_HOST' in environ ) ) : #NEWLINE# #INDENT# host = environ [ 'HTTP_HOST' ] . split ( ':' ) [ 0 ] #NEWLINE# sub_match = re . compile ( ( '^(.+?)\\.%s$' % domain_match ) ) #NEWLINE# subdomain = re . sub ( sub_match , '\\1' , host ) #NEWLINE# if ( ( subdomain not in sub_domains_ignore ) and ( subdomain != subdomain ) ) : #NEWLINE# #INDENT# sub_domain = subdomain #NEWLINE# #UNINDENT# #UNINDENT# if self . conditions : #NEWLINE# #INDENT# if ( ( 'method' in self . conditions ) and environ and ( environ [ 'REQUEST_METHOD' ] not in self . conditions [ 'method' ] ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# use_sd = self . conditions . get ( 'sub_domain' ) #NEWLINE# if ( use_sd and ( not sub_domain ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not use_sd ) and ( 'sub_domain' in self . conditions ) and sub_domain ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( isinstance ( use_sd , list ) and ( sub_domain not in use_sd ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# matchdict = match . groupdict ( ) #NEWLINE# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# extras = ( self . _default_keys - frozenset ( matchdict . keys ( ) ) ) #NEWLINE# for ( key , val ) in six . iteritems ( matchdict ) : #NEWLINE# #INDENT# if ( ( key != 'path_info' ) and self . encoding ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# val = as_unicode ( val , self . encoding , self . decode_errors ) #NEWLINE# #UNINDENT# except UnicodeDecodeError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( ( not val ) and ( key in self . defaults ) and self . defaults [ key ] ) : #NEWLINE# #INDENT# result [ key ] = self . defaults [ key ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result [ key ] = val #NEWLINE# #UNINDENT# #UNINDENT# for key in extras : #NEWLINE# #INDENT# result [ key ] = self . defaults [ key ] #NEWLINE# #UNINDENT# if sub_domains : #NEWLINE# #INDENT# result [ 'sub_domain' ] = sub_domain #NEWLINE# #UNINDENT# if ( self . conditions and ( 'function' in self . conditions ) and ( not self . conditions [ 'function' ] ( environ , result ) ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return result