This patch provides flexible management of lights during rendering, including per-node lighting changes. It allows (for example) turning on the nearest X lights to a given node, or in finding and turning on lights that are part of a 'zone' (e.g. a room) so that they don't light anything outside of that zone.
This means that you can add an arbitrary number of lights to your scene, and then turn them on and off during the scene rendering, exactly when you need them. Since the light manager works by getting callbacks before and after each render phase and scene node render, you can also use it to get up to other cunning hijinks during scene node rendering, given sufficient imagination.
A new example has been added which demonstrates two methods of light management. In this image, there are 45 lights in the scene. Normally, only the 8 lights nearest to the camera would be turned on and would light every node, but here, each cube is being lit by the 3 lights that are part of its local 'zone', with no spill-over to the other cubes. In effect, all 45 lights are being used.

Note that the device abstractions have had to be modified, from relatively minor changes to Null and Software2, to a slightly larger change in D3D8/D3D9, and a fairly big change in OpenGL to separate out requested lights from hardware lights, which fairly closely mimics the behaviour in D3D, where you can create an arbitrary number of device lights, with the limit being on the total number that are actually set active at one time.
I believe all of this is backwards compatible, with no change to the default behaviour. The extra testing in the scene rendering shouldn't introduce any measurable performance hit.