def _copyConferenceToForm(self, conf, displayName):
     """Copy relevant fields from Conference to ConferenceForm."""
     
     cf = ConferenceForm()
     
     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)))
     
             else:
     
                 setattr(cf, field.name, getattr(conf, field.name))
     
         elif field.name == "websafeKey":
     
             setattr(cf, field.name, conf.key.urlsafe())
     
     if displayName:
     
         setattr(cf, 'organizerDisplayName', displayName)
     
     cf.check_initialized()
     
     return cf
Exemplo n.º 2
0
 def _copyConferenceToForm(self, conf, displayName):
     """Copy relevant fields from Conference to ConferenceForm.
         Args:   conf: conference entity
                 displayName: Name of conference
         Returns:    Conference Form
     """
     # Establish empty conference form
     cf = ConferenceForm()
     # For every field in the form
     for field in cf.all_fields():
         # If the Conference entitry has the field name as a property
         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)))
             else:
                 # Assign the form field to the value in the entity property
                 setattr(cf, field.name, getattr(conf, field.name))
         # Special handling for the websafeKey field
         elif field.name == "websafeKey":
             # Assign the field from the conference key
             setattr(cf, field.name, conf.key.urlsafe())
     # Assign the displayName to the form from the function arg if exists
     if displayName:
         setattr(cf, 'organizerDisplayName', displayName)
     # Check that all required fields are present
     cf.check_initialized()
     return cf
Exemplo n.º 3
0
 def _copyConferenceToForm(self, conf, displayName):
     cf = ConferenceForm()
     for field in cf.all_fields():
         if hasattr(conf, field.name):
             if(field.name.startsWith("Date")):
                 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())
     if displayName:
         setattr(cf, 'organizerDisplayName', displayName)
     cf.check_initialized()
     return cf
Exemplo n.º 4
0
    def _copyConferenceToForm(self, conf, displayName):

        cf = ConferenceForm()
        for field in cf.all_fields():
            if hasattr(conf, field.name):
                if field.name.endswith('Date'):
                    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())
        if displayName:
            setattr(cf, 'organizerDisplayName', displayName)
        cf.check_initialized()
        return cf
Exemplo n.º 5
0
 def toConferenceForm(self, conf=None, displayName=None):
     """Copy relevant fields from Conference to ConferenceForm."""
     cf = ConferenceForm()
     if conf:
         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)))
                 else:
                     setattr(cf, field.name, getattr(conf, field.name))
             elif field.name == "websafeConferenceKey" and hasattr(conf, "key"):
                 setattr(cf, field.name, conf.key.urlsafe())
     if displayName:
         setattr(cf, "organizerDisplayName", displayName)
     cf.check_initialized()
     return cf
 def _copyConferenceToForm(self, conf, displayName):
     """ Copy relevant fields from Conference to ConferenceForm.
     Set the origanizer using the displayName.
 """
     # create an empty conference form
     cf = ConferenceForm()
     # fill in the values
     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)))
             else:
                 setattr(cf, field.name, getattr(conf, field.name))
         elif field.name == "websafeKey":
             setattr(cf, field.name, conf.key.urlsafe())
     if displayName:
         setattr(cf, "organizerDisplayName", displayName)
     cf.check_initialized()
     return cf
Exemplo n.º 7
0
 def _copyConferenceToForm(self, conf, displayName):
     # create a new ConferenceForm object
     cf = ConferenceForm()
     for field in cf.all_fields():
         if hasattr(conf, field.name):
             # convert Date to date string; just copy others
             if field.name.endswith('Date'):
                 # set cf."field.name" equal to string of conf."field.name"
                 setattr(cf, field.name, str(getattr(conf, field.name)))
             else:
                 # set cf."field.name" equal to conf."field.name"
                 setattr(cf, field.name, getattr(conf, field.name))
         elif field.name == "websafeKey":
             setattr(cf, field.name, conf.key.urlsafe())
     if displayName:
         setattr(cf, 'organizerDisplayName', displayName)
     # check if all required fields are initialized
     # returns ValidationError if not
     cf.check_initialized()
     return cf
Exemplo n.º 8
0
    def _copyConferenceToForm(self, conference, displayName):
        """Copy relevant fields from Conference to ConferenceForm"""
        conferenceForm = ConferenceForm()

        for field in conferenceForm.all_fields():
            logging.debug("field name is: "+field.name)
            if hasattr(conference, field.name):
                # convert Date to date string: just copy others
                if field.name.endswith('Date'):
                    setattr(conferenceForm, field.name, str(getattr(conference, field.name)))
                else:
                    setattr(conferenceForm, field.name, getattr(conference, field.name))
            elif field.name == "webSafeKey":
                setattr(conferenceForm, field.name, conference.key.urlsafe())
            if displayName:
                setattr(conferenceForm, "organizerDisplayName", displayName)

        logging.info( "conferenceForm is: " )
        logging.info( conferenceForm )
        conferenceForm.check_initialized()
        return conferenceForm