def exists( self, index # type: int ): try: err = self._original._results[index][0] if err: path = self._original._specs[index][1] raise E.exc_from_rc(err, obj=path) return True except E.PathNotFoundException: return False except E.CouchbaseException: raise
def exists(self, path_or_index): """ Checks if a path exists in the document. This is meant to be used for a corresponding :meth:`~couchbase.subdocument.exists` request. :param path_or_index: The path (or index) to check :return: `True` if the path exists, `False` if the path does not exist :raise: An exception if the server-side check failed for a reason other than the path not existing. """ result = self._resolve(path_or_index) if not result[0]: return True elif E.SubdocPathNotFoundError._can_derive(result[0]): return False else: raise E.exc_from_rc(result[0])
def __iter__(self): for resinfo, specinfo in izip(self._results, self._specs): err, value, path = resinfo[0], resinfo[1], specinfo[1] if err: raise E.exc_from_rc(err, obj=path) yield value
def __getitem__(self, item): rv = self._resolve(item) if rv[0]: raise E.exc_from_rc(rv[0], obj=item) else: return rv[1]