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