本文整理汇总了Python中models.Speaker.put方法的典型用法代码示例。如果您正苦于以下问题:Python Speaker.put方法的具体用法?Python Speaker.put怎么用?Python Speaker.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Speaker
的用法示例。
在下文中一共展示了Speaker.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createSpeaker
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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
示例2: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例3: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例4: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例5: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例6: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例7: post
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
def post(self, key):
presentation_filename = self.request.get('presentation_filename')
speaker = Speaker()
speaker.full_name = self.request.get('full_name')
speaker.designation = self.request.get('designation')
speaker.organization = self.request.get('organization')
speaker.department = self.request.get('department')
speaker.organization_website = self.request.get('organization_website')
speaker.city = self.request.get('city')
speaker.email = self.request.get('email')
speaker.mobile_number = self.request.get('mobile_number')
speaker.research_topic = self.request.get('research_topic')
speaker.bio_sketch = self.request.get('bio_sketch')
if presentation_filename:
speaker.presentation = self.request.get('presentation')
speaker.presentation_filename = self.request.get('presentation_filename')
speaker.presentation_extension = splitext(presentation_filename)[1]
speaker.put()
queue_mail_task(url='/worker/mail/thanks/speaker_nomination/',
params=dict(
full_name=speaker.full_name,
email = speaker.email,
key=str(speaker.key())
),
method='POST'
)
self.response.out.write(speaker.to_json('full_name', 'is_starred', 'is_deleted', 'is_active'))
示例8: post
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
def post(self, key):
presentation_filename = self.request.get("presentation_filename")
speaker = Speaker()
speaker.full_name = self.request.get("full_name")
speaker.designation = self.request.get("designation")
speaker.organization = self.request.get("organization")
speaker.department = self.request.get("department")
speaker.organization_website = self.request.get("organization_website")
speaker.city = self.request.get("city")
speaker.email = self.request.get("email")
speaker.mobile_number = self.request.get("mobile_number")
speaker.research_topic = self.request.get("research_topic")
speaker.bio_sketch = self.request.get("bio_sketch")
if presentation_filename:
presentation = Presentation()
presentation.filename = self.request.get("presentation_filename")
presentation.content = db.Blob(self.request.get("presentation"))
presentation.extension = splitext(presentation_filename)[1]
presentation.put()
speaker.presentation_file = presentation
speaker.put()
queue_mail_task(
url="/worker/mail/thanks/speaker_nomination/",
params=dict(full_name=speaker.full_name, email=speaker.email, key=str(speaker.key())),
method="POST",
)
self.response.out.write(speaker.to_json("full_name", "is_starred", "is_deleted", "is_active"))
示例9: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例10: addSpeaker
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例11: _createSessionObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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
示例12: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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
示例13: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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
示例14: _createSpeakerObject
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
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)
示例15: createSpeaker
# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import put [as 别名]
def createSpeaker(self, request):
"""Create new speaker"""
# check for required fields
if not request.name:
raise endpoints.BadRequestException("Speaker 'name' field required")
# create speaker
speaker = Speaker(
name = request.name.title(), #store in fixed title case for case-independent string request later
bio = request.bio
)
speaker.put()
# return SpeakerForm
return self._copySpeakerToForm(speaker)