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


Python Subscription.find_by_sid_and_distributor方法代码示例

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


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

示例1: _get_preferred_format

# 需要导入模块: from announcer.model import Subscription [as 别名]
# 或者: from announcer.model.Subscription import find_by_sid_and_distributor [as 别名]
 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,代码行数:16,代码来源:mail.py

示例2: render_preference_panel

# 需要导入模块: from announcer.model import Subscription [as 别名]
# 或者: from announcer.model.Subscription import find_by_sid_and_distributor [as 别名]
    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,代码行数:68,代码来源:pref.py


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