本文整理汇总了Python中models.SpeakerForm.check_initialized方法的典型用法代码示例。如果您正苦于以下问题:Python SpeakerForm.check_initialized方法的具体用法?Python SpeakerForm.check_initialized怎么用?Python SpeakerForm.check_initialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.SpeakerForm
的用法示例。
在下文中一共展示了SpeakerForm.check_initialized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFeaturedSpeaker
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def getFeaturedSpeaker(self, request):
"""Returns the sessions of the featured speaker"""
data = memcache.get("featured_speaker")
from pprint import pprint
pprint(data)
sessions = []
sessionNames = []
speaker = None
if data and data.has_key("speaker") and data.has_key("sessionNames"):
speaker = data["speaker"]
sessionNames = data["sessionNames"]
else:
upcoming_session = (
Session.query(Session.date >= datetime.now()).order(Session.date, Session.startTime).get()
)
if upcoming_session:
speaker = upcoming_session.speaker
sessions = Session.query(Session.speaker == speaker)
sessionNames = [session.name for session in sessions]
# create speaker form
sf = SpeakerForm()
for field in sf.all_fields():
if field.name == "sessionNames":
setattr(sf, field.name, sessionNames)
elif field.name == "speaker":
setattr(sf, field.name, speaker)
sf.check_initialized()
return sf
示例2: getFeaturedSpeaker
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def getFeaturedSpeaker(self,request):
""" Returns a featured speaker and his/her sessions """
sessions = []
sessionNames = []
speaker = None
# look for data in memcache
memcache_data = memcache.get(MEMCACHE_SPEAKER_KEY)
if memcache_data:
speaker = memcache_data['speaker']
sessionNames = memcache_data['sessionNames']
else:
speaker = sessionNames = None
sf = SpeakerForm()
for field in sf.all_fields():
if field.name == 'speaker':
setattr(sf, field.name, speaker)
elif field.name == 'sessionNames':
setattr(sf, field.name, sessionNames)
sf.check_initialized()
return sf
示例3: getFeaturedSpeaker
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def getFeaturedSpeaker(self, request):
"""Returns the sessions of the featured speaker"""
# try to get the speaker related data from memcache that was storied earlier
data = memcache.get('featured_speaker')
from pprint import pprint
pprint(data)
sessionNames = []
speaker = None
if data and data.has_key('speaker') and data.has_key('sessionNames'):
speaker = data['speaker']
sessionNames = data['sessionNames']
# if the memcache fails or is found to be empty, then display a message accordingly
else:
raise endpoints.NotFoundException(
'Failed to retrieve data related to the speaker.')
# populate the speaker form appropriately in case the speaker data is sucessfully retrieved
sf = SpeakerForm()
for field in sf.all_fields():
if field.name == 'sessionNames':
setattr(sf, field.name, sessionNames)
elif field.name == 'speaker':
setattr(sf, field.name, speaker)
sf.check_initialized()
return sf
示例4: getFeaturedSpeaker
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def getFeaturedSpeaker(self, request):
"""Returns the sessions of the featured speaker"""
# attempt to get data from memcache
data = memcache.get('featured_speaker')
from pprint import pprint
pprint(data)
sessions = []
sessionNames = []
speaker = None
if data and data.has_key('speaker') and data.has_key('sessionNames'):
speaker = data['speaker']
sessionNames = data['sessionNames']
# if memcache fails or is empty, pull speaker from upcoming session
else:
upcoming_session = Session.query(Session.date >= datetime.now())\
.order(Session.date, Session.startTime).get()
if upcoming_session:
speaker = upcoming_session.speaker
sessions = Session.query(Session.speaker == speaker)
sessionNames = [session.name for session in sessions]
# populate speaker form
sf = SpeakerForm()
for field in sf.all_fields():
if field.name == 'sessionNames':
setattr(sf, field.name, sessionNames)
elif field.name == 'speaker':
setattr(sf, field.name, speaker)
sf.check_initialized()
return sf
示例5: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
sf = SpeakerForm()
for field in sf.all_fields():
if hasattr(speaker, field.name):
setattr(sf, field.name, str(getattr(speaker, field.name)))
sf.check_initialized()
return sf
示例6: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speak):
"""Copy relevant fields from Speaker to SpeakerForm."""
sp = SpeakerForm()
for field in sp.all_fields():
setattr(sp, field.name, getattr(speak, field.name))
sp.check_initialized()
return sp
示例7: getFeaturedSpeaker
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def getFeaturedSpeaker(self, request):
"""Returns the sessions of the featured speaker"""
# try to get data from memcache
data = memcache.get(MEMCACHE_FEATURED_SPEAKER_KEY)
sessions = []
sessionNames = []
speaker = None
if data and data.has_key('speaker') and data.has_key('sessionNames'):
speaker = data['speaker']
sessionNames = data['sessionNames']
# if data is not on memcache, get speaker from upcoming session
else:
nextSession = Session.query(Session.date >= datetime.now()).order(Session.date, Session.startTime).get()
if nextSession:
speaker = nextSession.speaker
sessions = Session.query(Session.speaker == speaker)
sessionNames = [session.name for session in sessions]
# fill speaker form
speaker_form = SpeakerForm()
for field in speaker_form.all_fields():
if field.name == 'sessionNames':
setattr(speaker_form, field.name, sessionNames)
elif field.name == 'speaker':
setattr(speaker_form, field.name, speaker)
speaker_form.check_initialized()
return speaker_form
示例8: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, spkr):
"""Copy relevant fields from Speaker to SpeakerForm."""
sf = SpeakerForm()
setattr(sf, "name", getattr(spkr, "name"))
setattr(sf, "websafeKey", spkr.key.urlsafe())
sf.check_initialized()
return sf
示例9: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
"""Copy relevant fields from Speaker to SpeakerForm."""
sf = SpeakerForm()
for field in sf.all_fields():
if hasattr(speaker, field.name):
setattr(sf, field.name, getattr(speaker, field.name))
sf.check_initialized()
return sf
示例10: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
'''Copy relevant fields from Speaker to SpeakerForm'''
speaker_form = SpeakerForm()
for field in speaker_form.all_fields():
if hasattr(speaker, field.name):
setattr(speaker_form, field.name, getattr(speaker, field.name))
speaker_form.check_initialized()
return speaker_form
示例11: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speak):
"""Copy relevant fields from Speaker to SpeakerForm."""
sp = SpeakerForm()
for field in sp.all_fields():
if hasattr(speak, field.name):
setattr(sp, field.name, getattr(speak, field.name))
elif field.name == "speakerWebSafeKey":
setattr(sp, field.name, speak.key.urlsafe())
sp.check_initialized()
return sp
示例12: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
"""Check for speaker info, return speakerForm with speaker information."""
sf = SpeakerForm()
for field in sf.all_fields():
if hasattr(speaker, field.name):
setattr(sf, field.name, getattr(speaker, field.name))
elif field.name == 'websafeKey':
setattr(sf, field.name, speaker.key.urlsafe())
sf.check_initialized()
return sf
示例13: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
# Get empty SessionForm
sf = SpeakerForm()
# Copy fields from Session to SessionForm
for field in sf.all_fields():
if hasattr(speaker, field.name):
setattr(sf, field.name, getattr(speaker, field.name))
sf.check_initialized()
return sf
示例14: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
sf = SpeakerForm()
for field in sf.all_fields():
print "Field %s" % field.name
if hasattr(speaker, field.name):
setattr(sf, field.name, str(getattr(speaker, field.name)))
elif field.name == 'websafeKey':
setattr(sf, field.name, speaker.key.urlsafe())
sf.check_initialized()
return sf
示例15: _copySpeakerToForm
# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import check_initialized [as 别名]
def _copySpeakerToForm(self, speaker):
"""Copy relevant fields from Speaker to SpeakerForm."""
form = SpeakerForm()
if speaker is not None:
setattr(form, 'websafeKey', speaker.key.urlsafe())
for field in form.all_fields():
if hasattr(speaker, field.name):
setattr(form, field.name, getattr(speaker, field.name))
form.check_initialized()
return form