products/CPSSubscriptions

changeset 1056:3ac6cd0a5b23 CPS-3.5

#2049: better logging and clarity
author Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
date Tue, 27 Sep 2011 15:00:22 +0200
parents f144ec2238ec
children 387470868ff8
files SubscriptionsTool.py
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/SubscriptionsTool.py
     1.2 +++ b/SubscriptionsTool.py
     1.3 @@ -934,18 +934,16 @@
     1.4  
     1.5          for subscription in subscriptions:
     1.6              if subscription.isInterestedInEvent(event_type, object, infos):
     1.7 -                for pt_recipient_rule in subscription.getRecipientsRules():
     1.8 -                    pt_recipients = pt_recipient_rule.getRecipients(event_type,
     1.9 -                                                                    object,
    1.10 -                                                                    infos)
    1.11 -                    if isinstance(pt_recipients, DictType):
    1.12 -                        for pt_recipient in pt_recipients.keys():
    1.13 -                            recipients[pt_recipient] = pt_recipients[
    1.14 -                                pt_recipient]
    1.15 -                    else:
    1.16 -                        logger.debug("ComputeRecipientsRules ERROR: "
    1.17 -                                     "You should provide a dictionnary %s"
    1.18 -                                     % pt_recipient_rule.absolute_url())
    1.19 +                for rule in subscription.getRecipientsRules():
    1.20 +                    rrecs = rule.getRecipients(event_type, object, infos)
    1.21 +                    if not isinstance(rrecs, dict):
    1.22 +                        logger.error("getRecipients of %r did not return a "
    1.23 +                                     "dict. Skipping.", rule)
    1.24 +                        continue
    1.25 +                    elif rrecs:
    1.26 +                        logger.debug("rule %r recipients=%r", rule, rrecs)
    1.27 +                    recipients.update(rrecs)
    1.28 +
    1.29          return recipients
    1.30  
    1.31      #############################################################