<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_flag(self, request, val, fld):
 """If the specified val is not None, then set the specified field to its boolean value"""

        if val is not None:
            val = bool(val)
            request.set(fld, val)