parameters: (self, request, reg=True)
return_statement: return BooleanMessage(data=retval)
docstring: Register or unregister user for selected conference.
docstring_summary: Register or unregister user for selected conference.
docstring_tokens: Register or unregister user for selected conference .
function: def _conferenceRegistration(self, request, reg=True):
          """Register or unregister user for selected conference."""
          retval = None
          prof = self._getProfileFromUser() # get user Profile
  
          # check if conf exists given websafeConfKey
          # get conference; check that it exists
          wsck = request.websafeConferenceKey
          conf = ndb.Key(urlsafe=wsck).get()
          if not conf:
              raise endpoints.NotFoundException(
                  'No conference found with key: %s' % wsck)
  
          # register
          if reg:
              # check if user already registered otherwise add
              if wsck in prof.conferenceKeysToAttend:
                  raise ConflictException(
                      "You have already registered for this conference")
  
              # check if seats avail
              if conf.seatsAvailable <= 0:
                  raise ConflictException(
                      "There are no seats available.")
  
              # register user, take away one seat
              prof.conferenceKeysToAttend.append(wsck)
              conf.seatsAvailable -= 1
              retval = True
  
          # unregister
          else:
              # check if user already registered
              if wsck in prof.conferenceKeysToAttend:
  
                  # unregister user, add back one seat
                  prof.conferenceKeysToAttend.remove(wsck)
                  conf.seatsAvailable += 1
                  retval = True
              else:
                  retval = False
  
          # write things back to the datastore & return
          prof.put()
          conf.put()
          return BooleanMessage(data=retval)
function_tokens: def _conferenceRegistration ( self , request , reg = True ) : retval = None prof = self . _getProfileFromUser ( ) # get user Profile # check if conf exists given websafeConfKey # get conference; check that it exists wsck = request . websafeConferenceKey conf = ndb . Key ( urlsafe = wsck ) . get ( ) if not conf : raise endpoints . NotFoundException ( 'No conference found with key: %s' % wsck ) # register if reg : # check if user already registered otherwise add if wsck in prof . conferenceKeysToAttend : raise ConflictException ( "You have already registered for this conference" ) # check if seats avail if conf . seatsAvailable <= 0 : raise ConflictException ( "There are no seats available." ) # register user, take away one seat prof . conferenceKeysToAttend . append ( wsck ) conf . seatsAvailable -= 1 retval = True # unregister else : # check if user already registered if wsck in prof . conferenceKeysToAttend : # unregister user, add back one seat prof . conferenceKeysToAttend . remove ( wsck ) conf . seatsAvailable += 1 retval = True else : retval = False # write things back to the datastore & return prof . put ( ) conf . put ( ) return BooleanMessage ( data = retval )