def _copySessionToForm(self, session): """Copies the given Session object to a SessionForm object.""" sessionForm = SessionForm() sessionForm.name = session.name sessionForm.speaker = session.speaker sessionForm.date = str(session.date) sessionForm.startTime = str(session.startTime) sessionForm.duration = session.duration sessionForm.typeOfSession = session.typeOfSession sessionForm.highlights = session.highlights sessionForm.websafeKey = session.key.urlsafe() return sessionForm
def _copySessionToForm(self, session): """Copy fields from Session to SessionForm.""" session_form = SessionForm() for field in session_form.all_fields(): try: if field.name == 'startTime': session_form.startTime = str(session.startTime) elif field.name == 'date': session_form.date = str(session.date) elif hasattr(session, field.name): setattr(session_form, field.name, getattr(session, field.name)) elif field.name == "sessionSafeKey": setattr(session_form, field.name, session.key.urlsafe()) except AttributeError: raise endpoints.BadRequestException("Error, check the input fields.") session_form.check_initialized() return session_form
def _copySessionToForm(self, session): """Copy fields from Session to SessionForm.""" session_form = SessionForm() for field in session_form.all_fields(): try: if field.name == 'startTime': session_form.startTime = str(session.startTime) elif field.name == 'date': session_form.date = str(session.date) elif hasattr(session, field.name): setattr(session_form, field.name, getattr(session, field.name)) elif field.name == "sessionSafeKey": setattr(session_form, field.name, session.key.urlsafe()) except AttributeError: raise endpoints.BadRequestException( "Error, check the input fields.") session_form.check_initialized() return session_form
def _copySessionToForm(self, session): """Copy relevant fields from Session to SessionForm""" # create a new entity first sf = SessionForm() # convert Session properties to SessionForm fields sf.name = session.name sf.highlights = session.highlights sf.speakerKeys = session.speakerKeys sf.duration = session.duration sf.typeOfSession = getattr(SessionTypes, session.typeOfSession) sf.date = str(session.date) sf.startTime = int('%s%s' % (str(session.startTime)[:2], str(session.startTime)[3:5])) sf.websafeKey = session.key.urlsafe() # check and return sf.check_initialized() return sf
def _copySessionToForm(self, session): """Copy relevant fields from Session to SessionForm""" # create a new entity first sf = SessionForm() # convert Session properties to SessionForm fields sf.name = session.name sf.highlights = session.highlights sf.speakerKeys = session.speakerKeys sf.duration = session.duration sf.typeOfSession = getattr(SessionTypes, session.typeOfSession) sf.date = str(session.date) sf.startTime = int( '%s%s' % (str(session.startTime)[:2], str(session.startTime)[3:5])) sf.websafeKey = session.key.urlsafe() # check and return sf.check_initialized() return sf
def _copySessionToForm(self, session): """Copy relevant fields from Session to SessionForm.""" sf = SessionForm() for field in sf.all_fields(): if field.name == 'startTime': sf.startTime = str(session.startTime) elif hasattr(session, field.name): setattr(sf, field.name, getattr(session, field.name)) speakerEmail = session.speakerEmail speaker = SessionSpeaker.query(SessionSpeaker.email == speakerEmail).get() if not speaker: sf.speakerName = "Not Found" sf.speakerEmail = "Not Found" else: sf.speakerEmail = speakerEmail sf.speakerName = speaker.name sf.websafeConferenceKey = session.key.parent().urlsafe() sf.websafeSessionKey = session.key.urlsafe() sf.check_initialized() return sf
def _copySessionToForm(self, session): """Copy relevant fields from Session to SessionForm""" # create a new entity first sf = SessionForm() # convert Session properties to SessionForm fields sf.sessionName = session.sessionName sf.highlights = session.highlights sf.speaker = session.speaker sf.duration = session.duration #logging.debug("copySession :: About to set typeOfSession") #logging.debug("copySession :: type of Session type is %s", type(session.typeOfSession)) sf.typeOfSession = getattr(SessionType,session.typeOfSession) sf.sessionDate = str(session.sessionDate) sf.startTime = int('%s%s' % (str(session.startTime)[:2], str(session.startTime)[3:5])) sf.websafeKey = session.key.urlsafe() # check and return sf.check_initialized() return sf