nti.contentfragments.schema module

Helper classes to use content fragments in zope.interface or zope.schema declarations.

class nti.contentfragments.schema.HTMLContentFragment(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.TextUnicodeContentFragment

A Text type that also requires the object implement an interface descending from IHTMLContentFragment.

Pass the keyword arguments for zope.schema.Text to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide IHTMLContentFragment, one will be created simply by copying; no validation or transformation will occur.

class nti.contentfragments.schema.LatexFragmentTextLine(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.TextLineUnicodeContentFragment

A TextLine that requires content to be in LaTeX format.

Pass the keyword arguments for TextLine to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide ILatexContentFragment, one will be created simply by copying; no validation or transformation will occur.

class nti.contentfragments.schema.PlainText(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.TextUnicodeContentFragment

A zope.schema.Text that requires content to be plain text.

Pass the keyword arguments for Text to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide IPlainTextContentFragment, one will be created simply by copying; no validation or transformation will occur.

Caution

This will perform conversions on the input data, stripping things that “look like” HTML, if it does not already implement the required interface.

class nti.contentfragments.schema.PlainTextLine(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.TextLineUnicodeContentFragment

A TextLine that requires content to be plain text.

Pass the keyword arguments for TextLine to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide ILatexContentFragment, one will be created simply by copying; no validation or transformation will occur.

Caution

This will perform conversions on the input data, stripping things that “look like” HTML, if it does not already implement the required interface.

class nti.contentfragments.schema.RstContentFragment(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.TextUnicodeContentFragment

A zope.schema.Text type that also requires the object implement an interface descending from IRstContentFragment. Note that currently this does no validation of the content to ensure it is valid reStructuredText.

Pass the keyword arguments for zope.schema.Text to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide IRstContentFragment, one will be created simply by copying; no validation or transformation will occur.

fromUnicode(value)[source]

We implement IFromUnicode by adapting the given object to our text schema.

This happens after unicode normalization.

class nti.contentfragments.schema.SanitizedHTMLContentFragment(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.HTMLContentFragment

A Text type that also requires the object implement an interface descending from ISanitizedHTMLContentFragment. Note that the default adapter for this can actually produce IPlainTextContentFragment if there is no HTML present in the input.

Pass the keyword arguments for zope.schema.Text to the constructor; the schema argument for Object is already handled.

Note

If you provide a default string that does not already provide ISanitizedHTMLContentFragment, one will be created simply by copying; no validation or transformation will occur.

class nti.contentfragments.schema.Tag(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.PlainTextLine

Requires its content to be only one plain text word that is lowercased.

fromUnicode(value)[source]

We implement IFromUnicode by adapting the given object to our text schema.

This happens after unicode normalization.

class nti.contentfragments.schema.TextLineUnicodeContentFragment(*args, **kwargs)[source]

Bases: nti.contentfragments.schema._FromUnicodeMixin, nti.schema.field.Object, nti.schema.field.ValidTextLine

A zope.schema.TextLine type that also requires the object implement an interface descending from IUnicodeContentFragment.

Pass the keyword arguments for zope.schema.TextLine to the constructor; the schema argument for Object is already handled.

If you pass neither a default nor defaultFactory argument, a defaultFactory argument will be provided to construct an empty content fragment.

Caution

This will perform conversions on the input data, stripping or adjusting things that “look like” HTML, if it does not already implement the required interface; the actual value is likely to be a ISanitizedHTMLContentFragment or a IPlainTextContentFragment.

class nti.contentfragments.schema.TextUnicodeContentFragment(*args, **kwargs)[source]

Bases: nti.contentfragments.schema._FromUnicodeMixin, nti.schema.field.Object, nti.schema.field.ValidText

A zope.schema.Text type that also requires the object implement an interface descending from IUnicodeContentFragment.

Pass the keyword arguments for zope.schema.Text to the constructor; the schema argument for Object is already handled.

Caution

This will perform conversions on the input data, stripping or adjusting things that “look like” HTML, if it does not already implement the required interface; the actual value is likely to be a ISanitizedHTMLContentFragment or a IPlainTextContentFragment.

class nti.contentfragments.schema.VerbatimPlainText(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.PlainText

Like PlainText, except instead of running a conversion on the input data, stripping HTML, will simply assume that the input data is already meant to be plain text and will preserve markup as-is.

class nti.contentfragments.schema.VerbatimPlainTextLine(*args, **kwargs)[source]

Bases: nti.contentfragments.schema.PlainTextLine

Like PlainTextLine, except instead of running a conversion on the input data, stripping HTML, will simply assume that the input data is already meant to be plain text and will preserve markup as-is.

nti.contentfragments.schema.Title()[source]

Return a zope.schema.interfaces.IField representing the standard title of some object. This should be stored in the title field.