so I wanted to do the same thing so I have couple of layers in my scene, each layer is opened in a 3dview window. One of the layers (which is viewed in one of the 3d views) I don't want the user to be able to rotate in the scene using the middle mouse button.
which does it in three lines of code, but I wonder how I can do it without the need to install this as an addon, like I want to use this layout.prop(context.space_data.region_3d, 'lock_rotation', text='Lock View Rotation')
for a specific 3dview in my file