'Set the spine to be spine_items where spine_items is an iterable of
the form (name, linear). Will raise an error if one of the names is not
present in the manifest.'

def set_spine(self, spine_items):

    imap = self.manifest_id_map
    imap = {name: item_id for (item_id, name) in imap.iteritems()}
    items = [item for (item, name, linear) in self.spine_iter]
    (tail, last_tail) = ((items[0].tail, items[(-1)].tail) if items else (u'\n                ', u'\n        '))
    map(self.remove_from_xml, items)
    spine = self.opf_xpath(u'//opf:spine')[0]
    spine.text = tail
    for (name, linear) in spine_items:
        i = spine.makeelement((u'{%s}itemref' % OPF_NAMESPACES[u'opf']), nsmap={u'opf': OPF_NAMESPACES[u'opf']})
        i.tail = tail
        i.set(u'idref', imap[name])
        spine.append(i)
        if (not linear):
            i.set(u'linear', u'no')
    if (len(spine) > 0):
        spine[(-1)].tail = last_tail
    self.dirty(self.opf_name)
