summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2011-04-19 12:49:42 -0400
committerBarry Warsaw2011-04-19 12:49:42 -0400
commit23bed0392f25df18478c01aa991c289b83069307 (patch)
treeb6c7b62c390ea710e47a747b47e7f114ee8493dd
parentb6b5825bf19e6fb9c5f13ffe2558c1a3531b8b85 (diff)
downloadmailman-23bed0392f25df18478c01aa991c289b83069307.tar.gz
mailman-23bed0392f25df18478c01aa991c289b83069307.tar.zst
mailman-23bed0392f25df18478c01aa991c289b83069307.zip
Give user resources and user address resources a self_link.
-rw-r--r--src/mailman/rest/docs/users.txt75
-rw-r--r--src/mailman/rest/users.py2
2 files changed, 46 insertions, 31 deletions
diff --git a/src/mailman/rest/docs/users.txt b/src/mailman/rest/docs/users.txt
index adca53ea3..4a73ab8d8 100644
--- a/src/mailman/rest/docs/users.txt
+++ b/src/mailman/rest/docs/users.txt
@@ -29,6 +29,7 @@ When there are users in the database, they can be retrieved as a collection.
http_etag: "..."
password: None
real_name: Anne Person
+ self_link: http://localhost:9001/3.0/users/1
user_id: 1
http_etag: "..."
start: 0
@@ -74,6 +75,7 @@ It is also available via the location given in the response.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
Because email addresses just have an ``@`` sign in then, there's no confusing
@@ -84,6 +86,7 @@ them with user ids. Thus, a user can be retrieved via its email address.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
Users can be created without a password. A *user friendly* password will be
@@ -107,6 +110,7 @@ therefore cannot be retrieved. It can be reset though.
http_etag: "..."
password: {CLEARTEXT}...
real_name: Cris Person
+ self_link: http://localhost:9001/3.0/users/3
user_id: 3
@@ -149,37 +153,42 @@ sorted in lexical order by original (i.e. case-preserved) email address.
>>> transaction.commit()
>>> dump_json('http://localhost:9001/3.0/users/2/addresses')
- entry 0:
- email: bart.q.person@example.com
- http_etag: "..."
- original_email: Bart.Q.Person@example.com
- real_name:
- registered_on: None
- verified_on: None
- entry 1:
- email: bart.person@example.com
- http_etag: "..."
- original_email: bart.person@example.com
- real_name:
- registered_on: None
- verified_on: None
- entry 2:
- email: bart@example.com
- http_etag: "..."
- original_email: bart@example.com
- real_name: Bart Person
- registered_on: None
- verified_on: None
- entry 3:
- email: bperson@example.com
- http_etag: "..."
- original_email: bperson@example.com
- real_name:
- registered_on: None
- verified_on: None
- http_etag: "..."
- start: 0
- total_size: 4
+ entry 0:
+ email: bart.q.person@example.com
+ http_etag: "..."
+ original_email: Bart.Q.Person@example.com
+ real_name:
+ registered_on: None
+ self_link:
+ http://localhost:9001/3.0/addresses/Bart.Q.Person@example.com
+ verified_on: None
+ entry 1:
+ email: bart.person@example.com
+ http_etag: "..."
+ original_email: bart.person@example.com
+ real_name:
+ registered_on: None
+ self_link: http://localhost:9001/3.0/addresses/bart.person@example.com
+ verified_on: None
+ entry 2:
+ email: bart@example.com
+ http_etag: "..."
+ original_email: bart@example.com
+ real_name: Bart Person
+ registered_on: None
+ self_link: http://localhost:9001/3.0/addresses/bart@example.com
+ verified_on: None
+ entry 3:
+ email: bperson@example.com
+ http_etag: "..."
+ original_email: bperson@example.com
+ real_name:
+ registered_on: None
+ self_link: http://localhost:9001/3.0/addresses/bperson@example.com
+ verified_on: None
+ http_etag: "..."
+ start: 0
+ total_size: 4
In fact, any of these addresses can be used to look up Bart's user record.
::
@@ -189,6 +198,7 @@ In fact, any of these addresses can be used to look up Bart's user record.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
>>> dump_json('http://localhost:9001/3.0/users/bart.person@example.com')
@@ -196,6 +206,7 @@ In fact, any of these addresses can be used to look up Bart's user record.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
>>> dump_json('http://localhost:9001/3.0/users/bperson@example.com')
@@ -203,6 +214,7 @@ In fact, any of these addresses can be used to look up Bart's user record.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
>>> dump_json('http://localhost:9001/3.0/users/Bart.Q.Person@example.com')
@@ -210,4 +222,5 @@ In fact, any of these addresses can be used to look up Bart's user record.
http_etag: "..."
password: {CLEARTEXT}bbb
real_name: Bart Person
+ self_link: http://localhost:9001/3.0/users/2
user_id: 2
diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py
index 54402096f..14ed04316 100644
--- a/src/mailman/rest/users.py
+++ b/src/mailman/rest/users.py
@@ -52,6 +52,7 @@ class _UserBase(resource.Resource, CollectionMixin):
password=user.password,
user_id=user.user_id,
created_on=user.created_on,
+ self_link=path_to('users/{0}'.format(user.user_id)),
)
def _get_collection(self, request):
@@ -145,6 +146,7 @@ class _AllUserAddresses(resource.Resource, CollectionMixin):
original_email=address.original_email,
real_name=address.real_name,
registered_on=address.registered_on,
+ self_link=path_to('addresses/{0}'.format(address.original_email)),
verified_on=address.verified_on,
)