'Compiles the regular expression and stores it.'

def compile(self):

    assert (self.map is not None), 'rule    not    bound'
    if self.map.host_matching:
        domain_rule = (self.host or '')
    else:
        domain_rule = (self.subdomain or '')
    self._trace = []
    self._converters = {}
    self._weights = []
    regex_parts = []
    def _build_regex(rule):
        for (converter, arguments, variable) in parse_rule(rule):
            if (converter is None):
                regex_parts.append(re.escape(variable))
                self._trace.append((False, variable))
                for part in variable.split('/'):
                    if part:
                        self._weights.append((0, (- len(part))))
            else:
                if arguments:
                    (c_args, c_kwargs) = parse_converter_args(arguments)
                else:
                    c_args = ()
                    c_kwargs = {}
                convobj = self.get_converter(variable, converter, c_args, c_kwargs)
                regex_parts.append(('(?P<%s>%s)' % (variable, convobj.regex)))
                self._converters[variable] = convobj
                self._trace.append((True, variable))
                self._weights.append((1, convobj.weight))
                self.arguments.add(str(variable))
    _build_regex(domain_rule)
    regex_parts.append('\\|')
    self._trace.append((False, '|'))
    _build_regex(((self.is_leaf and self.rule) or self.rule.rstrip('/')))
    if (not self.is_leaf):
        self._trace.append((False, '/'))
    if self.build_only:
        return
    regex = ('^%s%s$' % (u''.join(regex_parts), ((((not self.is_leaf) or (not self.strict_slashes)) and '(?<!/)(?P<__suffix__>/?)') or '')))
    self._regex = re.compile(regex, re.UNICODE)
