original_docstring: Create or update Conference object, returning ConferenceForm/request.
docstring: Create or update Conference object, returning ConferenceForm/request.
docstring_tokens: Create or update Conference object returning ConferenceForm / request .
code: def _createConferenceObject(self, request):
          """Create or update Conference object, returning ConferenceForm/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("Conference 'name' field required")
  
          # copy ConferenceForm/ProtoRPC Message into dict
          data = {field.name: getattr(request, field.name) for field in request.all_fields()}
          del data['websafeKey']
          del data['organizerDisplayName']
  
          # add default values for those missing (both data model & outbound Message)
          for df in DEFAULTS:
              if data[df] in (None, []):
                  data[df] = DEFAULTS[df]
                  setattr(request, df, DEFAULTS[df])
  
          # convert dates from strings to Date objects; set month based on start_date
          if data['startDate']:
              data['startDate'] = datetime.strptime(data['startDate'][:10], "%Y-%m-%d").date()
              data['month'] = data['startDate'].month
          else:
              data['month'] = 0
          if data['endDate']:
              data['endDate'] = datetime.strptime(data['endDate'][:10], "%Y-%m-%d").date()
  
          # set seatsAvailable to be same as maxAttendees on creation
          if data["maxAttendees"] > 0:
              data["seatsAvailable"] = data["maxAttendees"]
          # generate Profile Key based on user ID and Conference
          # ID based on Profile key get Conference key from ID
          p_key = ndb.Key(Profile, user_id)
          c_id = Conference.allocate_ids(size=1, parent=p_key)[0]
          c_key = ndb.Key(Conference, c_id, parent=p_key)
          data['key'] = c_key
          data['organizerUserId'] = request.organizerUserId = user_id
  
          # create Conference, send email to organizer confirming
          # creation of Conference & return (modified) ConferenceForm
          Conference(**data).put()
          taskqueue.add(params={'email': user.email(),
                                'conferenceInfo': repr(request)},
                        url='/tasks/send_confirmation_email'
          )
          return request
code_tokens: def _createConferenceObject ( self , request ) : user = endpoints . get_current_user ( ) if not user : raise endpoints . UnauthorizedException ( 'Authorization required' ) user_id = getUserId ( user ) if not request . name : raise endpoints . BadRequestException ( "Conference 'name' field required" ) data = { field . name : getattr ( request , field . name ) for field in request . all_fields ( ) } del data [ 'websafeKey' ] del data [ 'organizerDisplayName' ] for df in DEFAULTS : if data [ df ] in ( None , [ ] ) : data [ df ] = DEFAULTS [ df ] setattr ( request , df , DEFAULTS [ df ] ) if data [ 'startDate' ] : data [ 'startDate' ] = datetime . strptime ( data [ 'startDate' ] [ : 10 ] , "%Y-%m-%d" ) . date ( ) data [ 'month' ] = data [ 'startDate' ] . month else : data [ 'month' ] = 0 if data [ 'endDate' ] : data [ 'endDate' ] = datetime . strptime ( data [ 'endDate' ] [ : 10 ] , "%Y-%m-%d" ) . date ( ) if data [ "maxAttendees" ] > 0 : data [ "seatsAvailable" ] = data [ "maxAttendees" ] p_key = ndb . Key ( Profile , user_id ) c_id = Conference . allocate_ids ( size = 1 , parent = p_key ) [ 0 ] c_key = ndb . Key ( Conference , c_id , parent = p_key ) data [ 'key' ] = c_key data [ 'organizerUserId' ] = request . organizerUserId = user_id Conference ( ** data ) . put ( ) taskqueue . add ( params = { 'email' : user . email ( ) , 'conferenceInfo' : repr ( request ) } , url = '/tasks/send_confirmation_email' ) return request
short_docstring: Create or update Conference object, returning ConferenceForm/request.
short_docstring_tokens: Create or update Conference object returning ConferenceForm / request .
comment: """Create or update Conference object, returning ConferenceForm/request."""$SEP$# preload necessary data items
  $SEP$# copy ConferenceForm/ProtoRPC Message into dict
  $SEP$# add default values for those missing (both data model & outbound Message)
  $SEP$# convert dates from strings to Date objects; set month based on start_date
  $SEP$# set seatsAvailable to be same as maxAttendees on creation
  $SEP$# generate Profile Key based on user ID and Conference
  $SEP$# ID based on Profile key get Conference key from ID
  $SEP$# create Conference, send email to organizer confirming
  $SEP$# creation of Conference & return (modified) ConferenceForm
  