コード例 #1
0
    def _copyConferenceSessionToForm(self, confSession):
        """
        Copy relevant fields from ConferenceSession to ConferenceSessionForm.
        """

        csf = ConferenceSessionForm()
        for field in csf.all_fields():
            if hasattr(confSession, field.name):
                if field.name == "date":
                    setattr(
                        csf, field.name, str(
                            getattr(
                                confSession, field.name)))
                elif field.name == "typeOfSession":
                    setattr(
                        csf,
                        field.name,
                        getattr(
                            ConferenceSessionType,
                            getattr(
                                confSession,
                                field.name)))
                else:
                    setattr(csf, field.name, getattr(confSession, field.name))
            elif field.name == "sessionKey":
                setattr(csf, field.name, confSession.key.urlsafe())

        csf.check_initialized()
        return csf
コード例 #2
0
 def _copySessionToForm(self, sess):
     """Copy the session to the session form"""
     sf = ConferenceSessionForm()
     for field in sf.all_fields():
         if hasattr(sess, field.name):
             # convert Date to date string; just copy others
             if field.name.endswith('Date'):
                 setattr(sf, field.name, str(getattr(sess, field.name)))
             elif field.name == 'speakers':
                 setattr(sf, field.name, [s.name for s in getattr(sess, field.name)])
             elif field.name == 'start_time':
                 setattr(sf, field.name, str(getattr(sess, field.name)))
             else:
                 setattr(sf, field.name, getattr(sess, field.name))
         elif field.name == "websafeKey":
             setattr(sf, field.name, sess.key.urlsafe())
     sf.check_initialized()
     return sf
コード例 #3
0
	def _copyConferenceSessionToForm(self, conf):
		"""Copy relevant fields from ConferenceSession to ConferenceSessionForm."""
		cf = ConferenceSessionForm()
		for field in cf.all_fields():
			if hasattr(conf, field.name):
				# convert Date to date string; just copy others
				if field.name.endswith('Date'):
					setattr(cf, field.name, str(getattr(conf, field.name)))
				elif field.name == "duration":
					setattr(cf, field.name, str(getattr(conf, field.name)))	
				elif field.name == "startTime":
					setattr(cf, field.name, str(getattr(conf, field.name)))							
				else:
					setattr(cf, field.name, getattr(conf, field.name))
			elif field.name == "websafeKey":
				setattr(cf, field.name, conf.key.urlsafe())
				
		cf.check_initialized()
		
		return cf
コード例 #4
0
 def toConferenceSessionForm(self, conf_sess=None, displayName=None):
     """Copy relevant fields from ConferenceSession to ConferenceSessionForm."""
     cf = ConferenceSessionForm()
     if conf_sess:
         for field in cf.all_fields():
             if hasattr(conf_sess, field.name):
                 # convert Date to date string
                 if field.name == "date":
                     setattr(cf, field.name, str(getattr(conf_sess, field.name)))
                 elif field.name == "startTime":
                     setattr(cf, field.name, conf_sess.startTime.strftime("%H:%M %p"))
                 elif field.name == "typeOfSession":
                     setattr(cf, field.name, getattr(SessionType, getattr(conf_sess, field.name)))
                 else:
                     setattr(cf, field.name, getattr(conf_sess, field.name))
             elif field.name == "websafeSessionKey" and hasattr(conf_sess, "key"):
                 setattr(cf, field.name, str(conf_sess.key.urlsafe()))
         if displayName:
             setattr(cf, "speakerDisplayName", displayName)
     cf.check_initialized()
     return cf