本文整理汇总了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)
示例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)
示例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)