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


Python Speaker.key方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import key [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'))
开发者ID:Mrudul,项目名称:clo-summit,代码行数:31,代码来源:api.py

示例2: post

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import key [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"))
开发者ID:yesudeep,项目名称:clo-summit,代码行数:31,代码来源:api.py

示例3: post

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import key [as 别名]
    def post(self):
        from models import Presentation
        
        host_info = get_host_info(self.request)
        host_info.put()

        presentation_filename = self.request.get('presentation_filename')
        presentation = self.request.get('presentation')

        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')
        speaker.host_info = host_info
        #if presentation_filename:
        #    speaker.presentation = db.Blob(presentation)
        #    speaker.presentation_filename = presentation_filename
        #    speaker.presentation_extension = splitext(presentation_filename)[1]
        if presentation_filename:
            speaker_presentation = Presentation()
            speaker_presentation.filename = presentation_filename
            speaker_presentation.extension = splitext(presentation_filename)[1]
            speaker_presentation.content = db.Blob(presentation)
            speaker_presentation.put()
            
            speaker.presentation = speaker_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'
        )

        response = render_template('thank_you.html', message_title='Thank you for nominating a speaker.', message_body='We appreciate your taking the time to nominating a speaker.  We will get in touch with you soon')
        self.response.out.write(response)
开发者ID:Mrudul,项目名称:clo-summit,代码行数:49,代码来源:www.py

示例4: createSpeaker

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import key [as 别名]
 def createSpeaker(self, request):
     """ Create a speaker """
     # Make sure the user is logged in.
     user = endpoints.get_current_user()
     if not user:
         raise endpoints.UnauthorizedException('Authorization required.')
     user_id = getUserId(user)
     user_key = ndb.Key(Profile, user_id)
     # Create the Speaker object
     speaker = Speaker()
     # Copy the fields from the request to the Speaker
     speaker = message_to_ndb(request, speaker)
     # Allocate the Speaker id and set the key with the User as parent
     speaker_id = speaker.allocate_ids(size=1, parent=user_key)[0]
     speaker.key = ndb.Key(Speaker, speaker_id, parent=user_key)
     # Write the speaker to the db
     speaker.put()
     # Create a SpeakerForm and copy the fields from the request
     speaker_form = SpeakerForm()
     speaker_form = ndb_to_message(speaker, speaker_form)
     # Send back the SpeakerForm including the websafe key
     return speaker_form
开发者ID:kirklink,项目名称:udacity-fullstack-p4,代码行数:24,代码来源:conference.py

示例5: _createSessionObject

# 需要导入模块: from models import Speaker [as 别名]
# 或者: from models.Speaker import key [as 别名]
    def _createSessionObject(self, request, websafeConferenceKey):
        """Create Session object and return it."""
        # preload necessary data items

        # check user login
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # check conference exists
        c_key = None
        try:
            c_key = ndb.Key(urlsafe=websafeConferenceKey)
            conf = c_key.get()
        except Exception:
            conf = None
        if not conf:
            raise endpoints.NotFoundException(
                'No conference found with key: %s' % websafeConferenceKey)
        # check user is organizer of conference
        if conf.organizerUserId != user_id:
            raise endpoints.UnauthorizedException(
                'Only conference organizer can add '
                'sessions to this conference')

        # check session name and speaker email both are included in the form
        if not request.name:
            raise endpoints.BadRequestException(
                "Session 'name' field required")

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

        # check that there is no other session with the same name
        sessions = Session.query(Session.name == request.name).count()
        if sessions:
            raise endpoints.BadRequestException("There is already a session named %s" % request.name)

        # retrieve the speaker using the provided speaker email. If not exists,
        # create a new speaker with the provided name and email
        speaker_key = ndb.Key(Speaker, request.speakerEmail)
        speaker = speaker_key.get()
        if not speaker:
            # there is no speaker, try to create it
            # the speaker name is now required
            if not request.speakerName:
                raise endpoints.BadRequestException(
                    "Speaker name field required")

            # create the speaker entity
            speaker = Speaker()
            speaker.name = request.speakerName
            speaker.email = request.speakerEmail
            speaker.key = speaker_key
            speaker.put()

        # copy request values to to a new dictionary, and remove
        # unnecessary ones
        data = {field.name: getattr(request, field.name) for field in
                request.all_fields()}
        data['speakerId'] = speaker.email

        # delete extra fields from data
        del data['speakerName']
        del data['speakerEmail']
        del data['websafeConferenceKey']

        # add default values for  missing fields
        # (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])

        # properly parse dates and times
        if data['date']:
            data['date'] = datetime.strptime(data['date'][:10],
                                             "%Y-%m-%d").date()
        data['startTime'] = datetime.strptime(data['startTime'],
                                              "%H:%M").time()

        # generate a session key, using conference key as parent
        session_id = Session.allocate_ids(size=1, parent=c_key)[0]
        session_key = ndb.Key(Session, session_id, parent=c_key)
        data['key'] = session_key

        # create the session entity and store it in the Datastore
        session = Session(**data)
        session.put()
        return session
开发者ID:albertoanguita,项目名称:ConferenceApp_Udacity,代码行数:93,代码来源:conference.py


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