def upload_dir(app, filename):
    """ Returns the upload path for applications.
    The end result will be something like:
        "uploads/applications/Firefox/icons/firefox.png"
    """

    path = ('applications/' + app.name + '/icons/' + filename)
    # Note: if the file already exist in the same path, django will
    # automatically append a random hash code to the filename!
    return path