code: def set_flag(self, request, val, fld):
          
          if val is not None:
              val = bool(val)
              request.set(fld, val)
docs: If the specified val is not None, then set the specified field to its boolean value