t.w._flatten : module documentation

Part of twisted.web View Source

Context-free flattener/serializer for rendering Python objects, possibly complex or arbitrarily nested, as strings.
Function escapedData Escape a string for inclusion in a document.
Function escapedCDATA Escape CDATA for inclusion in a document.
Function escapedComment Escape a comment for inclusion in a document.
Function _getSlotValue Find the value of the named slot in the given stack of slot data.
Function _flattenElement Make root slightly more flat by yielding all its immediate contents as strings, deferreds or generators that are recursive calls to itself.
Function _flattenTree Make root into an iterable of str and Deferred by doing a depth first traversal of the tree.
Function _writeFlattenedData Take strings from an iterator and pass them to a writer function.
def escapedData(data, inAttribute): (source)
Escape a string for inclusion in a document.
ParametersdataThe string to escape. (type: str or unicode)
inAttributeA flag which, if set, indicates that the string should be quoted for use as the value of an XML tag value. (type: bool)
ReturnsThe quoted form of data. If data is unicode, return a utf-8 encoded string. (type: str)
def escapedCDATA(data): (source)
Escape CDATA for inclusion in a document.
ParametersdataThe string to escape. (type: str or unicode)
ReturnsThe quoted form of data. If data is unicode, return a utf-8 encoded string. (type: str)
def escapedComment(data): (source)
Escape a comment for inclusion in a document.
ParametersdataThe string to escape. (type: str or unicode)
ReturnsThe quoted form of data. If data is unicode, return a utf-8 encoded string. (type: str)
def _getSlotValue(name, slotData, default=None): (source)
Find the value of the named slot in the given stack of slot data.
def _flattenElement(request, root, slotData, renderFactory, inAttribute): (source)
Make root slightly more flat by yielding all its immediate contents as strings, deferreds or generators that are recursive calls to itself.
ParametersrequestA request object which will be passed to IRenderable.render.
rootAn object to be made flatter. This may be of type unicode, str, slot, Tag, URL, tuple, list, GeneratorType, Deferred, or an object that implements IRenderable.
slotDataA list of dict mapping str slot names to data with which those slots will be replaced.
renderFactoryIf not None, An object that provides IRenderable.
inAttributeA flag which, if set, indicates that str and unicode instances encountered must be quoted as for XML tag attribute values.
ReturnsAn iterator which yields str, Deferred, and more iterators of the same type.
def _flattenTree(request, root): (source)
Make root into an iterable of str and Deferred by doing a depth first traversal of the tree.
ParametersrequestA request object which will be passed to IRenderable.render.
rootAn object to be made flatter. This may be of type unicode, str, slot, Tag, tuple, list, GeneratorType, Deferred, or something providing IRenderable.
ReturnsAn iterator which yields objects of type str and Deferred. A Deferred is only yielded when one is encountered in the process of flattening root. The returned iterator must not be iterated again until the Deferred is called back.
def _writeFlattenedData(state, write, result): (source)
Take strings from an iterator and pass them to a writer function.
ParametersstateAn iterator of str and Deferred. str instances will be passed to write. Deferred instances will be waited on before resuming iteration of state.
writeA callable which will be invoked with each str produced by iterating state.
resultA Deferred which will be called back when state has been completely flattened into write or which will be errbacked if an exception in a generator passed to state or an errback from a Deferred from state occurs.
ReturnsNone
API Documentation for Twisted, generated by pydoctor at 2012-06-04 17:20:01.