本文整理汇总了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())
示例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()
示例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()
示例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())
示例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()
示例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())
示例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())
示例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())
示例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)
示例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())
示例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