Module xhtml

The XHTML renderer

This renderer is dedicated to the Nagare framework

Imports:
__future__, imghdr, lxml, nagare, nagare.namespaces, nagare.namespaces.xml, operator, peak.rules, types, webob
Classes:
A(_HTMLActionTag): <a> tags
AsyncHeadRenderer(HeadRenderer):
AsyncRenderer(Renderer): The XHTML asynchronous renderer
CheckboxInput(_HTMLActionTag): <input> tags with type=checkbox attributes
FileInput(_HTMLActionTag): <input> tags with type=file attributes
Form(xhtml_base._HTMLTag): The <form> tag
HeadRenderer(xhtml_base.HeadRenderer): The XHTML head Renderer
HiddenInput(_HTMLActionTag): <input> tags with type=hidden attributes
ImageInput(_HTMLActionTag): <input> tags with type=image attributes
Img(_HTMLActionTag): <img> tags
Label(xhtml_base._HTMLTag): <label> tags
Option(xhtml_base._HTMLTag): <options> tags
PasswordInput(_HTMLActionTag): <input> tags with type=password attributes
RadioInput(_HTMLActionTag): <input> tags with type=radio attributes
Renderer(xhtml_base.Renderer): The XHTML synchronous renderer
Script(xhtml_base._HTMLTag):
Select(_HTMLActionTag): <select> tags
Style(xhtml_base._HTMLTag):
SubmitInput(_HTMLActionTag): <input> tags with type=submit attributes
TextArea(_HTMLActionTag): <textarea> tags
TextInput(_HTMLActionTag): Dispatcher class for all the <input> tags
_HTMLActionTag(xhtml_base._HTMLTag): Base class of all the tags with a .action() method
Methods:
absolute_url(url, static): Convert a relative URL of a static content to an absolute one
add_attribute(self, name, value): Add an attribute with a ajax.Update value
add_attribute(self, name, value): Add an attribute with a function value
add_attribute(self, name, value): Add an attribute with a method value
add_attribute(self, name, value): Add an attribute with a ajax.JS value
add_attribute(next_method, self, name, value):
add_child(next_method, self, script): Add a <script> to a tag
add_child(next_method, self, style): Add a <style> to a tag
render(self, h, *args): Generate the <head> tree
render(self, h, *args): Generate a javascript view of the head
Attributes:
h = Renderer()
t = ((1, 'a'), (2, 'b'), (3, 'c'))

Class xhtml.A

Back to xhtml

Bases:
_HTMLActionTag

<a> tags

Methods:
async_action(self, renderer, action, with_request): Register an asynchronous action
sync_action(self, renderer, action, with_request): Register a synchronous action
Attributes:
_actions = (41, None, 'onclick')
_async_action = async_action

Method xhtml.A.async_action

Back to xhtml.A

Arguments:
self, renderer, action, with_request

Register an asynchronous action

In:
  • renderer -- the current renderer
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Method xhtml.A.sync_action

Back to xhtml.A

Arguments:
self, renderer, action, with_request

Register a synchronous action

In:
  • renderer -- the current renderer
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Class xhtml.AsyncHeadRenderer

Back to xhtml

Bases:
HeadRenderer
Methods:
__init__(self, static_url): Renderer initialisation
_css(self, style): Memorize an in-line anonymous css style
_get_anonymous_css(self): Return the list of the in-line anonymous css styles, sorted by order of insertion
_get_anonymous_javascript(self): Return the list of anonymous javascript codes, sorted by order of insertion
_javascript(self, script): Memorize an in-line anonymous javascript code
_script(self, append, tag, script):
_style(self, append, tag, style):

Method xhtml.AsyncHeadRenderer.__init__

Back to xhtml.AsyncHeadRenderer

Arguments:
self, static_url

Renderer initialisation

The HeadRenderer keeps track of the javascript and css used by every views, to be able to concatenate them into the <head> section.


Method xhtml.AsyncHeadRenderer._css

Back to xhtml.AsyncHeadRenderer

Arguments:
self, style

Memorize an in-line anonymous css style

In:
  • style -- the css style

Method xhtml.AsyncHeadRenderer._get_anonymous_css

Back to xhtml.AsyncHeadRenderer

Arguments:
self

Return the list of the in-line anonymous css styles, sorted by order of insertion

Return:
  • list of css styles

Method xhtml.AsyncHeadRenderer._get_anonymous_javascript

Back to xhtml.AsyncHeadRenderer

Arguments:
self

Return the list of anonymous javascript codes, sorted by order of insertion

Return:
  • list of javascript codes

Method xhtml.AsyncHeadRenderer._javascript

Back to xhtml.AsyncHeadRenderer

Arguments:
self, script

Memorize an in-line anonymous javascript code

In:
  • script -- the javascript code

Class xhtml.AsyncRenderer

Back to xhtml

Bases:
Renderer

The XHTML asynchronous renderer

Methods:
AsyncRenderer(self, *args, **kw): Create an associated asynchronous HTML renderer
SyncRenderer(self, *args, **kw): Create an associated synchronous HTML renderer
__init__(self, parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/', async_header=False): Renderer initialisation
_css(self, style):
_javascript(self, js):
action(self, tag, action, with_request): Register an asynchronous action on a tag
end_rendering(self, output): Method called after a component is rendered
get_async_root(self):
javascript_url(self, url):
start_rendering(self, component, model):
Attributes:
head_renderer_factory = AsyncHeadRenderer

Method xhtml.AsyncRenderer.AsyncRenderer

Back to xhtml.AsyncRenderer

Arguments:
self, *args, **kw

Create an associated asynchronous HTML renderer

Return:
  • a new asynchronous renderer

Method xhtml.AsyncRenderer.SyncRenderer

Back to xhtml.AsyncRenderer

Arguments:
self, *args, **kw

Create an associated synchronous HTML renderer

Return:
  • a new synchronous renderer

Method xhtml.AsyncRenderer.__init__

Back to xhtml.AsyncRenderer

Arguments:
self, parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/', async_header=False

Renderer initialisation

In:
  • parent -- parent renderer
  • session -- the session object
  • request -- the request object
  • response -- the response object
  • static_url -- url of the static contents of the application
  • static_path -- path of the static contents of the application
  • url -- url prefix of the application
  • async_header -- is the head renderer to create a synchronous or an asynchronous one?

Method xhtml.AsyncRenderer.action

Back to xhtml.AsyncRenderer

Arguments:
self, tag, action, with_request

Register an asynchronous action on a tag

In:
  • tag -- the tag
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Method xhtml.AsyncRenderer.end_rendering

Back to xhtml.AsyncRenderer

Arguments:
self, output

Method called after a component is rendered

In:
  • output -- rendered tree
Out:
  • rendered tree

Class xhtml.CheckboxInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=checkbox attributes

Methods:
selected(self, flag): (de)Select the tag
Attributes:
_actions = (1, 'name', 'onclick')
async_action = _HTMLActionTag.sync_action

Method xhtml.CheckboxInput.selected

Back to xhtml.CheckboxInput

Arguments:
self, flag

(de)Select the tag

In:
  • flag -- boolean to deselect / select the tag
Return:
  • self

Class xhtml.FileInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=file attributes

Methods:
init(self, renderer): Initialisation
Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Method xhtml.FileInput.init

Back to xhtml.FileInput

Arguments:
self, renderer

Initialisation

In:
  • renderer -- the current renderer
Return:
  • self

Class xhtml.Form

Back to xhtml

Bases:
xhtml_base._HTMLTag

The <form> tag

Methods:
_action(self, action, priority, args, with_request, permissions, subject, **kw): Register an action
add_child(self, child): Add a child to this <form> tag
init(self, renderer): Initialisation
post_action(self, action, args, with_request=False, permissions=None, subject=None, **kw): Register an action that will be executed after the actions of the form elements
pre_action(self, action, args, with_request=False, permissions=None, subject=None, **kw): Register an action that will be executed before the actions of the form elements

Method xhtml.Form._action

Back to xhtml.Form

Arguments:
self, action, priority, args, with_request, permissions, subject, **kw

Register an action

In:
  • action -- action
  • priority - action priority
  • args, kw -- action parameters
  • with_request -- will the request and response objects be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self

Method xhtml.Form.add_child

Back to xhtml.Form

Arguments:
self, child

Add a child to this <form> tag

Delete the existing <form> tags in the child tree


Method xhtml.Form.init

Back to xhtml.Form

Arguments:
self, renderer

Initialisation

In:
  • renderer -- the current renderer
Return:
  • self

Method xhtml.Form.post_action

Back to xhtml.Form

Arguments:
self, action, args, with_request=False, permissions=None, subject=None, **kw

Register an action that will be executed after the actions of the form elements

In:
  • action -- action
  • args, kw -- action parameters
  • with_request -- will the request and response object be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self
Decorators:
@partial.max_number_of_args(2)

Method xhtml.Form.pre_action

Back to xhtml.Form

Arguments:
self, action, args, with_request=False, permissions=None, subject=None, **kw

Register an action that will be executed before the actions of the form elements

In:
  • action -- action
  • args, kw -- action parameters
  • with_request -- will the request and response objects be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self
Decorators:
@partial.max_number_of_args(2)

Class xhtml.HeadRenderer

Back to xhtml

Bases:
xhtml_base.HeadRenderer

The XHTML head Renderer

This renderer knows about the static contents of the application

Methods:
__init__(self, static_url): Renderer initialisation
_get_css_url(self): Return the list of css URLs, sorted by order of insertion
_get_javascript_url(self): Return the list of javascript URLs, sorted by order of insertion
_get_named_css(self): Return the list of the in-line named css styles, sorted by order of insertion
_get_named_javascript(self): Return the list of named javascript codes, sorted by order of insertion
_script(self, append, tag, script):
_style(self, append, tag, style):
css(self, name, style, **kw): Memorize an in-line named css style
css_url(self, url, **kw): Memorize a css style URL
javascript(self, name, script, **kw): Memorize an in-line named javascript code
javascript_url(self, url, **kw): Memorize a javascript URL

Method xhtml.HeadRenderer.__init__

Back to xhtml.HeadRenderer

Arguments:
self, static_url

Renderer initialisation

The HeadRenderer keeps track of the javascript and css used by every views, to be able to concatenate them into the <head> section.


Method xhtml.HeadRenderer._get_css_url

Back to xhtml.HeadRenderer

Arguments:
self

Return the list of css URLs, sorted by order of insertion

Return:
  • list of css (URLs, attributes)

Method xhtml.HeadRenderer._get_javascript_url

Back to xhtml.HeadRenderer

Arguments:
self

Return the list of javascript URLs, sorted by order of insertion

Return:
  • list of javascript (URLs, attributes)

Method xhtml.HeadRenderer._get_named_css

Back to xhtml.HeadRenderer

Arguments:
self

Return the list of the in-line named css styles, sorted by order of insertion

Return:
  • list of (name, css style, attributes)

Method xhtml.HeadRenderer._get_named_javascript

Back to xhtml.HeadRenderer

Arguments:
self

Return the list of named javascript codes, sorted by order of insertion

Return:
  • list of (name, javascript code, attributes)

Method xhtml.HeadRenderer.css

Back to xhtml.HeadRenderer

Arguments:
self, name, style, **kw

Memorize an in-line named css style

In:
  • name -- unique name of this css style (to prevent double definition)
  • style -- the css style
  • kw -- attributes of the generated <style> tag
Return:
  • ()

Method xhtml.HeadRenderer.css_url

Back to xhtml.HeadRenderer

Arguments:
self, url, **kw

Memorize a css style URL

In:
  • url -- the css style URL
  • kw -- attributes of the generated <link> tag
Return:
  • ()

Method xhtml.HeadRenderer.javascript

Back to xhtml.HeadRenderer

Arguments:
self, name, script, **kw

Memorize an in-line named javascript code

In:
  • name -- unique name of this javascript code (to prevent double definition)
  • script -- the javascript code
  • kw -- attributes of the generated <script> tag
Return:
  • ()

Method xhtml.HeadRenderer.javascript_url

Back to xhtml.HeadRenderer

Arguments:
self, url, **kw

Memorize a javascript URL

In:
  • url -- the javascript URL
  • kw -- attributes of the the generated <script> tag
Return:
  • ()

Class xhtml.HiddenInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=hidden attributes

Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Class xhtml.ImageInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=image attributes

Methods:
add_child(self, child): Add attributes to the image input
Attributes:
_actions = (5, 'name', 'onclick')

Method xhtml.ImageInput.add_child

Back to xhtml.ImageInput

Arguments:
self, child

Add attributes to the image input

In:
  • child -- attributes dictionary

Class xhtml.Img

Back to xhtml

Bases:
_HTMLActionTag

<img> tags

Methods:
_set_content_type(cls, request, response, _action, with_request): Generate the image and guess its format
add_child(self, child): Add attributes to the image
sync_action(self, renderer, action, with_request): Register a synchronous action
Attributes:
async_action = sync_action

Method xhtml.Img._set_content_type

Back to xhtml.Img

Arguments:
cls, request, response, _action, with_request

Generate the image and guess its format

In:
  • request -- the web request object
  • response -- the web response object
  • action -- function to call to generate the image data
  • with_request -- will the request and response objects be passed to the action?
Return:
  • new response object raised
Decorators:
@classmethod

Method xhtml.Img.add_child

Back to xhtml.Img

Arguments:
self, child

Add attributes to the image

In:
  • child -- attributes dictionary

Method xhtml.Img.sync_action

Back to xhtml.Img

Arguments:
self, renderer, action, with_request

Register a synchronous action

The action will have to return the image data

In:
  • renderer -- the current renderer
  • action -- action
  • with_request -- will the request and response objects be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on

Class xhtml.Label

Back to xhtml

Bases:
xhtml_base._HTMLTag

<label> tags

Methods:
init(self, renderer): Initialisation

Method xhtml.Label.init

Back to xhtml.Label

Arguments:
self, renderer

Initialisation

In:
  • renderer -- the current renderer
Return:
  • self

Class xhtml.Option

Back to xhtml

Bases:
xhtml_base._HTMLTag

<options> tags

Methods:
selected(self, values): (de)Select the tags

Method xhtml.Option.selected

Back to xhtml.Option

Arguments:
self, values

(de)Select the tags

In:
  • values -- name or list of names of the tags to select
Return:
  • self

Class xhtml.PasswordInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=password attributes

Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Class xhtml.RadioInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=radio attributes

Methods:
selected(self, flag): (de)Select the tag
Attributes:
_actions = (2, 'value', 'onclick')
async_action = _HTMLActionTag.sync_action

Method xhtml.RadioInput.selected

Back to xhtml.RadioInput

Arguments:
self, flag

(de)Select the tag

In:
  • flag -- boolean to deselect / select the tag
Return:
  • self

Class xhtml.Renderer

Back to xhtml

Bases:
xhtml_base.Renderer

The XHTML synchronous renderer

Methods:
AsyncRenderer(self, *args, **kw): Create an associated asynchronous HTML renderer
SyncRenderer(self, *args, **kw): Create an associated synchronous HTML renderer
__init__(self, parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/'): Renderer initialisation
action(self, tag, action, with_request): Register a synchronous action on a tag
add_sessionid_in_form(self, form): Add the session and continuation ids into a <form>
add_sessionid_in_url(self, u='', params=None, sep='&'): Add the session and continuation ids into an url
class_init(cls, specialTags): Class initialisation
content_type(self): Generate the content type of the document
decorate_error(self, element, error): During the rendering, highlight an element that has an error
doctype(self): Generate the DOCTYPE of the document
makeelement(self, tag): Make a tag
parse_html(self, source, fragment=False, no_leading_text=False, xhtml=False, **kw): Parse a (X)HTML file
parse_xml(self, source, fragment=False, no_leading_text=False, **kw): Parse a XML file
register_callback(self, priority, f, with_request, render=None): Register an action
start_rendering(self, component, model): Method called before to render a component
Attributes:
HTML_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
XML_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
_specialTags = dict(text_input = TextInput, radio_input = RadioInput, checkbox_input = CheckboxInput, submit_input = SubmitInput, hidden_input = HiddenInput, file_input = FileInput, password_input = PasswordInput, image_input = ImageInput)
a = TagProp('a', set(xhtml_base.allattrs + xhtml_base.focusattrs + ('charset', 'type', 'name', 'href', 'hreflang', 'rel', 'rev', 'shape', 'coords', 'target', 'oncontextmenu')), A)
area = TagProp('area', set(xhtml_base.allattrs + xhtml_base.focusattrs + ('shape', 'coords', 'href', 'nohref', 'alt', 'target')), A)
button = TagProp('button', set(xhtml_base.allattrs + xhtml_base.focusattrs + ('name', 'value', 'type', 'disabled')), SubmitInput)
form = TagProp('form', set(xhtml_base.allattrs + ('action', 'method', 'name', 'enctype', 'onsubmit', 'onreset', 'accept_charset', 'target')), Form)
head_renderer_factory = HeadRenderer
img = TagProp('img', set(xhtml_base.allattrs + ('src', 'alt', 'name', 'longdesc', 'width', 'height', 'usemap', 'ismapalign', 'border', 'hspace', 'vspace', 'lowsrc')), Img)
input = TagProp('input', set(xhtml_base.allattrs + xhtml_base.focusattrs + ('type', 'name', 'value', 'checked', 'disabled', 'readonly', 'size', 'maxlength', 'srcalt', 'usemap', 'onselect', 'onchange', 'accept', 'align', 'border')), TextInput)
label = TagProp('label', set(xhtml_base.allattrs + ('for', 'accesskey', 'onfocus', 'onblur')), Label)
option = TagProp('option', set(xhtml_base.allattrs + ('selected', 'disabled', 'label', 'value')), Option)
script = TagProp('script', set(('id', 'charset', 'type', 'language', 'src', 'defer')), Script)
select = TagProp('select', set(xhtml_base.allattrs + ('name', 'size', 'multiple', 'disabled', 'tabindex', 'onfocus', 'onblur', 'onchange', 'rows')), Select)
style = TagProp('style', set(xhtml_base.i18nattrs + ('id', 'type', 'media', 'title')), Style)
textarea = TagProp('textarea', set(xhtml_base.allattrs + xhtml_base.focusattrs + ('name', 'rows', 'cols', 'disabled', 'readonly', 'onselect', 'onchange', 'wrap')), TextArea)

Method xhtml.Renderer.AsyncRenderer

Back to xhtml.Renderer

Arguments:
self, *args, **kw

Create an associated asynchronous HTML renderer

Return:
  • a new asynchronous renderer

Method xhtml.Renderer.SyncRenderer

Back to xhtml.Renderer

Arguments:
self, *args, **kw

Create an associated synchronous HTML renderer

Return:
  • a new synchronous renderer

Method xhtml.Renderer.__init__

Back to xhtml.Renderer

Arguments:
self, parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/'

Renderer initialisation

In:
  • parent -- parent renderer
  • session -- the session object
  • request -- the request object
  • response -- the response object
  • static_url -- url of the static contents of the application
  • static_path -- path of the static contents of the application
  • url -- url prefix of the application

Method xhtml.Renderer.action

Back to xhtml.Renderer

Arguments:
self, tag, action, with_request

Register a synchronous action on a tag

In:
  • tag -- the tag
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Method xhtml.Renderer.add_sessionid_in_form

Back to xhtml.Renderer

Arguments:
self, form

Add the session and continuation ids into a <form>

Forward this call to the sessions manager

In:
  • form -- the form tag

Method xhtml.Renderer.add_sessionid_in_url

Back to xhtml.Renderer

Arguments:
self, u='', params=None, sep='&'

Add the session and continuation ids into an url

Forward this call to the sessions manager

In:
  • u -- the url
  • params -- query string of the url
Return:
  • the completed url

Method xhtml.Renderer.class_init

Back to xhtml.Renderer

Arguments:
cls, specialTags

Class initialisation

In:
-- special_tags -- tags that have a special factory
Decorators:
@classmethod
Classes:
CustomLookup(ET.CustomElementClassLookup):

Class xhtml.Renderer.class_init.CustomLookup

Back to xhtml.Renderer.class_init

Bases:
ET.CustomElementClassLookup
Methods:
__init__(self, specialTags, defaultLookup):
lookup(self, node_type, document, namespace, name):

Method xhtml.Renderer.content_type

Back to xhtml.Renderer

Arguments:
self

Generate the content type of the document

If a content type was set on the response object, use it Else, use the HTML ou XHTML content type of this renderer

Return:
  • the content type
Decorators:
@property

Method xhtml.Renderer.decorate_error

Back to xhtml.Renderer

Arguments:
self, element, error

During the rendering, highlight an element that has an error

In:
  • element -- the element in error
  • error -- the error text

Method xhtml.Renderer.doctype

Back to xhtml.Renderer

Arguments:
self

Generate the DOCTYPE of the document

If a doctype was set on the response object, use it Else, use the HTML ou XHTML doctypes of this renderer

Return:
  • the doctype
Decorators:
@property

Method xhtml.Renderer.makeelement

Back to xhtml.Renderer

Arguments:
self, tag

Make a tag

In:
  • tag -- name of the tag to create
Return:
  • the new tag

Method xhtml.Renderer.parse_html

Back to xhtml.Renderer

Arguments:
self, source, fragment=False, no_leading_text=False, xhtml=False, **kw

Parse a (X)HTML file

In:
  • source -- can be a filename or a file object
  • fragment -- if True, can parse a HTML fragment i.e a HTML without a unique root
  • no_leading_text -- if fragment is True, no_leading_text is False and the HTML to parsed begins by a text, this text is keeped
  • xhtml -- is the HTML to parse a valid XHTML ?
  • kw -- keywords parameters are passed to the HTML parser
Return:
  • the root element of the parsed HTML, if fragment is False
  • a list of HTML elements, if fragment is True

Method xhtml.Renderer.parse_xml

Back to xhtml.Renderer

Arguments:
self, source, fragment=False, no_leading_text=False, **kw

Parse a XML file

In:
  • source -- can be a filename or a file object
  • fragment -- if True, can parse a XML fragment i.e a XML without a unique root
  • no_leading_text -- if fragment is True, no_leading_text is False and the XML to parsed begins by a text, this text is keeped
  • kw -- keywords parameters are passed to the XML parser
Return:
  • the root element of the parsed XML, if fragment is False
  • a list of XML elements, if fragment is True

Method xhtml.Renderer.register_callback

Back to xhtml.Renderer

Arguments:
self, priority, f, with_request, render=None

Register an action

Register the action to the current rendered component

In:
  • priority - -priority of the action
  • f -- the action
  • with_request -- will the request and response objects be passed to the action?
  • render -- render method to generate the view after the f action will be called

Method xhtml.Renderer.start_rendering

Back to xhtml.Renderer

Arguments:
self, component, model

Method called before to render a component

In:
  • component -- component to render
  • model -- name of the view to use

Class xhtml.Select

Back to xhtml

Bases:
_HTMLActionTag

<select> tags

Methods:
action(self, action, args, with_request=False, permissions=None, subject=None, **kw): Register an action
normalize_input(cls, action, args, v, **kw):
normalize_input_with_request(cls, action, args, request, response, v, **kw):
Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Method xhtml.Select.action

Back to xhtml.Select

Arguments:
self, action, args, with_request=False, permissions=None, subject=None, **kw

Register an action

In:
  • action -- action
  • args, kw -- action parameters
  • with_request -- will the request and response object be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self
Decorators:
@partial.max_number_of_args(2)

Class xhtml.SubmitInput

Back to xhtml

Bases:
_HTMLActionTag

<input> tags with type=submit attributes

Attributes:
_actions = (4, 'name', 'onclick')

Class xhtml.TextArea

Back to xhtml

Bases:
_HTMLActionTag

<textarea> tags

Methods:
action(self, action, args, with_request=False, permissions=None, subject=None, **kw): Register an action
clean_input(cls, action, args, v, **kw):
clean_input_with_request(cls, action, args, request, response, v, **kw):
Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Method xhtml.TextArea.action

Back to xhtml.TextArea

Arguments:
self, action, args, with_request=False, permissions=None, subject=None, **kw

Register an action

In:
  • action -- action
  • args, kw -- action parameters
  • with_request -- will the request and response object be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self
Decorators:
@partial.max_number_of_args(2)

Class xhtml.TextInput

Back to xhtml

Bases:
_HTMLActionTag

Dispatcher class for all the <input> tags

Methods:
__call__(self, *children, **attrib):
Attributes:
_actions = (1, 'name', 'onchange')
async_action = _HTMLActionTag.sync_action

Class xhtml._HTMLActionTag

Back to xhtml

Bases:
xhtml_base._HTMLTag

Base class of all the tags with a .action() method

Methods:
action(self, action, args, with_request=False, permissions=None, subject=None, **kw): Register an action
async_action(self, renderer, action, with_request): Register an asynchronous action
sync_action(self, renderer, action, with_request): Register a synchronous action
Attributes:
_async_action = async_action

Method xhtml._HTMLActionTag.action

Back to xhtml._HTMLActionTag

Arguments:
self, action, args, with_request=False, permissions=None, subject=None, **kw

Register an action

In:
  • action -- action
  • args, kw -- action parameters
  • with_request -- will the request and response objects be passed to the action?
  • permissions -- permissions needed to execute the action
  • subject -- subject to test the permissions on
Return:
  • self
Decorators:
@partial.max_number_of_args(2)

Method xhtml._HTMLActionTag.async_action

Back to xhtml._HTMLActionTag

Arguments:
self, renderer, action, with_request

Register an asynchronous action

In:
  • renderer -- the current renderer
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Method xhtml._HTMLActionTag.sync_action

Back to xhtml._HTMLActionTag

Arguments:
self, renderer, action, with_request

Register a synchronous action

In:
  • renderer -- the current renderer
  • action -- action
  • with_request -- will the request and response objects be passed to the action?

Method xhtml.absolute_url

Back to xhtml

Arguments:
url, static

Convert a relative URL of a static content to an absolute one

In:
  • url -- url to convert
  • static -- URL prefix of the static contents
Return:
  • an absolute URL

Method xhtml.add_attribute

Back to xhtml

Arguments:
self, name, value

Add an attribute with a ajax.Update value

In:
  • self -- the tag
  • name -- name of the attribute
  • value -- ajax.Update value
Decorators:
@peak.rules.when(xml.add_attribute, (xml._Tag, basestring, ajax.Update))

Method xhtml.add_attribute

Back to xhtml

Arguments:
self, name, value

Add an attribute with a function value

In:
  • self -- the tag
  • name -- name of the attribute
  • value -- function value
Decorators:
@peak.rules.when(xml.add_attribute, (xml._Tag, basestring, types.FunctionType))

Method xhtml.add_attribute

Back to xhtml

Arguments:
self, name, value

Add an attribute with a method value

In:
  • self -- the tag
  • name -- name of the attribute
  • value -- method value
Decorators:
@peak.rules.when(xml.add_attribute, (xml._Tag, basestring, types.MethodType))

Method xhtml.add_attribute

Back to xhtml

Arguments:
self, name, value

Add an attribute with a ajax.JS value

In:
  • self -- the tag
  • name -- name of the attribute
  • value -- ajax.JS value
Decorators:
@peak.rules.when(xml.add_attribute, (xml._Tag, basestring, ajax.JS))

Method xhtml.add_child

Back to xhtml

Arguments:
next_method, self, script

Add a <script> to a tag

In:
  • self -- the tag
  • script -- the script to add
Decorators:
@peak.rules.when(xml.add_child, (xhtml_base._HTMLTag, Script))

Method xhtml.add_child

Back to xhtml

Arguments:
next_method, self, style

Add a <style> to a tag

In:
  • self -- the tag
  • style -- the style to add
Decorators:
@peak.rules.when(xml.add_child, (xhtml_base._HTMLTag, Style))

Method xhtml.render

Back to xhtml

Arguments:
self, h, *args

Generate the <head> tree

In:
  • h -- not used
Return:
  • the <head> tree
Decorators:
@presentation.render_for(HeadRenderer)

Method xhtml.render

Back to xhtml

Arguments:
self, h, *args

Generate a javascript view of the head

In:
  • h -- the current renderer
Return:
  • a javascript string
Decorators:
@presentation.render_for(AsyncHeadRenderer)