parameters: (self, channel_id, url, country_id=False)
return_statement: return _match(self.search(domain))
docstring: determine if a rule of the given channel matches with the given url
              :param channel_id : the identifier of the channel_id
              :param url : the url to match with a rule
              :param country_id : the identifier of the country
              :returns the rule that matches the given condition. False otherwise.
              :rtype : im_livechat.channel.rule
docstring_summary: determine if a rule of the given channel matches with the given url
              :param channel_id : the identifier of the channel_id
              :param url : the url to match with a rule
              :param country_id : the identifier of the country
              :returns the rule that matches the given condition. False otherwise.
              :rtype : im_livechat.channel.rule
docstring_tokens: determine if a rule of the given channel matches with the given url : param channel_id : the identifier of the channel_id : param url : the url to match with a rule : param country_id : the identifier of the country : returns the rule that matches the given condition . False otherwise . : rtype : im_livechat . channel . rule
function: def match_rule(self, channel_id, url, country_id=False):
          """ determine if a rule of the given channel matches with the given url
              :param channel_id : the identifier of the channel_id
              :param url : the url to match with a rule
              :param country_id : the identifier of the country
              :returns the rule that matches the given condition. False otherwise.
              :rtype : im_livechat.channel.rule
          """
          def _match(rules):
              for rule in rules:
                  # url might not be set because it comes from referer, in that
                  # case match the first rule with no regex_url
                  if re.search(rule.regex_url or '', url or ''):
                      return rule
              return False
          # first, search the country specific rules (the first match is returned)
          if country_id: # don't include the country in the research if geoIP is not installed
              domain = [('country_ids', 'in', [country_id]), ('channel_id', '=', channel_id)]
              rule = _match(self.search(domain))
              if rule:
                  return rule
          # second, fallback on the rules without country
          domain = [('country_ids', '=', False), ('channel_id', '=', channel_id)]
          return _match(self.search(domain))
function_tokens: def match_rule ( self , channel_id , url , country_id = False ) : def _match ( rules ) : for rule in rules : # url might not be set because it comes from referer, in that # case match the first rule with no regex_url if re . search ( rule . regex_url or '' , url or '' ) : return rule return False # first, search the country specific rules (the first match is returned) if country_id : # don't include the country in the research if geoIP is not installed domain = [ ( 'country_ids' , 'in' , [ country_id ] ) , ( 'channel_id' , '=' , channel_id ) ] rule = _match ( self . search ( domain ) ) if rule : return rule # second, fallback on the rules without country domain = [ ( 'country_ids' , '=' , False ) , ( 'channel_id' , '=' , channel_id ) ] return _match ( self . search ( domain ) )