'Append numbers to duplicate files rather than underscores, like Trac.'

def get_available_name(self, name, max_length=None):

    parts = name.split('.')
    (basename, ext) = (parts[0], parts[1:])
    number = 2
    while self.exists(name):
        name = '.'.join(([basename, str(number)] + ext))
        number += 1
    return name
