'This only works for models in the database,
so all models in the chain must be saved to the DB first
(in a transaction), then backed out if they don\'t verify.'

def verify(self):

    if (not self.validate()):
        return False
    prev_invitation = None
    for link in self.chain:
        device = link['device']
        invitation = link['zone_invitation']
        devicezone = link['device_zone']
        if ((not device.is_trusted()) and (device.get_zone() != self.zone)):
            return False
        if invitation:
            if (not invitation.is_authorized(device)):
                return False
            if (prev_invitation and (not device.get_key().verify(prev_invitation.public_key, prev_invitation.public_key_signature))):
                return False
        if devicezone:
            if (devicezone.zone != self.zone):
                return False
        prev_invitation = invitation
    return True
