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


Python Service.get_by_key_name方法代码示例

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


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

示例1: GetService

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get_by_key_name [as 别名]
def GetService(id):
    service = memcache.get(u"service-%s" % id)
    if service is None:
        service = Service.get_by_key_name(u"<%s>" % id)
        if not service:
            return False
        memcache.set(u"service-%s" % id, service)
    return service.active and service
开发者ID:andris9,项目名称:VoteSMS,代码行数:10,代码来源:main.py

示例2: CheckService

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get_by_key_name [as 别名]
def CheckService(service_data, country_data, user):
    service = memcache.get(u"service-%s" % service_data["id"])
    if service and service.user is not user:
        return False
    if service is None:
        service = Service.get_by_key_name(u"<%s>" % service_data["id"])
        if not service:
            pointer_to_service = {"service": None}
            def tnx(service_data, country_data, user):
                service = Service(key_name = u"<%s>" % service_data["id"])
                service.id = service_data["id"]
                service.user = user
                service.countries = json.dumps(country_data)
                service.put()
                pointer_to_service["service"] = service
            try:
                db.run_in_transaction(tnx, service_data = service_data,
                                  country_data = country_data, user=user)
                memcache.set(u"service-%s" % service_data["id"], service)
                return pointer_to_service["service"]
            except db.TransactionFailedError, e:
                return False
        memcache.set(u"service-%s" % service_data["id"], service)
        return service
开发者ID:andris9,项目名称:VoteSMS,代码行数:26,代码来源:main.py

示例3: tnx

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get_by_key_name [as 别名]
        def tnx():
            
            service = Service.get_by_key_name(u"<%s>" % self.request.get("service_id"))
            if not service:
                error["message"] = _("Service not found")
                return

            service.messages += 1
            memcache.set(u"service-%s" % self.request.get("service_id"), service)
            
            message = Message(key_name = u"<%s>" % self.request.get("message_id"), parent = service)
            message.service   = service
            message.message_id= self.request.get("message_id")
            message.message   = self.request.get("message").strip()
            message.sender    = self.request.get("sender")
            message.country   = self.request.get("country")
            message.price     = int(float(self.request.get("price").strip())*100)
            message.currency  = self.request.get("currency")
            message.keyword   = self.request.get("keyword")
            message.shortcode = self.request.get("shortcode")
            message.operator  = self.request.get("operator")
            message.test      = self.request.get("test") == "true"
            
            db.put([message, service])
开发者ID:andris9,项目名称:VoteSMS,代码行数:26,代码来源:main.py

示例4: get

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get_by_key_name [as 别名]
 def get(self, category, service):
     svc = Service.get_by_key_name(service)
     self.response.out.write(simplejson.dumps(svc))
开发者ID:e911miri,项目名称:adroid,代码行数:5,代码来源:api.py


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