Пример #1
0
    def filter_subscriptions(self, event, subscriptions):
        action = '%s_VIEW' % event.realm.upper()

        for subscription in subscriptions:
            if event.realm in self.exception_realms:
                yield subscription
                continue

            sid, auth = subscription[1:3]
            # PermissionCache already takes care of sid = None
            if not auth:
                sid = 'anonymous'
            perm = PermissionCache(self.env, sid)
            resource_id = get_target_id(event.target)
            self.log.debug(
                'Checking *_VIEW permission on event for resource %s:%s'
                % (event.realm, resource_id)
            )
            if perm.has_permission(action) and action in perm(event.realm,
                                                              resource_id):
                yield subscription
            else:
                self.log.debug(
                    "Filtering %s because of %s rule" 
                    % (sid, self.__class__.__name__)
                )
Пример #2
0
    def matches(self, event):
        klass = self.__class__.__name__

        attrs = SubscriptionAttribute.find_by_class_realm_and_target(
            self.env, klass, event.realm, get_target_id(event.target))
        sids = set(map(lambda x: (x['sid'], x['authenticated']), attrs))

        for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
            yield i.subscription_tuple()
Пример #3
0
    def matches(self, event):
        klass = self.__class__.__name__

        attrs = SubscriptionAttribute.\
            find_by_class_realm_and_target(self.env, klass, event.realm,
                                           get_target_id(event.target))
        sids = set(map(lambda x: (x['sid'], x['authenticated']), attrs))

        for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
            yield i.subscription_tuple()
Пример #4
0
def uid_encode(projurl, realm, target):
    """
    Unique identifier used to track resources in relation to emails.

    Returns a base32 encode UID string.  projurl included to avoid
    Message-ID collisions.  Returns a base32 encode UID string.
    Set project_url in trac.ini for proper results.
    """
    uid = ','.join((projurl, realm, get_target_id(target)))
    return b32encode(uid.encode('utf8'))
Пример #5
0
def uid_encode(projurl, realm, target):
    """
    Unique identifier used to track resources in relation to emails.

    Returns a base32 encode UID string.  projurl included to avoid
    Message-ID collisions.  Returns a base32 encode UID string.
    Set project_url in trac.ini for proper results.
    """
    uid = ','.join((projurl, realm, get_target_id(target)))
    return b32encode(uid.encode('utf8'))
Пример #6
0
    def filter_subscriptions(self, event, subscriptions):
        action = '%s_VIEW' % event.realm.upper()

        for subscription in subscriptions:
            if event.realm in self.exception_realms:
                yield subscription
                continue

            sid, auth = subscription[1:3]
            # PermissionCache already takes care of sid = None
            if not auth:
                sid = 'anonymous'
            perm = PermissionCache(self.env, sid)
            resource_id = get_target_id(event.target)
            self.log.debug("Checking *_VIEW permission on event for resource "
                           "%s:%s", event.realm, resource_id)
            if action in perm and action in perm(event.realm, resource_id):
                yield subscription
            else:
                self.log.debug("Filtering %s because of %s rule", sid,
                               self.__class__.__name__)
Пример #7
0
 def wiki_page_deleted(self, page):
     klass = self.__class__.__name__
     SubscriptionAttribute.delete_by_class_realm_and_target(
         self.env, klass, 'wiki', get_target_id(page))
Пример #8
0
 def ticket_deleted(self, ticket):
     klass = self.__class__.__name__
     SubscriptionAttribute.delete_by_class_realm_and_target(
         self.env, klass, 'ticket', get_target_id(ticket))
Пример #9
0
 def wiki_page_renamed(self, page, old_name):
     class_ = self.__class__.__name__
     target = get_target_id(page)
     SubscriptionAttribute\
         .change_target(self.env, class_, 'wiki', old_name, target)
Пример #10
0
 def wiki_page_deleted(self, page):
     klass = self.__class__.__name__
     SubscriptionAttribute.\
         delete_by_class_realm_and_target(self.env, klass, 'wiki',
                                          get_target_id(page))
Пример #11
0
 def ticket_deleted(self, ticket):
     klass = self.__class__.__name__
     SubscriptionAttribute.delete_by_class_realm_and_target(
         self.env, klass, 'ticket', get_target_id(ticket))
Пример #12
0
 def wiki_page_renamed(self, page, old_name):
     class_ = self.__class__.__name__
     target = get_target_id(page)
     SubscriptionAttribute\
         .change_target(self.env, class_, 'wiki', old_name, target)