本文整理汇总了Python中models.SpeakerForm类的典型用法代码示例。如果您正苦于以下问题:Python SpeakerForm类的具体用法?Python SpeakerForm怎么用?Python SpeakerForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpeakerForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getFeaturedSpeaker
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
开发者ID:jlcjensen,项目名称:classworkp4-udacity,代码行数:31,代码来源:conference.py
示例2: getFeaturedSpeaker
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
开发者ID:evelthon,项目名称:udacity-full-stack-nanodegree,代码行数:25,代码来源:conference.py
示例3: sample_form
def sample_form(request):
if request.method == 'POST':
sf = None
instance_id = request.GET.get(u'speaker')
if instance_id is not None:
instance = get_object_or_404(Speaker, pk=instance_id)
sf = SpeakerForm(request.POST, instance=instance)
else:
sf = SpeakerForm(request.POST)
if sf.is_valid():
speaker = sf.save()
return http.HttpResponseRedirect(reverse("sampleformok", args=[speaker.pk]))
else:
return render_to_response('test/form.html', {'form': sf}, context_instance=RequestContext(request))
elif request.method == 'GET':
form = None
instance_id = request.GET.get(u'speaker')
if instance_id is not None:
instance = get_object_or_404(Speaker, pk=instance_id)
form = SpeakerForm(instance=instance)
else:
form = SpeakerForm(initial={u'languages': [1, 2], u'group': 1})
return render_to_response('test/form.html', {'form': form}, context_instance=RequestContext(request))
else:
return http.HttpResponseNotAllowed(['GET', 'POST'])
开发者ID:luismasuelli,项目名称:jackfrost,代码行数:25,代码来源:views.py
示例4: getFeaturedSpeaker
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
开发者ID:davidojedalopez,项目名称:conference-organization-app,代码行数:29,代码来源:conference.py
示例5: _copySpeakerToForm
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
开发者ID:erooma,项目名称:Conference-Application,代码行数:7,代码来源:conference.py
示例6: _copySpeakerToForm
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
开发者ID:whiskeyromeo,项目名称:Conference,代码行数:7,代码来源:conference.py
示例7: getFeaturedSpeaker
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
开发者ID:AkiraTreize,项目名称:udacity-full-stack,代码行数:32,代码来源:conference.py
示例8: getFeaturedSpeaker
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
开发者ID:Jawadhadi1,项目名称:Conference-Central,代码行数:27,代码来源:conference.py
示例9: _copySpeakerToForm
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
开发者ID:clho40,项目名称:p4---Conference,代码行数:8,代码来源:conference.py
示例10: _copySpeakerToForm
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
开发者ID:Nero5023,项目名称:ConferenceCentral,代码行数:8,代码来源:conference.py
示例11: _copySpeakerToForm
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
开发者ID:Scienxe,项目名称:udacity-scalable,代码行数:8,代码来源:conference.py
示例12: _copySpeakerToForm
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
开发者ID:skibster,项目名称:conference_central,代码行数:10,代码来源:conference.py
示例13: _copySpeakerToForm
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))
elif field.name == "websafeKey":
setattr(sf, field.name, speaker.key.urlsafe())
sf.check_initialized()
return sf
开发者ID:gravic07,项目名称:Conference_Central,代码行数:10,代码来源:conference.py
示例14: _copySpeakerToForm
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
开发者ID:sikegame,项目名称:udacity-p4,代码行数:10,代码来源:conference.py
示例15: _copySpeakerToForm
def _copySpeakerToForm(self, speaker):
"""Copy speaker to form"""
sp = SpeakerForm()
for field in sp.all_fields():
if hasattr(speaker, field.name):
setattr(sp, field.name, getattr(speaker, field.name))
elif field.name == "websafeKey":
setattr(sp, field.name, speaker.key.urlsafe())
sp.check_initialized()
return sp
开发者ID:xiangormirko,项目名称:conference_app_project_4,代码行数:10,代码来源:conference.py
示例16: _copySpeakerToForm
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
开发者ID:NadiiaLukianenko,项目名称:ud858,代码行数:10,代码来源:conference.py
示例17: _copySpeakerToForm
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
开发者ID:cpwhidden,项目名称:Conference-Central,代码行数:10,代码来源:conference.py
示例18: _copySpeakerToForm
def _copySpeakerToForm(self, speaker):
sf = SpeakerForm()
for field in sf.all_fields():
if hasattr(speaker, field.name):
# convert Date to date string; just copy others
setattr(sf, field.name, getattr(speaker, field.name))
elif field.name == "websafeKey":
setattr(sf, field.name, speaker.key.urlsafe())
sf.check_initialized()
return sf
开发者ID:LeKristapino,项目名称:udacity_project_4,代码行数:11,代码来源:conference.py
示例19: getFeaturedSpeaker
def getFeaturedSpeaker(self, request):
"""Returns the sessions of the featured speaker"""
# attempt to get data from memcache
data = memcache.get(MEMCACHE_FEATURED_SPEAKER_KEY)
# copy relevant fields to SpeakerForm
sf = SpeakerForm()
for field in sf.all_fields():
if data and data[field.name]:
setattr(sf, field.name, str(data[field.name]))
sf.check_initialized()
return sf
开发者ID:DuCalixte,项目名称:ConferenceCentral,代码行数:11,代码来源:conference.py
示例20: _copySpeakerToForm
def _copySpeakerToForm(self, speaker):
"""Copy relevant fields from Speaker to SpeakerForm."""
sf = SpeakerForm()
for field in sf.all_fields():
# retrieve speaker ID and display on SpeakerForm
if field.name == 'speakerId':
sf.speakerId = speaker.key.integer_id()
# copy other fields
elif hasattr(speaker, field.name):
setattr(sf, field.name, getattr(speaker, field.name))
sf.check_initialized()
return sf
开发者ID:wiseleywu,项目名称:Conference-Central-API,代码行数:12,代码来源:conference.py
注:本文中的models.SpeakerForm类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论