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 fromIHTMLContentFragment
.Pass the keyword arguments for
zope.schema.Text
to the constructor; theschema
argument forObject
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; theschema
argument forObject
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; theschema
argument forObject
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; theschema
argument forObject
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 fromIRstContentFragment
. 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; theschema
argument forObject
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.
-
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 fromISanitizedHTMLContentFragment
. Note that the default adapter for this can actually produceIPlainTextContentFragment
if there is no HTML present in the input.Pass the keyword arguments for
zope.schema.Text
to the constructor; theschema
argument forObject
is already handled.Note
If you provide a
default
string that does not already provideISanitizedHTMLContentFragment
, 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.
-
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 fromIUnicodeContentFragment
.Pass the keyword arguments for
zope.schema.TextLine
to the constructor; theschema
argument forObject
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 aIPlainTextContentFragment
.
-
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 fromIUnicodeContentFragment
.Pass the keyword arguments for
zope.schema.Text
to the constructor; theschema
argument forObject
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 aIPlainTextContentFragment
.
-
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.