def get_events(self, from_=None, to=None):
        """Query a slice of the events.

        Events are always returned in the order the were added.

        Parameters:
        from_   -- if not None, return only events added after the event with
                   id `from_`. If None, return from the start of history.
        to      -- if not None, return only events added before, and
                   including, the event with event id `to`. If None, return up
                   to, and including, the last added event.

        returns -- an iterable of (event id, eventdata) tuples.

        """
        if from_ and (from_ not in self.keys or from_ not in self.events):
            raise EventStore.EventKeyDoesNotExistError(
                "Could not find the from_ key: {0}".format(from_))
        if to and (to not in self.keys or to not in self.events):
            raise EventStore.EventKeyDoesNotExistError(
                "Could not find the from_ key: {0}".format(to))

        # +1 here because we have already seen the event we are asking for
        fromindex = self.keys.index(from_) + 1 if from_ else 0

        toindex = self.keys.index(to) + 1 if to else len(self.events)
        if fromindex > toindex:
            msg = ("'From' index came after 'To'."
                   " Keys: ({0}, {1})"
                   " Indices: ({2}, {3})").format(from_, to, fromindex,
                                                  toindex)
            raise EventOrderError(msg)
        return ((key, self.events[key])
                for key in self.keys[fromindex:toindex])