gavo.formal.twistedpatch module

Code to add some basic nevow functionality back to twisted.

This needs to be imported as early as possible after importing twisted.web for the first time.

The features were adding include:

  • have nevow tag[] syntax again.

  • swallow attributes with None values in tags

  • (Ab)use slotData to manage what was nevow:data, pass it into the render method as tag.slotData

  • functions are allowed as render values

class gavo.formal.twistedpatch.MPRequest(*args, **kwargs)[source]

Bases: Request

A request class that can sensibly deal with multipart request payloads.

Basically, file uploads turn up in the .files attribute.

This has a new class attribute, maxUploadSize, the number of bytes before we return a 413, defaulting to 64 MB.

maxUploadSize = 67108864
requestReceived(command, path, version)[source]

Called by channel when all data has been received.

This method is not intended for users.

@type command: C{bytes} @param command: The HTTP verb of this request. This has the case

supplied by the client (eg, it maybe “get” rather than “GET”).

@type path: C{bytes} @param path: The URI of this request.

@type version: C{bytes} @param version: The HTTP version of this request.

class gavo.formal.twistedpatch.Raw[source]

Bases: object

a thing to stick into stan trees that can write whatever it wants into the serialised result.

Just override getContent and return a byte string from it.

getContent(destFile)[source]
class gavo.formal.twistedpatch.Tag(tagName, attributes=None, children=None, render=None, filename=None, lineNumber=None, columnNumber=None, data=None)[source]

Bases: Tag

clone(deep=True, newData=<class 'gavo.formal.twistedpatch._NoData'>)[source]

Return a clone of this tag. If deep is True, clone all of this tag’s children. Otherwise, just shallow copy the children list without copying the children themselves.

gavo.formal.twistedpatch.patchTwTemplate(name, obj)[source]

monkeypatches whatever module holds the twisted.web.template definitions.