'Generate a new unique identifier and/or internal path for use in
creating a new manifest item, using the provided :param:`id` and/or
:param:`href` as bases.
Returns an two-tuple of the new id and path.  If either :param:`id` or
:param:`href` are `None` then the corresponding item in the return
tuple will also be `None`.'

def generate(self, id=None, href=None):

    if (id is not None):
        base = id
        index = 1
        while (id in self.ids):
            id = (base + str(index))
            index += 1
    if (href is not None):
        href = urlnormalize(href)
        (base, ext) = os.path.splitext(href)
        index = 1
        lhrefs = set([x.lower() for x in self.hrefs])
        while (href.lower() in lhrefs):
            href = ((base + str(index)) + ext)
            index += 1
    return (id, unicode(href))
