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


Python Session.time方法代码示例

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


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

示例1: createSession

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import time [as 别名]
    def createSession(self, request):
        """ Creates Session from given SESSION_POST_REQUEST_FOR_CONFERENCE and returns a SessionForm."""
        # (SessionForm, websafeConferenceKey) -- open only to the organizer of the conference
        profile = self._getProfileFromUser()
        conf = ndb.Key(urlsafe=request.websafeConferenceKey).get()
        if not conf:
            raise endpoints.NotFoundException(
                'No conference found with key: %s' % request.websafeConferenceKey)
        if conf.key.parent().get() != profile:
            raise endpoints.UnauthorizedException('Session creation is open only to the organizer of the conference!')

        # copy SESSION_POST_REQUEST_FOR_CONFERENCE/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}
        session = Session(name=data['name'],parent=conf.key)

        # convert dates from strings to Date objects; set month based on start_date
        if data['dateTime']:
            session.date = data['dateTime'].date()
            session.time = data['dateTime'].time()
        if data['highlights']:
            session.highlights = data['highlights']
        if data['typeOfSession']:
            session.typeOfSession = data['typeOfSession']
        if data['duration']:
            session.duration = data['duration']
        if data['speakers']:
            session.speakers = data['speakers']

        session.put()
        
        if data['speakers']:
            session.speakers = data['speakers']
            logging.debug("Creating session with speakers, adding task to taskqueue.", str(session))
            taskqueue.add(url='/tasks/add_featured_speaker', params={'sessionKeyUrlSafe': session.key.urlsafe()})
        return self._copySessionToForm(session)
开发者ID:harymitchell,项目名称:udacityConferenceApp,代码行数:37,代码来源:conference.py


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