def set_edit_mode(request, flag):
 if (flag and could_edit(request)):
  request.session[EDIT_FLAG_NAME] = True
 else:
  request.session.pop(EDIT_FLAG_NAME, None)

def set_edit_mode ( request , flag ) : if ( flag and could_edit ( request ) ) : request . session [ EDIT_FLAG_NAME ] = True else : request . session . pop ( EDIT_FLAG_NAME , None )
enable or disable edit mode for the request .