summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2010-06-18 14:04:45 -0400
committerBarry Warsaw2010-06-18 14:04:45 -0400
commitf4e7637b1682f025cc6c8bfb172eda8b710e3218 (patch)
treebbc66b16c54656e572d83dfb5ff2a40b6c638e13 /src
parent7a147b7d1dee75f488102783550ec4f1fa36249c (diff)
downloadmailman-f4e7637b1682f025cc6c8bfb172eda8b710e3218.tar.gz
mailman-f4e7637b1682f025cc6c8bfb172eda8b710e3218.tar.zst
mailman-f4e7637b1682f025cc6c8bfb172eda8b710e3218.zip
Because we'll often need to turn functions into restish matchers, add a
convenient decorator.
Diffstat (limited to 'src')
-rw-r--r--src/mailman/rest/helpers.py11
-rw-r--r--src/mailman/rest/lists.py9
2 files changed, 14 insertions, 6 deletions
diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py
index 369eebffa..8a82ebb60 100644
--- a/src/mailman/rest/helpers.py
+++ b/src/mailman/rest/helpers.py
@@ -24,6 +24,7 @@ __all__ = [
'ContainerMixin',
'etag',
'path_to',
+ 'restish_matcher',
]
@@ -162,3 +163,13 @@ class Validator:
missing = COMMASPACE.join(sorted(required_keys - value_keys))
raise ValueError('Missing parameters: {0}'.format(missing))
return values
+
+
+
+# XXX 2010-02-24 barry Seems like contrary to the documentation, matchers
+# cannot be plain functions, because matchers must have a .score attribute.
+# OTOH, I think they support regexps, so that might be a better way to go.
+def restish_matcher(function):
+ """Decorator for restish matchers."""
+ function.score = ()
+ return function
diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py
index 947869cd9..2349ac286 100644
--- a/src/mailman/rest/lists.py
+++ b/src/mailman/rest/lists.py
@@ -34,11 +34,13 @@ from mailman.interfaces.domain import BadDomainSpecificationError
from mailman.interfaces.listmanager import (
IListManager, ListAlreadyExistsError)
from mailman.interfaces.member import MemberRole
-from mailman.rest.helpers import CollectionMixin, Validator, etag, path_to
+from mailman.rest.helpers import (
+ CollectionMixin, Validator, etag, path_to, restish_matcher)
from mailman.rest.members import AMember
+@restish_matcher
def member_matcher(request, segments):
"""A matcher of member URLs inside mailing lists.
@@ -56,11 +58,6 @@ def member_matcher(request, segments):
# 3-tuple of (match_args, match_kws, segments).
return (), dict(role=role, address=segments[1]), ()
-# XXX 2010-02-24 barry Seems like contrary to the documentation, matchers
-# cannot be plain function, because matchers must have a .score attribute.
-# OTOH, I think they support regexps, so that might be a better way to go.
-member_matcher.score = ()
-
class _ListBase(resource.Resource, CollectionMixin):