本文整理汇总了Python中models.Event.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_by_key_name方法的具体用法?Python Event.get_by_key_name怎么用?Python Event.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.get_by_key_name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getEventInfo
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def getEventInfo(self, event_key):
"""
Return an Event dict with basic information
"""
memcache_key = "api_event_info_%s" % event_key
event_dict = memcache.get(memcache_key)
if event_dict is None:
event = Event.get_by_key_name(event_key)
if event is not None:
event_dict = dict()
event_dict["key"] = event.key().name()
event_dict["year"] = event.year
event_dict["event_code"] = event.event_short
event_dict["name"] = event.name
event_dict["short_name"] = event.short_name
event_dict["location"] = event.location
event_dict["official"] = event.official
event_dict["facebook_eid"] = event.facebook_eid
if event.start_date:
event_dict["start_date"] = event.start_date.isoformat()
else:
event_dict["start_date"] = None
if event.end_date:
event_dict["end_date"] = event.end_date.isoformat()
else:
event_dict["end_date"] = None
event_dict["teams"] = [a.team.key().name() for a in event.teams]
event_dict["matches"] = [a.key().name() for a in event.match_set]
memcache.set(memcache_key, event_dict, 300)
return event_dict
示例2: getTeamWLT
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def getTeamWLT(self, team_key, event_key):
"""
Given a team_key, and an event_key, find the Win Loss Tie.
"""
event = Event.get_by_key_name(event_key)
matches = event.match_set.filter("team_key_names =", team_key)
return self.getTeamWLTFromMatches(team_key, matches)
示例3: get
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def get(self, event_key):
event = Event.get_by_key_name(event_key)
template_values = {
"event": event
}
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/events/edit.html')
self.response.out.write(template.render(path, template_values))
示例4: get
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def get(self, event_key):
event = Event.get_by_key_name(event_key)
teams = set()
# Add teams from Matches
for m in event.match_set:
for team in m.team_key_names:
teams.add(team)
# Add teams from existing EventTeams
for a in event.teams:
if a.team:
teams.add("frc%s" % a.team.team_number)
eventteams_count = 0
for team in teams:
team_object = Team.get_or_insert(
key_name = team,
team_number = int(team[3:]), #"frc177"->"177"
)
et = EventTeam.get_or_insert(
key_name = event_key + "_" + team,
event = event,
team = team_object,
year = event.year)
# Update if needed
reput = False
if not et.team:
reput = True
et.team = team_object
elif et.team.key().name != team_object.key().name:
reput = True
et.team = team_object
if et.year != event.year:
reput = True
et.year = event.year
if reput:
logging.info("Had to re-put %s" % et.key().name)
et.put()
eventteams_count = eventteams_count + 1
template_values = {
'eventteams_count': eventteams_count,
}
path = os.path.join(os.path.dirname(__file__), '../templates/cron/eventteam_update.html')
self.response.out.write(template.render(path, template_values))
示例5: findOrSpawn
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def findOrSpawn(self, new_event):
""""
Check if an event currently exists in the database based on key_name.
Doesn't put objects.
If it does, update it and give it back.
If it does not, give it back.
"""
query = Event.all()
# First, look for a key_name collision.
event = Event.get_by_key_name(new_event.get_key_name())
if event is not None:
event = self.updateMerge(new_event, event)
return event
# Don't see it, give it back.
return new_event
示例6: get
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def get(self, event_key):
memcache_key = "event_detail_%s" % event_key
html = memcache.get(memcache_key)
if html is None:
event = Event.get_by_key_name(event_key)
matches = MatchHelper.organizeMatches(event.match_set)
teams = TeamHelper.sortTeams([a.team for a in event.teams])
template_values = {
"event": event,
"matches": matches,
"teams": teams,
}
path = os.path.join(os.path.dirname(__file__), '../templates/events/details.html')
html = template.render(path, template_values)
memcache.set(memcache_key, html, 300)
self.response.out.write(html)
示例7: get
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def get(self, event_key):
df = DatafeedTbaVideos()
event = Event.get_by_key_name(event_key)
tbavideos = df.getEventVideosList(event)
new_tbavideos = list()
if len(tbavideos) < 1:
logging.info("No tbavideos found for event " + event.key().name())
else:
for tbavideo in tbavideos:
new_tbavideo = TBAVideoUpdater.findOrSpawn(tbavideo) # findOrSpawn doesn't put() things.
new_tbavideos.append(new_tbavideo)
keys = db.put(new_tbavideos) # Doing a bulk put() is faster than individually.
template_values = {
'tbavideos': new_tbavideos,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/tba_videos_get.html')
self.response.out.write(template.render(path, template_values))
示例8: post
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_key_name [as 别名]
def post(self, match_key):
logging.info(self.request)
alliances_json = self.request.get("alliances_json")
alliances = simplejson.loads(alliances_json)
team_key_names = list()
for alliance in alliances:
team_key_names.extend(alliances[alliance].get('teams', None))
match = Match(
key_name = match_key,
event = Event.get_by_key_name(self.request.get("event_key_name")),
game = self.request.get("game"),
set_number = int(self.request.get("set_number")),
match_number = int(self.request.get("match_number")),
comp_level = self.request.get("comp_level"),
team_key_names = team_key_names,
alliances_json = alliances_json,
#no_auto_update = str(self.request.get("no_auto_update")).lower() == "true", #TODO
)
match = MatchUpdater.createOrUpdate(match)
self.redirect("/admin/match/" + match.get_key_name())