Looks good. Took me a while before I realised that it's mostly moved
code. Because of that, this is landable as-is, though my comments
below still apply.
[1]
+ if referer and referer not in ('localhost', self.request.getURL()):
Implicit booleanism. You could express this in another way:
if referer in (None, '', 'localhost', self.request.getURL()): next_url = canonical_url(self.context)
else: next_url = referer
[2]
+ persons_for_user = {}
+ person_count = 0
+ bug = self.context.bug
+ for person in bug.getSubscribersForPerson(self.user):
+ if person.id not in persons_for_user:
+ persons_for_user[person.id] = person
+ person_count += 1
+
+ self._subscriber_count_for_current_user = person_count
+ return persons_for_user.values()
I think that person_count is equivalent to len(persons_for_user).
Having said that, _subscriber_count_for_current_user doesn't appear to
be used anywhere.
Also, based on how it's used, _subscribers_for_current_user could be
simplified to:
@cachedproperty
def _subscribers_for_current_user(self):
"""Return a dict of the subscribers for the current user."""
return set(bug.getSubscribersForPerson(self.user))
[3]
+ 'Unsubscribe <a href="%s">%s</a> from this bug' % (
+ canonical_url(person),
The canonical_url(person) may need to be cgi.escape()d too.
[4]
+ def _isSubscriptionRequest(self):
+ """Return True if the form contains subscribe/unsubscribe input."""
+ return (
+ self.user and
+ self.request.method == 'POST' and
+ 'cancel' not in self.request.form and
+ self.widgets['subscription'].hasValidInput())
Could this be replaced by referring to
self.subscribe_action.submitted()?
Actually, it doesn't seem to be used anymore.
Okay, I'll stop going through this stuff so finely as I now see that
it's mostly moved code.
Looks good. Took me a while before I realised that it's mostly moved
code. Because of that, this is landable as-is, though my comments
below still apply.
[1]
+ if referer and referer not in ('localhost', self.request. getURL( )):
Implicit booleanism. You could express this in another way:
if referer in (None, '', 'localhost', self.request. getURL( )):
next_ url = canonical_ url(self. context)
next_ url = referer
else:
[2]
+ persons_for_user = {} ersForPerson( self.user) : for_user[ person. id] = person r_count_ for_current_ user = person_count for_user. values( )
+ person_count = 0
+ bug = self.context.bug
+ for person in bug.getSubscrib
+ if person.id not in persons_for_user:
+ persons_
+ person_count += 1
+
+ self._subscribe
+ return persons_
I think that person_count is equivalent to len(persons_ for_user) .
Having said that, _subscriber_ count_for_ current_ user doesn't appear to
be used anywhere.
Also, based on how it's used, _subscribers_ for_current_ user could be
simplified to:
@cachedproperty for_current_ user(self) : getSubscribersF orPerson( self.user) )
def _subscribers_
"""Return a dict of the subscribers for the current user."""
return set(bug.
[3]
+ 'Unsubscribe <a href="%s">%s</a> from this bug' % ( url(person) ,
+ canonical_
The canonical_ url(person) may need to be cgi.escape()d too.
[4]
+ def _isSubscription Request( self): unsubscribe input.""" 'subscription' ].hasValidInput ())
+ """Return True if the form contains subscribe/
+ return (
+ self.user and
+ self.request.method == 'POST' and
+ 'cancel' not in self.request.form and
+ self.widgets[
Could this be replaced by referring to action. submitted( )?
self.subscribe_
Actually, it doesn't seem to be used anymore.
Okay, I'll stop going through this stuff so finely as I now see that
it's mostly moved code.