def put_state(self, request_dict):
        registration = request_dict['params'].get('registration', None)
        if registration:
            s, created = ActivityState.objects.get_or_create(state_id=request_dict['params']['stateId'], agent=self.Agent,
                activity_id=request_dict['params']['activityId'], registration_id=request_dict['params']['registration'])
        else:
            s, created = ActivityState.objects.get_or_create(state_id=request_dict['params']['stateId'], agent=self.Agent,
                activity_id=request_dict['params']['activityId'])
        
        if "application/json" not in request_dict['headers']['CONTENT_TYPE']:
            try:
                post_state = ContentFile(request_dict['state'].read())
            except:
                try:
                    post_state = ContentFile(request_dict['state'])
                except:
                    post_state = ContentFile(str(request_dict['state']))
            
            # If a state already existed with the profileId and activityId
            if not created:
                etag.check_preconditions(request_dict, s)
                if s.state:
                    try:
                        s.state.delete()
                    except __HOLE__:
                        # probably was json before
                        s.json_state = {}
            self.save_non_json_state(s, post_state, request_dict)
        # State being PUT is json
        else:
            if not created:
                etag.check_preconditions(request_dict, s)
            the_state = request_dict['state']
            s.json_state = the_state
            s.content_type = request_dict['headers']['CONTENT_TYPE']
            s.etag = etag.create_tag(the_state)

            #Set updated
            if 'updated' in request_dict['headers'] and request_dict['headers']['updated']:
                s.updated = request_dict['headers']['updated']
            else:
                s.updated = datetime.datetime.utcnow().replace(tzinfo=utc)
            s.save()
dataset/ETHPy150Open adlnet/ADL_LRS/lrs/managers/ActivityStateManager.py/ActivityStateManager.put_state