Help: applying texture to selected objects

import Blender
from Blender import *

def apply_texture(imagename):
  texture = Blender.Image.Load(imagename)
  for object in Blender.Object.GetSelected():
    if object.getType() == 'Mesh':
      faces = object.getData().faces
      print object
      # Select all faces for uv texturing
      for f in faces:
        f.image = texture
        f.mode = NMesh.FaceModes['TEX']
        print f.image

in_editmode = Window.EditMode()
# MUST leave edit mode before changing an active mesh:
if in_editmode: Window.EditMode(0)


# be nice to the user and return things to how they were:
if in_editmode: Window.EditMode(1)

Im trying to apply a texture to all the faces of the selected objects, but for some reason it doesnt work.

Am I forgetting something or doing something wrong?

Thank you

Signed Sueastside