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


Python Notification.get_history_by_target方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import get_history_by_target [as 别名]
 def get(self):
     try:
         method, encoded = self.request.headers['AUTHORIZATION'].split()
         if method.lower() == 'basic':
             username, password = base64.b64decode(encoded).split(':')
             account = Account.all().filter('api_key =', username).get()
             if account:
                 notifications = Notification.get_history_by_target(account).fetch(20)
                 self.response.headers['Content-Type'] = 'application/json'
                 def to_json(notice):
                     o = notice.to_dict()
                     o['created'] = notice.created.strftime('%a %b %d %H:%M:%S +0000 %Y')
                     o['source_icon'] = notice.source.source_or_default_icon()
                     return simplejson.dumps(o)
                 self.response.out.write("[%s]" % ', '.join([to_json(n) for n in notifications]))
             else:
                 raise KeyError()
     except KeyError:
         self.response.headers['WWW-Authenticate'] = 'Basic realm="%s"' % 'Notify.io'
         self.error(401)
开发者ID:DFectuoso,项目名称:notify-io,代码行数:22,代码来源:api.py

示例2: get

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import get_history_by_target [as 别名]
    def get(self):
        try:
            method, encoded = self.request.headers["AUTHORIZATION"].split()
            if method.lower() == "basic":
                username, password = base64.b64decode(encoded).split(":")
                account = Account.all().filter("api_key =", username).get()
                if account:
                    notifications = Notification.get_history_by_target(account).fetch(20)
                    self.response.headers["Content-Type"] = "application/json"

                    def to_json(notice):
                        o = notice.to_dict()
                        o["created"] = notice.created.strftime("%a %b %d %H:%M:%S +0000 %Y")
                        o["source_icon"] = notice.source.source_or_default_icon()
                        return simplejson.dumps(o)

                    self.response.out.write("[%s]" % ", ".join([to_json(n) for n in notifications]))
                else:
                    raise KeyError()
        except KeyError:
            self.response.headers["WWW-Authenticate"] = 'Basic realm="%s"' % "Notify.io"
            self.error(401)
开发者ID:Mondego,项目名称:pyreco,代码行数:24,代码来源:allPythonContent.py

示例3: render

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import get_history_by_target [as 别名]
 def render(self, template_path, locals):
     locals["pending_channels"] = Channel.get_all_by_target(self.account).filter("status =", "pending").fetch(10)
     locals["recent_notifications"] = Notification.get_history_by_target(self.account).fetch(3)
     super(DashboardHandler, self).render(template_path, locals)
开发者ID:Mondego,项目名称:pyreco,代码行数:6,代码来源:allPythonContent.py


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