- def __init__(self, uri=None):
- if uri is not None:
- self.uri = uri
- match = self._re_wl_uri.match(uri)
- assert match
- self.slug = match.group('slug')
- self.language = match.group('lang') or self.DEFAULT_LANGUAGE
+ def __init__(self, uri):
+ uri = unicode(uri)
+ self.uri = uri
+ self.slug = uri.rstrip('/').rsplit('/', 1)[-1]
+
+ @classmethod
+ def strict(cls, uri):
+ match = cls._re_wl_uri.match(uri)
+ if not match:
+ raise ValueError('Supplied URI (%s) does not match '
+ 'the template: %s.' % (uri, cls._re_wl_uri))
+ return cls(uri)