本文整理汇总了Python中app.models.Event.track方法的典型用法代码示例。如果您正苦于以下问题:Python Event.track方法的具体用法?Python Event.track怎么用?Python Event.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Event
的用法示例。
在下文中一共展示了Event.track方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Event
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import track [as 别名]
csvreader = csv.reader(events_file, delimiter='|', quotechar='"')
first_row = True
for row in csvreader:
if first_row:
# Skip the header line.
first_row = False
continue
if row[2] in tuxtrax_tracks:
track_name = tuxtrax_tracks[row[2]]
else:
# There is no corresponding track in CREM at this time.
continue
event = Event()
event.title = row[0]
event.description = unicode(row[1], 'utf8')
event.track = db.session.query(Track).\
filter(Track.name == track_name).first()
event.duration = int(row[3])
event.failityRequest = row[4]
event.convention = convention
# Assign a random timeslot.
timeslot_index = random.randint(0, timeslot_count-1)
timeslot = Timeslot.query.filter_by(timeslot_index=timeslot_index).first()
event.timeslots.append(timeslot)
db.session.add(event)
events_file.close()
# Commit the test data to the database.
db.session.commit()