当前位置: 首页>>代码示例>>Python>>正文


Python model.Subscription类代码示例

本文整理汇总了Python中announcer.model.Subscription的典型用法代码示例。如果您正苦于以下问题:Python Subscription类的具体用法?Python Subscription怎么用?Python Subscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Subscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_rule

 def _add_rule(self, arg, req):
     rule = Subscription(self.env)
     rule['sid'] = req.session.sid
     rule['authenticated'] = req.session.authenticated and 1 or 0
     rule['distributor'] = arg
     rule['format'] = req.args.get('format-%s'%arg, '')
     rule['adverb'] = req.args['new-adverb-%s'%arg]
     rule['class'] = req.args['new-rule-%s'%arg]
     Subscription.add(self.env, rule)
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:9,代码来源:pref.py

示例2: test_init

 def test_init(self):
     # Examine properties of the initialized objekt.
     fields = ('id', 'sid', 'authenticated', 'distributor', 'format',
               'priority', 'adverb', 'class')
     sub = Subscription(self.env)
     for field in fields:
         self.assertEqual(sub[field], None)
     # Check basic class method for subscription presentation too.
     sub = self.sub
     self.assertEqual(sub.subscription_tuple(),
                          (sub['class'], sub['distributor'], sub['sid'],
                           sub['authenticated'], None, sub['format'],
                           sub['priority'], sub['adverb']))
开发者ID:lkraav,项目名称:trachacks,代码行数:13,代码来源:model.py

示例3: matches

    def matches(self, event):
        if event.realm != 'ticket':
            return
        if event.category not in ('created', 'changed', 'attachment added'):
            return

        klass = self.__class__.__name__
        cc = event.target['cc'] or ''
        sids = set()
        for chunk in re.split('\s|,', cc):
            chunk = chunk.strip()

            if not chunk or chunk.startswith('@'):
                continue

            if re.match(r'^[^@][email protected]+', chunk):
                sid, auth, addr = None, 0, chunk
            else:
                sid, auth, addr = chunk, 1, None

            # Default subscription
            for s in self.default_subscriptions():
                yield (s[0], s[1], sid, auth, addr, None, s[2], s[3])
            if sid:
                sids.add((sid, auth))

        for s in Subscription.find_by_sids_and_class(self.env, sids, klass):
            yield s.subscription_tuple()
开发者ID:aroth-arsoft,项目名称:trac-announcer,代码行数:28,代码来源:subscribers.py

示例4: matches

    def matches(self, event):
        if event.realm != "ticket":
            return
        if event.category not in ('created', 'changed', 'attachment added'):
            return

        ticket = event.target
        if not ticket['reporter'] or ticket['reporter'] == 'anonymous':
            return

        if re.match(r'^[^@][email protected]+', ticket['reporter']):
            sid, auth, addr = None, 0, ticket['reporter']
        else:
            sid, auth, addr = ticket['reporter'], 1, None

        # Default subscription
        for s in self.default_subscriptions():
            yield (s[0], s[1], sid, auth, addr, None,
                    s[2], s[3])

        if sid:
            klass = self.__class__.__name__
            for s in Subscription.find_by_sids_and_class(self.env,
                    ((sid,auth),), klass):
                yield s.subscription_tuple()
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:25,代码来源:subscribers.py

示例5: matches

    def matches(self, event):
        if event.realm != "ticket":
            return
        if event.category not in ("changed", "created", "attachment added"):
            return

        klass = self.__class__.__name__
        ticket = event.target
        sids = set()

        for field in self.custom_cc_fields:
            subs = ticket[field] or ""
            for chunk in re.split("\s|,", subs):
                chunk = chunk.strip()
                if not chunk or chunk.startswith("@"):
                    continue

                if re.match(r"^[^@][email protected]+", chunk):
                    sid, auth, addr = None, None, chunk
                else:
                    sid, auth, addr = chunk, True, None

                # Default subscription
                for s in self.default_subscriptions():
                    yield (s[0], s[1], sid, auth, addr, None, s[3], s[4])
                if sid:
                    sids.add((sid, auth))

        for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
            yield i.subscription_tuple()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:subscribers.py

示例6: matches

    def matches(self, event):
        if event.realm != 'ticket':
            return
        if event.category not in ('created', 'changed', 'attachment added'):
            return
        ticket = event.target

        try:
            component = model.Component(self.env, ticket['component'])
            if not component.owner:
                return

            if re.match(r'^[^@][email protected]+', component.owner):
                sid, auth, addr = None, 0, component.owner
            else:
                sid, auth, addr = component.owner, 1, None

            # Default subscription
            for s in self.default_subscriptions():
                yield s[0], s[1], sid, auth, addr, None, s[2], s[3]

            if sid:
                klass = self.__class__.__name__
                for s in Subscription.find_by_sids_and_class(self.env,
                                                             ((sid, auth),),
                                                             klass):
                    yield s.subscription_tuple()

        except:
            self.log.debug("Component for ticket (%s) not found",
                           ticket['id'])
开发者ID:aroth-arsoft,项目名称:trac-announcer,代码行数:31,代码来源:subscribers.py

示例7: matches

    def matches(self, event):
        if event.realm != 'blog':
            return
        if event.category != 'post created':
            return

        klass = self.__class__.__name__
        for i in Subscription.find_by_class(self.env, klass):
            yield i.subscription_tuple()
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:9,代码来源:announce.py

示例8: matches

    def matches(self, event):
        if event.realm != 'acct_mgr':
            return
        # DEVEL: Need a better plan, because the real issue is a missing
        #   user_* method on AccountManager changes.
        if not event.category in self.categories:
            return

        klass = self.__class__.__name__
        for i in Subscription.find_by_class(self.env, klass):
            yield i.subscription_tuple()
开发者ID:lkraav,项目名称:trachacks,代码行数:11,代码来源:announce.py

示例9: matches

    def matches(self, event):
        if event.realm != 'blog':
            return
        if event.category not in ('post created', 'post changed',
                                  'post deleted', 'comment created',
                                  'comment changed', 'comment deleted'):
            return

        klass = self.__class__.__name__
        for i in Subscription.find_by_class(self.env, klass):
            yield i.subscription_tuple()
开发者ID:aroth-arsoft,项目名称:trac-announcer,代码行数:11,代码来源:announce.py

示例10: matches

    def matches(self, event):
        if event.realm != "ticket":
            return
        if event.category not in ('created', 'changed', 'attachment added'):
            return
        ticket = event.target

        if (not ticket['owner'] or ticket['owner'] == 'anonymous') and \
                not 'owner' in event.changes:
            return

        sid = sid_old = None
        if ticket['owner'] and ticket['owner'] != 'anonymous':
            if re.match(r'^[^@][email protected]+', ticket['owner']):
                sid, auth, addr = None, 0, ticket['owner']
            else:
                sid, auth, addr = ticket['owner'], 1, None
        if 'owner' in event.changes:
            previous_owner = event.changes['owner']
            if re.match(r'^[^@][email protected]+', previous_owner):
                sid_old, auth_old, addr_old = None, 0, previous_owner
            else:
                sid_old, auth_old, addr_old = previous_owner, 1, None

        # Default subscription
        for s in self.default_subscriptions():
            if sid:
                yield (s[0], s[1], sid, auth, addr, None, s[2], s[3])
            if sid_old:
                yield (s[0], s[1], sid_old, auth_old, addr_old, None, s[2],
                       s[3])
        if sid:
            klass = self.__class__.__name__
            for s in Subscription.find_by_sids_and_class(self.env,
                    ((sid, auth),), klass):
                yield s.subscription_tuple()
        if sid_old:
            klass = self.__class__.__name__
            for s in Subscription.find_by_sids_and_class(self.env,
                    ((sid_old, auth_old),), klass):
                yield s.subscription_tuple()
开发者ID:lkraav,项目名称:trachacks,代码行数:41,代码来源:subscribers.py

示例11: _get_preferred_format

 def _get_preferred_format(self, realm, sid, authenticated):
     if authenticated is None:
         authenticated = 0
     # Format is unified for all subscriptions of a user.
     result = Subscription.find_by_sid_and_distributor(
         self.env, sid, authenticated, 'email')
     if result:
         chosen = result[0]['format']
         self.log.debug("EmailDistributor determined the preferred format"
                        " for '%s (%s)' is: %s", sid, authenticated and
                        'authenticated' or 'not authenticated', chosen)
         return chosen
     else:
         return self._get_default_format()
开发者ID:aroth-arsoft,项目名称:trac-announcer,代码行数:14,代码来源:mail.py

示例12: _set_format

 def _set_format(self, arg, req):
     Subscription.update_format_by_distributor_and_sid(self.env, arg,
             req.session.sid, req.session.authenticated,
             req.args['format-%s'%arg])
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:4,代码来源:pref.py

示例13: _move_rule

 def _move_rule(self, arg, req):
     (rule_id, new_priority) = arg.split('-')
     if int(new_priority) >= 1:
         Subscription.move(self.env, rule_id, int(new_priority))
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:4,代码来源:pref.py

示例14: _delete_rule

 def _delete_rule(self, arg, req):
     Subscription.delete(self.env, arg)
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:2,代码来源:pref.py

示例15: render_preference_panel

    def render_preference_panel(self, req, panel, path_info=None):
        if req.method == 'POST':
            method_arg = req.args.get('method', '')
            m = re.match('^([^_]+)_(.+)', method_arg)
            if m:
                method, arg = m.groups()
                method_func = self.post_handlers.get(method)
                if method_func:
                    method_func(arg, req)
                else:
                    pass
            else:
                pass
            req.redirect(req.href.prefs('subscriptions'))

        data = {'rules':{}, 'subscribers':[]}

        desc_map = {}

        data['formatters'] = ('text/plain', 'text/html')
        data['selected_format'] = {}
        data['adverbs'] = ('always', 'never')

        for i in self.subscribers:
            if not i.description():
                continue
            if not req.session.authenticated and i.requires_authentication():
                continue
            data['subscribers'].append({
                'class': i.__class__.__name__,
                'description': i.description()
            })
            desc_map[i.__class__.__name__] = i.description()


        for i in self.distributors:
            for j in i.transports():
                data['rules'][j] = []
                for r in Subscription.find_by_sid_and_distributor(self.env,
                        req.session.sid, req.session.authenticated, j):
                    if desc_map.get(r['class']):
                        data['rules'][j].append({
                            'id': r['id'],
                            'adverb': r['adverb'],
                            'description': desc_map[r['class']],
                            'priority': r['priority']
                        })
                        data['selected_format'][j] = r['format']

        data['default_rules'] = {}
        defaults = []
        for i in self.default_subscribers:
            defaults.extend(i.default_subscriptions())

        for r in sorted(defaults, key=itemgetter(2)):
            klass, dist, _, adverb = r
            if not data['default_rules'].get(dist):
                data['default_rules'][dist] = []
            if desc_map.get(klass):
                data['default_rules'][dist].append({
                    'adverb': adverb,
                    'description': desc_map.get(klass)
                })

        add_stylesheet(req, 'announcer/css/announcer_prefs.css')
        return "prefs_announcer_manage_subscriptions.html", dict(data=data)
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:66,代码来源:pref.py


注:本文中的announcer.model.Subscription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。