本文整理匯總了Python中models.Channel.send_activation_email方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.send_activation_email方法的具體用法?Python Channel.send_activation_email怎麽用?Python Channel.send_activation_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Channel
的用法示例。
在下文中一共展示了Channel.send_activation_email方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import send_activation_email [as 別名]
def post(self, hash):
hash = hash.lower()
target = Account.all().filter("hash =", hash).get()
if not target:
target = Account.all().filter("hashes =", hash).get()
source = Account.all().filter("api_key =", self.request.get("api_key")).get()
channel = Channel.all().filter("target =", target).filter("source =", source).get()
approval_notice = None
if not channel and source and target:
channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
channel.put()
approval_notice = channel.get_approval_notice()
channel.send_activation_email()
if channel:
notice = Notification(channel=channel, text=strip_tags(self.request.get("text")), icon=source.source_icon)
for arg in ["title", "link", "icon", "sticky", "tags"]:
value = strip_tags(self.request.get(arg, None))
if value:
setattr(notice, arg, value)
notice.put()
# Increment the counter on the channel to represent number of notices sent
channel.count += 1
channel.put()
if channel.status == "enabled":
notice.dispatch()
self.response.out.write("OK\n")
elif channel.status == "pending":
self.response.set_status(202)
if approval_notice:
approval_notice.dispatch()
self.response.out.write("OK\n")
else:
self.response.out.write("202 Pending approval")
elif channel.status == "disabled":
self.response.set_status(202)
self.response.out.write("202 Accepted but disabled")
else:
self.error(404)
self.response.out.write("404 Target or source not found")
示例2: post
# 需要導入模塊: from models import Channel [as 別名]
# 或者: from models.Channel import send_activation_email [as 別名]
def post(self):
hash = self.request.path.split('/')[-1]
target = Account.all().filter('hash =', hash).get()
if not target:
target = Account.all().filter('hashes =', hash).get()
source = Account.all().filter('api_key =', self.request.get('api_key')).get()
channel = Channel.all().filter('target =', target).filter('source =', source).get()
approval_notice = None
if not channel and source and target:
channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
channel.put()
approval_notice = channel.get_approval_notice()
channel.send_activation_email()
if channel:
notice = Notification(channel=channel, text=strip_tags(self.request.get('text')), icon=source.source_icon)
for arg in ['title', 'link', 'icon', 'sticky', 'tags']:
value = strip_tags(self.request.get(arg, None))
if value:
setattr(notice, arg, value)
notice.put()
# Increment the counter on the channel to represent number of notices sent
channel.count += 1
channel.put()
if channel.status == 'enabled':
self.response.out.write(notice.dispatch())
elif channel.status == 'pending':
self.response.set_status(202)
if approval_notice:
self.response.out.write(":".join([channel.outlet.hash, approval_notice.to_json()]))
else:
self.response.out.write("202 Pending approval")
elif channel.status == 'disabled':
self.response.set_status(202)
self.response.out.write("202 Accepted but disabled")
else:
self.error(404)
self.response.out.write("404 Target or source not found")