当前位置: 首页>>代码示例>>Python>>正文


Python SpeakerForm.all_fields方法代码示例

本文整理汇总了Python中models.SpeakerForm.all_fields方法的典型用法代码示例。如果您正苦于以下问题:Python SpeakerForm.all_fields方法的具体用法?Python SpeakerForm.all_fields怎么用?Python SpeakerForm.all_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.SpeakerForm的用法示例。


在下文中一共展示了SpeakerForm.all_fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getFeaturedSpeaker

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:jlcjensen,项目名称:classworkp4-udacity,代码行数:33,代码来源:conference.py

示例2: getFeaturedSpeaker

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:evelthon,项目名称:udacity-full-stack-nanodegree,代码行数:27,代码来源:conference.py

示例3: getFeaturedSpeaker

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:davidojedalopez,项目名称:conference-organization-app,代码行数:31,代码来源:conference.py

示例4: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:whiskeyromeo,项目名称:Conference,代码行数:9,代码来源:conference.py

示例5: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:erooma,项目名称:Conference-Application,代码行数:9,代码来源:conference.py

示例6: getFeaturedSpeaker

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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     
开发者ID:Jawadhadi1,项目名称:Conference-Central,代码行数:29,代码来源:conference.py

示例7: getFeaturedSpeaker

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:AkiraTreize,项目名称:udacity-full-stack,代码行数:34,代码来源:conference.py

示例8: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:Nero5023,项目名称:ConferenceCentral,代码行数:10,代码来源:conference.py

示例9: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:clho40,项目名称:p4---Conference,代码行数:10,代码来源:conference.py

示例10: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:cpwhidden,项目名称:Conference-Central,代码行数:12,代码来源:conference.py

示例11: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:sikegame,项目名称:udacity-p4,代码行数:12,代码来源:conference.py

示例12: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [as 别名]
 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,代码行数:12,代码来源:conference.py

示例13: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:NadiiaLukianenko,项目名称:ud858,代码行数:12,代码来源:conference.py

示例14: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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))
         elif field.name == "websafeKey":
             setattr(sf, field.name, speaker.key.urlsafe())
     sf.check_initialized()
     return sf
开发者ID:gravic07,项目名称:Conference_Central,代码行数:12,代码来源:conference.py

示例15: _copySpeakerToForm

# 需要导入模块: from models import SpeakerForm [as 别名]
# 或者: from models.SpeakerForm import all_fields [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
开发者ID:skibster,项目名称:conference_central,代码行数:12,代码来源:conference.py


注:本文中的models.SpeakerForm.all_fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。