• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Speaker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_by_speaker

    def get_by_speaker(self, request):
        """
        Given a speaker, return all sessions given by this particular speaker,
        across all conferences
        :param request:
        :return:
        """

        if request.name and not request.title:
            speakers = Speaker.query(Speaker.name == request.name)
        elif not request.name and request.title:
            speakers = Speaker.query(Speaker.title == request.title)
        else:
            speakers = Speaker.query(Speaker.name == request.name) \
                .filter(Speaker.title == request.title)

        speakers.fetch()

        all_sessions = []
        if speakers:
            for speaker in speakers:
                sessions = Session.query(
                    Session.speakerKeys == speaker.key).fetch()
                if sessions:
                    all_sessions += sessions

        return SessionForms(items=self.populate_forms(all_sessions))
开发者ID:voutilad,项目名称:udacity-project4,代码行数:27,代码来源:session.py


示例2: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create Speaker object, returning SpeakerForm/request."""
        # Need to be logged in to create a speaker entity
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException("Authorization required")
        user_id = getUserId(user)

        # Speaker name is a required property
        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field required")

        # Copy SpeakerForm/ProtoRPC Message into dictionary
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}
        del data["websafeKey"]

        # Make the logged in user the parent of the Speaker object.
        p_key = ndb.Key(Profile, user_id)
        s_id = Speaker.allocate_ids(size=1, parent=p_key)[0]
        s_key = ndb.Key(Speaker, s_id, parent=p_key)
        data["key"] = s_key

        # Create the Speaker entity in the datastore
        new_speaker = Speaker(**data)
        new_speaker.put()

        return self._copySpeakerToForm(new_speaker)
开发者ID:SteveWooding,项目名称:fullstack-nanodegee-conference,代码行数:27,代码来源:conference.py


示例3: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create Speaker object, returning SpeakerForm."""

        # check for auth'ed and valid user
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # Speaker name must be filled
        if not request.name:
            raise endpoints.BadRequestException("Field 'name' required")

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}

        # allocate new Speaker ID
        s_id = Speaker.allocate_ids(size=1)[0]
        # make Speaker key from ID
        s_key = ndb.Key(Speaker, s_id)
        data['key'] = s_key

        # create Speaker & return SpeakerForm
        speaker = Speaker(**data)
        speaker.put()

        return self._copySpeakerToForm(speaker)
开发者ID:skh,项目名称:skhonference,代码行数:27,代码来源:conference.py


示例4: _getKeyForSpeaker

 def _getKeyForSpeaker(self, request):
     """
     This function gets the key for an existing speaker that has been
     requested.
     """
     if not request.name:
         raise endpoints.BadRequestException("Speaker 'name' field \
             required")
     # creates new key for Speaker
     spkr_key = Speaker().key
     # for all noted speakers, make a query
     notedSpeakersQuery = Speaker.query()
     # lists noted speakers
     notedSpeakers = []
     for ns in notedSpeakersQuery:
         notedSpeakers.append(ns.name)
     # When no speaker is found with a name, a NotFoundException is raised.
     if request.name not in notedSpeakers:
         raise endpoints.NotFoundException(
             'No speaker found with name: %s'
             % request.name)
     # Otherwise, have its key returned.
     else:
         spkr_key = Speaker.query(Speaker.name == request.name).get().key
     return spkr_key
开发者ID:WebDesigner32,项目名称:ConferenceCentralApp,代码行数:25,代码来源:conference.py


示例5: _getSpeakerKey

    def _getSpeakerKey(self, request):
        """ Returns the key for a requested speaker, when he exists."""

        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field \
                required")

        # create a new Speaker.key
        spk_key = Speaker().key
        # query all existing/known speakers
        qryKnownSpeakers = Speaker.query()
        # write the names of the known speakers in a list
        knownSpeakers = []
        for ks in qryKnownSpeakers:
            knownSpeakers.append(ks.name)
        # If speaker doesn't exist, raise an "Not Found"-exception.
        if request.name not in knownSpeakers:
            raise endpoints.NotFoundException(
                'No speaker found with name: %s'
                % request.name)
        # Else return its key.
        # NOTE: For simplification, it is assumed that a name uniquely
        # identifies a speaker.
        else:
            spk_key = Speaker.query(Speaker.name == request.name).get().key
        return spk_key
开发者ID:adarsh0806,项目名称:FSND-P4_Conference-Organization-App,代码行数:26,代码来源:conference.py


示例6: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create Speaker object, 
        returning SpeakerForm/request."""
        # preload necessary data items
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        if not request.name:
            raise endpoints.BadRequestException(
                "Speaker 'name' field required")

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) \
            for field in request.all_fields()}
        del data['websafeKey']

        speaker_id = Speaker.allocate_ids(size=1)[0]
        speaker_key = ndb.Key(Speaker, speaker_id)
        data['key'] = speaker_key

        # create Speaker
        speaker = Speaker(**data)
        speaker.put()

        # return the modified SpeakerForm
        return self._copySpeakerToForm(speaker)
开发者ID:cpwhidden,项目名称:Conference-Central,代码行数:28,代码来源:conference.py


示例7: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create Speaker object, returning SpeakerForm/request."""
        
        user = self._getAuthUser()
        user_id = getUserId(user)

        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field required")

        if not request.email:
            raise endpoints.BadRequestException("Speaker 'email' field required")

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}
        
        # create Speaker key
        sp_id = Speaker.allocate_ids(size=1)[0]
        sp_key = ndb.Key(Speaker, sp_id)
        
        # assign the Speaker key
        data['key'] = sp_key
        
        del data['websafeKey']
        
        # create Speaker
        speaker = Speaker(**data)
        speaker.put()
        
        return self._copySpeakerToForm(speaker)
开发者ID:Crash888,项目名称:FSWDN-P4,代码行数:29,代码来源:conference.py


示例8: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create or update Speaker object, returning SpeakerForm/request."""
        # preload necessary data items
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # name is a required Speaker field
        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field required")

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) \
                for field in request.all_fields()}
        del data['websafeKey']      # websafeKey not a Speaker attribute

        # allocate Speaker id
        s_id = Speaker.allocate_ids(size=1)[0]
        s_key = ndb.Key(Speaker, s_id)
        data['key'] = s_key

        # create Session, send email to organizer confirming
        # creation of Session & return (modified) SessionForm
        speaker = Speaker(**data)
        speaker.put()

        return self._copySpeakerToForm(speaker)
开发者ID:mkmadd,项目名称:ud858,代码行数:28,代码来源:conference.py


示例9: _createSpeakerObject

 def _createSpeakerObject(self, request):
     """Create Speaker Object, returning SessionForm/request."""
     data = {field.name: getattr(request, field.name)
             for field in request.all_fields()}
     del data['speakerId']
     key = Speaker(**data).put()
     return self._copySpeakerToForm(key.get())
开发者ID:wiseleywu,项目名称:Conference-Central-API,代码行数:7,代码来源:conference.py


示例10: createSpeaker

    def createSpeaker(self, request):
        """Create Speaker object, returning SpeakerForm/request."""
        # preload necessary data items
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')

        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field required")
        if not request.mainEmail:
            raise endpoints.BadRequestException("Speaker 'mainEmail' field required")

        sp_key = ndb.Key(Speaker, request.mainEmail)
        speaker = sp_key.get()
        if not speaker:
            speaker = Speaker(
                key = sp_key,
                name = request.name,
                mainEmail = request.mainEmail,
            )
            if request.title:
                speaker.title = request.title
            if request.bio:
                speaker.bio = request.bio
            speaker.put()

        return request
开发者ID:TimHack,项目名称:P4-ConferenceCentral,代码行数:27,代码来源:conference.py


示例11: _createSpeakerObject

    def _createSpeakerObject(self, request):
        user = endpoints.get_current_user()
        # Raise an exception if the user is not logged in
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # Raise an exception if the displayName is not provided
        if not request.displayName:
            raise endpoints.BadRequestException("dislayName field required")

        # Copy SpeakerForm into a dictionary
        data = {field.name: getattr(request, field.name)
                for field in request.all_fields()}
        del data['websafeKey']

        # generate Speaker key
        sp_id = Speaker.allocate_ids(size=1)[0]
        sp_key = ndb.Key(Speaker, sp_id)
        data['key'] = sp_key

        # Create Speaker and save
        sp = Speaker(**data)
        sp.put()

        return self._copySpeakerToForm(sp)
开发者ID:mvkrishna,项目名称:udacity-full-stack,代码行数:26,代码来源:conference.py


示例12: getConferenceSessionsBySpeaker

    def getConferenceSessionsBySpeaker(self, request):
        """Return Conference sessions by Speaker."""
        # make sure user is authed
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        # user_id = getUserId(user)

        sp_lastName = request.lastName
        sp_firstName = request.firstName

        if sp_firstName:
            # find by first and last name
            speaker = Speaker.query(ndb.AND(
                Speaker.lastName == sp_lastName,
                Speaker.firstName == sp_firstName))
        else:
            # find by last name only
            speaker = Speaker.query(Speaker.lastName == sp_lastName)

        speaker_keys = [sp.key for sp in speaker]

        # iterate over each key finding all sessions
        all_sessions = []
        for sp_k in speaker_keys:
            sessions = Session.query(Session.speaker == sp_k)
            for s in sessions:
                all_sessions.append(s)

        # return list of sessions that match each of the speaker_keys
        return SessionForms(
            items=[self._copySessionToForm(sess) for sess in all_sessions]
        )
开发者ID:skibster,项目名称:conference_central,代码行数:33,代码来源:conference.py


示例13: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create or update Speaker object, returning SpeakerForm."""

        if not request.name:
            raise endpoints.BadRequestException(
                "Speaker 'name' field required")
        q = Speaker.query()
        q = q.filter(Speaker.name == request.name)
        if q.count() != 0:
            raise endpoints.BadRequestException(
                "Speaker already excists")

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name)
                for field in request.all_fields()}

        # Create session id from parent COnference Key and
        # a Session key from that id
        s_id = Speaker.allocate_ids(size=1)[0]
        s_key = ndb.Key(Speaker, s_id)
        data['key'] = s_key
        del data['websafeKey']

        # Save session and return a SessionForm to the user
        Speaker(**data).put()
        return self._copySpeakerToForm(s_key.get())
开发者ID:Sean-Holcomb,项目名称:Conference-Organization-App,代码行数:26,代码来源:conference.py


示例14: addSpeaker

 def addSpeaker(self, request):
     """Get profile from user, take field info for all fields, give key and put into datastore"""
     prof=self._getProfileFromUser()
     data={field.name:getattr(request, field.name) for field in request.all_fields()}
     del data['websafeKey']
     speaker=Speaker(**data)
     speaker.put()
     return self._copySpeakerToForm(speaker)
开发者ID:dantintle,项目名称:udacityP4,代码行数:8,代码来源:conference.py


示例15: _createSessionObject

    def _createSessionObject(request, conference):
        """Create or update Session object, returning SessionForm/request."""
        # preload necessary data items

        if not request.name:
            raise endpoints.BadRequestException("Session 'name' field required")

        speaker_wskey = None
        if not request.speakerWSKey:
            if request.speakerName:
                speaker = Speaker.query(Speaker.name == request.speakerName).get()
                if speaker:
                    speaker_wskey = speaker.key.urlsafe()
                else:
                    speaker_id = Speaker.allocate_ids(size=1)[0]
                    speaker_key = ndb.Key(Speaker, speaker_id)
                    speaker_wskey = speaker_key.urlsafe()

                    speaker = Speaker(**{'key': speaker_key,'name': request.speakerName})
                    speaker.put()
            else:
                raise endpoints.BadRequestException("Session speaker required")
        else:
            speaker_wskey = request.speakerWSKey

        # copy SessionForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}
        del data['sessionWSKey']
        del data['speakerWSKey']
        del data['speakerName']
        del data['conferenceWSKey']
        del data['startDateHour']

        print '1:' + str(data.keys())

        # add default values for those missing (both data model & outbound Message)
        for df in SESSION_DEFAULTS:
            if data[df] in (None, []):
                data[df] = SESSION_DEFAULTS[df]
                setattr(request, df, SESSION_DEFAULTS[df])

        # convert dates from strings to Date objects; set month based on start_date
        if data['startDate'] and isinstance(data['startDate'], types.StringType):
            data['startDate'] = datetime.strptime(data['startDate'][:10], "%Y-%m-%d").datetime()

        session_id = Session.allocate_ids(size=1, parent=conference.key)[0]
        session_key = ndb.Key(Session, session_id, parent=conference.key)
        data['key'] = session_key
        data['speakerKey'] = speaker_wskey  

        # create Session, send email to organizer confirming creation of Session & return (modified) SessionForm
        session = Session(**data)
        session.put()

        # taskqueue.add(params={'email': user.email(), 'conferenceInfo': repr(request)}, url='/tasks/send_confirmation_email')

        return session
开发者ID:thiagoh,项目名称:appengine-test,代码行数:57,代码来源:conference.py


示例16: createSpeaker

    def createSpeaker(self, request):
        """Create a speaker."""
        if not request.name:
            raise endpoints.BadRequestException(
                "Speaker 'name' field required")

        speaker = Speaker(name=request.name)
        key = speaker.put().urlsafe()  # for debugging
        print(key)  # for debugging
        return SpeakerForm(name=request.name, websafeKey=key)
开发者ID:Ethan826,项目名称:udacity-conference,代码行数:10,代码来源:conference.py


示例17: _createSpeakerObject

    def _createSpeakerObject(self, data):
        """Create Speaker object, return Speaker key"""
        # allocate new Speaker ID
        speaker_id = Speaker.allocate_ids(size=1)[0]
        # make Speaker key fom ID
        speaker_key = ndb.Key(Speaker, speaker_id)

        # Create Speaker and return Speaker key
        speaker = Speaker(name=data,
                          key=speaker_key)
        speaker.put()
        return speaker_key
开发者ID:supermanrising,项目名称:Conference-Central,代码行数:12,代码来源:conference.py


示例18: _createSpeakerObject

    def _createSpeakerObject(self, request):
        speaker_id = request.mainEmail
        sp_key = ndb.Key(Speaker, speaker_id)

        speaker = Speaker(
                key=sp_key,
                name=request.name,
                mainEmail=request.mainEmail,
                phone=request.phone,
            )
        speaker.put()

        return request
开发者ID:akamuri,项目名称:Conference_Central_App_Project_4,代码行数:13,代码来源:conference.py


示例19: _createSpeakerObject

    def _createSpeakerObject(self, request):
        """Create or update a Speaker object, returning SpeakerForm/request.
        In this version, any user can create a speaker, this allows speakers
        to be reused for different conferences"""
        
        # check for required field
        if not request.name:
            raise endpoints.BadRequestException("Speaker 'name' field required")

        # create Speaker & return SpeakerForm
        speaker = Speaker(name=request.name, organisation=request.organisation)
        speaker.put()
        return self._copySpeakerToForm(speaker)
开发者ID:dimitridjuric,项目名称:scalable-conf,代码行数:13,代码来源:conference.py


示例20: get

    def get(self, id = None):
	request = self.wsgi_request
	response = self.wsgi_response
	c = self.context
	response.headers['content-type'] = 'application/json'

	if id is None:
	    #get all the speakers
	    speakers = [x.to_json(encode = False) for x in Speaker.get_all()]
	    self.set_body(json.dumps(speakers))
	else:
	    speaker = Speaker.get(id)
	    self.set_body(speaker.to_json())
	return self.render()
开发者ID:droot,项目名称:Batty,代码行数:14,代码来源:handlers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.SpeakerForm类代码示例发布时间:2022-05-27
下一篇:
Python models.Site类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap