Package foolscap :: Module constraint :: Class Optional
[hide private]
[frames] | no frames]

Class Optional

source code

Constraint --+
             |
            Optional

Instance Methods [hide private]
 
__init__(self, constraint, default) source code
 
maxSize(self, seen=None)
I help a caller determine how much memory could be consumed by the input stream while my constraint is in effect.
source code
 
maxDepth(self, seen=None)
I return the greatest number Slicer objects that might exist on the SlicerStack (or Unslicers on the UnslicerStack) while processing an object which conforms to this constraint.
source code

Inherited from Constraint: OPENBYTES, __providedBy__, checkObject, checkOpentype, checkToken, setNumberTaster

Class Variables [hide private]
  name = 'Optional'
Used to describe the Constraint in a Violation error message
  __implemented__ = <implementedBy foolscap.constraint.Optional>
  __provides__ = <zope.interface.declarations.ClassProvides obje...

Inherited from Constraint: COUNTERBYTES, opentypes, strictTaster, taster

Method Details [hide private]

maxSize(self, seen=None)

source code 

I help a caller determine how much memory could be consumed by the input stream while my constraint is in effect.

My constraint will be enforced against the bytes that arrive over the wire. Eventually I will either accept the incoming bytes and my Unslicer will provide an object to its parent (including any subobjects), or I will raise a Violation exception which will kick my Unslicer into 'discard' mode.

I define maxSizeAccept as the maximum number of bytes that will be received before the stream is accepted as valid. maxSizeReject is the maximum that will be received before a Violation is raised. The max of the two provides an upper bound on single objects. For container objects, the upper bound is probably (n-1)*accept + reject, because there can only be one outstanding about-to-be-rejected object at any time.

I return (maxSizeAccept, maxSizeReject).

I raise an UnboundedSchema exception if there is no bound.

Overrides: Constraint.maxSize
(inherited documentation)

maxDepth(self, seen=None)

source code 

I return the greatest number Slicer objects that might exist on the SlicerStack (or Unslicers on the UnslicerStack) while processing an object which conforms to this constraint. This is effectively the maximum depth of the object tree. I raise UnboundedSchema if there is no bound.

Overrides: Constraint.maxDepth
(inherited documentation)

Class Variable Details [hide private]

__provides__

Value:
<zope.interface.declarations.ClassProvides object at 0x870514c>