[silva.app.subscriptions][Sylvain Viollon] Fix label.
[email protected] Mon, 11 Nov 2013 14:46:00 +0100
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Fri Oct 25 18:25:21 2013 +0200
revision: 102:728f2bfcf585 in silva.app.subscriptions
branch: 2.4
details: https://hg.infrae.com/silva.app.subscriptions?cmd=changeset;node=728f2bfcf585
modified: src/silva/app/subscriptions/service.py
added:
removed:
log: Fix label.
Subject: [silva.app.subscriptions][Sylvain Viollon] Improve validation of the content_id from the user.
author: Sylvain Viollon
date: Mon Nov 11 14:42:02 2013 +0100
revision: 103:a3e303c87ac1 in silva.app.subscriptions
branch: 2.4
details: https://hg.infrae.com/silva.app.subscriptions?cmd=changeset;node=a3e303c87ac1
modified: src/silva/app/subscriptions/service.py
added:
removed:
log: Improve validation of the content_id from the user.
Subject: [silva.app.subscriptions][Sylvain Viollon] More refactoring on resolving the content.
author: Sylvain Viollon
date: Mon Nov 11 14:45:56 2013 +0100
revision: 104:e097b548db99 in silva.app.subscriptions
branch: 2.4
details: https://hg.infrae.com/silva.app.subscriptions?cmd=changeset;node=e097b548db99
modified: src/silva/app/subscriptions/service.py
added:
removed:
log: More refactoring on resolving the content.
diffstat:
src/silva/app/subscriptions/service.py | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diffs (57 lines):
diff -r 31999c21616f -r e097b548db99 src/silva/app/subscriptions/service.py
--- a/src/silva/app/subscriptions/service.py Fri Oct 25 18:24:24 2013 +0200
+++ b/src/silva/app/subscriptions/service.py Mon Nov 11 14:45:56 2013 +0100
@@ -42,6 +42,24 @@
logger = logging.getLogger('silva.app.subscriptions')
+def get_subscribable_content(identifier):
+ """Fetch a subscribable content out of an identifier.
+ """
+ if not identifier:
+ # Identifier is missing.
+ raise errors.NotSubscribableError()
+ try:
+ identifier = int(identifier)
+ except (ValueError, TypeError):
+ # Identifier is an invalid format.
+ raise errors.NotSubscribableError()
+ content = get_content_from_id(identifier)
+ if content is None:
+ # Idnetifier did not resolve.
+ raise errors.NotSubscribableError()
+ return content
+
+
class SubscriptionService(Folder.Folder, SilvaService):
"""Subscription Service
"""
@@ -149,8 +167,7 @@
# Check and confirm subscription
# NOTE: no doc string, so, not *publishable* TTW
#
- content = get_content_from_id(content_id)
- assert content is not None, u'Invalid content'
+ content = get_subscribable_content(content_id)
manager = ISubscriptionManager(content, None)
if manager is None:
raise errors.NotSubscribableError()
@@ -165,8 +182,7 @@
# Check and confirm cancellation
# NOTE: no doc string, so, not *publishable* TTW
#
- content = get_content_from_id(content_id)
- assert content is not None, u'Invalid content'
+ content = get_subscribable_content(content_id)
manager = ISubscriptionManager(content, None)
if manager is None:
raise errors.CancellationError()
@@ -278,7 +294,7 @@
"""
grok.context(SubscriptionService)
- label = _(u"Subscriptions Configuration")
+ label = _(u"Subscriptions configuration")
description = _(u"Enable or disable the possiblity to let users "
u"subscribe to content. If they do, they will receive "
u"an email notification when the content is modified "