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


Python Speaker.get方法代码示例

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


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

示例1: _createSpeakerObject

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

示例2: delete

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def delete(self, id = None):
	request = self.wsgi_request
	response = self.wsgi_response
	c = self.context
	if id is None:
	    self.set_body('speaker id is a Must')
	else:
	    speaker = Speaker.get(id)
	    if speaker is None:
		self.set_body('No speakererence with %d exist' % (id))
	    else:
		speaker.delete()
		self.set_body("Deleted Successfully...")
	return self.render()
开发者ID:droot,项目名称:Batty,代码行数:16,代码来源:handlers.py

示例3: get

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

示例4: _createSpeakerObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _createSpeakerObject(self, request):
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')

        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}
        del data["sessionKeysToAttend"]
        data["key"] = ndb.Key(Speaker, data["email"])

        # create Speaker entity
        # creation of Speaker & return new Speaker form
        speaker = Speaker(**data).put()

        return self._copySpeakerToForm(speaker.get())
开发者ID:Morenito88,项目名称:full_stack_p4,代码行数:17,代码来源:conference.py

示例5: put

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def put(self, id = None):
	request = self.wsgi_request
	response = self.wsgi_response
	c = self.context

	if id is None:
	    self.set_body('speaker id is a Must')
	else:
	    speaker = Speaker.get(id)
	    if request.params.first_name: speaker.first_name = request.params.first_name
	    if request.params.last_name: speaker.last_name = request.params.last_name
	    if request.params.desc: speaker.desc = request.params.desc
	    if request.params.twitter_handle: speaker.twitter_handle = request.params.twitter_handle
	    speaker = speaker.save()
	    self.set_body(speaker.to_json())
	return self.render()
开发者ID:droot,项目名称:Batty,代码行数:18,代码来源:handlers.py

示例6: _create_speaker_object

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _create_speaker_object(self, request):
        """ Creates a Speaker object """

        # Make sure that the user is authenticated
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException("Authorization required.")

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

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

        speaker_key = Speaker(**data).put()
        return self._copy_speaker_to_form(speaker_key.get())
开发者ID:hackarias,项目名称:conference-center,代码行数:19,代码来源:conference.py

示例7: _createSpeakerObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _createSpeakerObject(self, request):
        """ Create or update Speaker object, returning SpeakerForm
        """

        if not request.name:
            raise endpoints.BadRequestException(
                "Session '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']

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

        spkr_key = Speaker(**data).put()
        return self._copySpeakerToForm(spkr_key.get())
开发者ID:adarsh0806,项目名称:udacity-nd004-p4-conference-organization-app,代码行数:21,代码来源:conference.py

示例8: _createSpeakerObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _createSpeakerObject(self, request):
        """Create Speaker object, returning SpeakerFormOut."""
        # preload necessary data items
        user_id = get_current_user_id()

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

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

        # generate Profile Key based on user ID, used as parent
        p_key = ndb.Key(Profile, user_id)
        data['parent'] = p_key

        # create Speaker & return (new) SpeakerFormOut
        speaker = Speaker(**data).put()
        return self._copySpeakerToForm(speaker.get())
开发者ID:liuderchi,项目名称:fsnd_P4_Conference_Org,代码行数:22,代码来源:conference.py

示例9: _createSpeakerObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _createSpeakerObject(self, request):
        """Create or update Speaker object, returning SpeakerForm/request."""
        # ensure user auth
        user, u_id = self._validateUser()

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

        if request.email:
            q = Speaker.query(Speaker.email == request.email)
            entity = q.get()
            if entity:
                raise endpoints.ForbiddenException('Email is already registered with a speaker.')

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

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

示例10: createspeaker

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def createspeaker(self, request):
        """Create a Speaker object"""
        if not request.name:
            raise endpoints.BadRequestException("Speaker must have a name")

        # check for authorization, valid conference key, and that the current user is the conference orgainizer   # noqa
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException("Authorization required")
        # copy SpeakerForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}   # noqa
        del data['websafeSpeakerKey']
     
        # add default values for those missing (both data model & outbound Message)   # noqa
        for df in DEFAULTSPEAKER:
            if data[df] in (None, []):
                data[df] = DEFAULTSPEAKER[df]
                setattr(request, df, DEFAULTSPEAKER[df])

        # creation of Session, record the key to get the item & return (modified) SessionForm   # noqa
        speakerKey = Speaker(**data).put()
        return self._copySpeakerToForm(speakerKey.get())
开发者ID:yoavitl,项目名称:Udacity,代码行数:24,代码来源:conference.py

示例11: _addSpeakerObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import get [as 别名]
    def _addSpeakerObject(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.speakerFirst or not request.speakerLast:
            raise endpoints.BadRequestException("Speaker 'name' fields are required")

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

        # creation of Speaker with key & return (modified) SpeakerForm
        speaker_key = Speaker(**data).put()
        wsk = speaker_key.urlsafe()

        speaker = speaker_key.get()
        speaker.speakerWSK = wsk
        speaker.put()
        
        return request
开发者ID:erooma,项目名称:Conference-Application,代码行数:25,代码来源:conference.py


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