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


Python Subscription.get_by_email方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get_by_email [as 别名]
    def post(self):
        """Notify subscribers that a service changed status."""

        address = self.request.get('address')
        service = Service.get(self.request.get('service'))
        oldstatus = Status.get(self.request.get('oldstatus'))
        number = self.request.get('number')

        logging.info("Service: %s" % service)
        logging.info("Service name: %s" % service.name)

        msg = "%s changed state from %s to %s (%s)" % (
                service.name, oldstatus.name,
                service.current_event().status.name,
                service.current_event().message)

        user = Subscription.get_by_email(address)
        if user.status == "available" or not number:
        	status_code = xmpp.send_message(address, msg)
    		chat_message_sent = (status_code == xmpp.NO_ERROR)
		logging.info("Notified: %s\nmessage: %s code: %d" % (address, msg, status_code))
        elif user.status == "unavailable" and number:
		sms = smsgw(to = number, msg = msg)
		sms.send()
		logging.info("Offline SMS: %s\nmessage: %s" % (number, msg))
开发者ID:feczo,项目名称:splashmon,代码行数:27,代码来源:xmpp.py

示例2: txn

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get_by_email [as 别名]
 def txn():
     user = Subscription.get_by_email(from_jid)
     if user:
         user.is_friend = is_friend
         return user.put()
     else:
         return Subscription(key_name=hashlib.sha1(from_jid).hexdigest(),
                           address=from_jid, is_friend=is_friend).put()
开发者ID:feczo,项目名称:splashmon,代码行数:10,代码来源:xmpp.py

示例3: get

# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get_by_email [as 别名]
    def get(self):
        if users.get_current_user() is None:
            self.redirect(users.create_login_url(         self.request.uri))
            return 
           
        user_address = users.get_current_user().email()
        user = Subscription.get_by_email(user_address)
	if user.address in settings.XMPP_FILTER:
            if user.status == "available":
                xmpp.send_message(user_address, "test msg")
                self.response.out.write("A message sent.")
            elif user.status == "unavailable":
                self.response.out.write("The user is offline.")
	    else:
		self.response.out.write("unkown status: %" % user.status)
        else:
            xmpp.send_invite(user_address)
            self.response.out.write("An invitation sent.")
开发者ID:feczo,项目名称:splashmon,代码行数:20,代码来源:xmpp.py


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