Previous topic


Next topic


This Page

Binary Types

The spyne.model.binary package contains binary type markers.

class spyne.model.binary.ByteArray[source]

Bases: spyne.model._base.SimpleModel

Canonical container for arbitrary data. Every protocol has a different way of encapsulating this type. E.g. xml-based protocols encode this as base64, while HttpRpc just hands it over.

Its native python format is a sequence of str objects for Python 2.x and a sequence of bytes objects for Python 3.x.

class spyne.model.binary.File[source]

Bases: spyne.model._base.SimpleModel

A compact way of dealing with incoming files for protocols with a standard way of encoding file metadata along with binary data. (E.g. Http)

class Value(name=None, path=None, type='application/octet-stream', data=None, handle=None, move=False)[source]

Bases: spyne.model.complex.ComplexModel

The class for values marked as File.

  • name – Original name of the file
  • path – Current path to the file.
  • type – The mime type of the file’s contents.
  • data – Optional sequence of str or bytes instances that contain the file’s data.
  • handlefile object that contains the file’s data. It is ignored unless the path argument is None.

This method normalizes the file object by making path, name and handle properties consistent. It writes incoming data to the file object and points the data iterable to the contents of this file.