Conditional texturemapping in a shader

I have a shader I wrote to do some custom lighting calculations. I apply this shader to my whole scene. To calculate the output color from the fragment shader, it multiplies the lighting calculation by the interpolated vertex color and the texture color like this:

o_color=lighting_factor * l_color * tex2D(tex_0,l_texcoord0);

The problem is that not all models in the scene have a texture map assigned and when you sample an undefined texture, bad things happen. Is there any way in a shader to test if a sampler actually has a texture assigned to it or not? Or is there a way to make panda pass some kind of boolean to the shader that says whether that object has a texture on it?

You could simply ensure every object in your scene has a texture applied to it. For instance, load up a white 1x1 texture:

tex = loader.loadTexture('white.png')

Since you do not specify an override to the setTexture() call, it will only apply to those objects that do not already have a texture.