Correctly applying new materials to the object
It's a little difficult to test since you didn't provide a .blend, but this should give you a solution.

First of all, remove this line from your script:

# mat.use_shadeless = True


Shadeless is what is making it look flat.



Second, the texture. You had it right in your first post: you want it to be UV mapped.

# this is correct:
mtex.texture_coords = 'UV'


But in order for it to show up properly, you need to UV unwrap your model. You can find an abundance of tutorials for it online, and if you already know how to do it you can disregard the rest of this answer.

Imagine this is your chair back:



Go into edit mode with Tab, and select where the seams of the texture will go. This will make sense in a second. Here's approximately what I'd recommend, for a chair.



Notice that if you took scissors and cut along these lines, you would be left with a bunch of more or less flat pieces. This is exactly what you want. Now press CTRL + E and click Mark Seam.



If you deselect all (A) then you'll see red marks where you "cut" your mesh.

Press A to select all agaain, and press U and click Unwrap. In the bottom left corner of the 3D view, change it to a UV/Image editor.



Press ALT + O, and browse to the texture you want, and then using R G and S, position the unwrapped model the way you want it. You may want to line the grain up with the vertical axis for example.



And you will be left with a gorgeous chair back.



If you look around at the backside, you can see the seams too.