perceval/archive.py
def retrieve(self, uri, payload, headers):
        """Retrieve a raw item from the archive.

        The method will return the `data` content corresponding to the
        hascode derived from the given parameters.

        :param uri: request URI
        :param payload: request payload
        :param headers: request headers

        :returns: the archived data

        :raises ArchiveError: when an error occurs retrieving data
        """
        hashcode = self.make_hashcode(uri, payload, headers)

        logger.debug("Retrieving entry %s with %s %s %s in %s",
                     hashcode, uri, payload, headers, self.archive_path)

        self._db.row_factory = sqlite3.Row

        try:
            cursor = self._db.cursor()
            select_stmt = "SELECT data " \
                          "FROM " + self.ARCHIVE_TABLE + " " \
                          "WHERE hashcode = ?"
            cursor.execute(select_stmt, (hashcode,))
            row = cursor.fetchone()
            cursor.close()
        except sqlite3.DatabaseError as e:
            msg = "data retrieval error; cause: %s" % str(e)
            raise ArchiveError(cause=msg)

        if row:
            found = pickle.loads(row['data'])
        else:
            msg = "entry %s not found in archive %s" % (hashcode, self.archive_path)
            raise ArchiveError(cause=msg)

        return found
def retrieve(self, uri, payload, headers):
        hashcode = self.make_hashcode(uri, payload, headers)

        logger.debug("Retrieving entry %s with %s %s %s in %s",
                     hashcode, uri, payload, headers, self.archive_path)

        self._db.row_factory = sqlite3.Row

        try:
            cursor = self._db.cursor()
            select_stmt = "SELECT data " \
                          "FROM " + self.ARCHIVE_TABLE + " " \
                          "WHERE hashcode = ?"
            cursor.execute(select_stmt, (hashcode,))
            row = cursor.fetchone()
            cursor.close()
        except sqlite3.DatabaseError as e:
            msg = "data retrieval error; cause: %s" % str(e)
            raise ArchiveError(cause=msg)

        if row:
            found = pickle.loads(row['data'])
        else:
            msg = "entry %s not found in archive %s" % (hashcode, self.archive_path)
            raise ArchiveError(cause=msg)

        return found
def retrieve ( self , uri , payload , headers ) : hashcode = self . make_hashcode ( uri , payload , headers ) logger . debug ( "Retrieving entry %s with %s %s %s in %s" , hashcode , uri , payload , headers , self . archive_path ) self . _db . row_factory = sqlite3 . Row try : cursor = self . _db . cursor ( ) select_stmt = "SELECT data " "FROM " + self . ARCHIVE_TABLE + " " "WHERE hashcode = ?" cursor . execute ( select_stmt , ( hashcode , ) ) row = cursor . fetchone ( ) cursor . close ( ) except sqlite3 . DatabaseError as e : msg = "data retrieval error; cause: %s" % str ( e ) raise ArchiveError ( cause = msg ) if row : found = pickle . loads ( row [ 'data' ] ) else : msg = "entry %s not found in archive %s" % ( hashcode , self . archive_path ) raise ArchiveError ( cause = msg ) return found
Retrieve a raw item from the archive.

        The method will return the `data` content corresponding to the
        hascode derived from the given parameters.

        :param uri: request URI
        :param payload: request payload
        :param headers: request headers

        :returns: the archived data

        :raises ArchiveError: when an error occurs retrieving data
Retrieve a raw item from the archive .