nagare.namespaces package

Submodules

nagare.namespaces.common module

Base class of all the renderers

class nagare.namespaces.common.Renderer

Bases: object

end_rendering(output)

Method call after the rendering of the component

In:
  • output – the rendering tree
generate_id(prefix='')

Generate a random id

In:
  • prefix – prefix of the generated id
new()

Create a new renderer from the same type of this renderer

start_rendering(comp, model)

Method calls before to render a component

In:
  • comp – the component to render
  • model – the view to render

nagare.namespaces.esi module

Edge Server-side Include renderer

class nagare.namespaces.esi.Renderer(parent=None)

Bases: nagare.namespaces.xml.XmlRenderer

The ESI renderer

attempt

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

choose

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

comment

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

esi(text)

Generate a esi comment element

In:
  • text – comment text
Return:
  • the comment element
except_

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

include

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

inline

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

otherwise

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

remove

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

try_

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

vars

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

when

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

nagare.namespaces.xhtml module

The XHTML renderer

This renderer is dedicated to the Nagare framework

class nagare.namespaces.xhtml.A

Bases: nagare.namespaces.xhtml._HTMLActionTag

<a> tags

async_action(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?
sync_action(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 nagare.namespaces.xhtml.AsyncHeadRenderer(static_url)

Bases: nagare.namespaces.xhtml.HeadRenderer

class nagare.namespaces.xhtml.AsyncRenderer(parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/', async_header=False)

Bases: nagare.namespaces.xhtml.Renderer

The XHTML asynchronous renderer

AsyncRenderer(*args, **kw)

Create an associated asynchronous HTML renderer

Return:
  • a new asynchronous renderer
SyncRenderer(*args, **kw)

Create an associated synchronous HTML renderer

Return:
  • a new synchronous renderer
action(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?
end_rendering(output)

Method called after a component is rendered

In:
  • output – rendered tree
Out:
  • rendered tree
get_async_root()
head_renderer_factory

alias of AsyncHeadRenderer

javascript_url(url)
start_rendering(component, model)
class nagare.namespaces.xhtml.CheckboxInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=checkbox attributes

async_action(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?
selected(flag)

(de)Select the tag

In:
  • flag – boolean to deselect / select the tag
Return:
  • self
class nagare.namespaces.xhtml.FileInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=file attributes

async_action(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?
init(renderer)

Initialisation

In:
  • renderer – the current renderer
Return:
  • self
class nagare.namespaces.xhtml.Form

Bases: nagare.namespaces.xhtml_base._HTMLTag

The <form> tag

add_child(child)

Add a child to this <form> tag

Delete the existing <form> tags in the child tree

init(renderer)

Initialisation

In:
  • renderer – the current renderer
Return:
  • self
post_action(*args, **kw)
pre_action(*args, **kw)
class nagare.namespaces.xhtml.HeadRenderer(static_url)

Bases: nagare.namespaces.xhtml_base.HeadRenderer

The XHTML head Renderer

This renderer knows about the static contents of the application

css(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:
  • ()
css_url(url, **kw)

Memorize a css style URL

In:
  • url – the css style URL
  • kw – attributes of the generated <link> tag
Return:
  • ()
javascript(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:
  • ()
javascript_url(url, **kw)

Memorize a javascript URL

In:
  • url – the javascript URL
  • kw – attributes of the the generated <script> tag
Return:
  • ()
class nagare.namespaces.xhtml.HiddenInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=hidden attributes

async_action(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 nagare.namespaces.xhtml.ImageInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=image attributes

add_child(child)

Add attributes to the image input

In:
  • child – attributes dictionary
class nagare.namespaces.xhtml.Img

Bases: nagare.namespaces.xhtml._HTMLActionTag

<img> tags

add_child(child)

Add attributes to the image

In:
  • child – attributes dictionary
async_action(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
sync_action(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 nagare.namespaces.xhtml.Label

Bases: nagare.namespaces.xhtml_base._HTMLTag

<label> tags

init(renderer)

Initialisation

In:
  • renderer – the current renderer
Return:
  • self
class nagare.namespaces.xhtml.Option

Bases: nagare.namespaces.xhtml_base._HTMLTag

<options> tags

selected(values)

(de)Select the tags

In:
  • values – name or list of names of the tags to select
Return:
  • self
class nagare.namespaces.xhtml.PasswordInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=password attributes

async_action(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 nagare.namespaces.xhtml.RadioInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=radio attributes

async_action(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?
selected(flag)

(de)Select the tag

In:
  • flag – boolean to deselect / select the tag
Return:
  • self
class nagare.namespaces.xhtml.Renderer(parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/')

Bases: nagare.namespaces.xhtml_base.Renderer

The XHTML synchronous renderer

AsyncRenderer(*args, **kw)

Create an associated asynchronous HTML renderer

Return:
  • a new asynchronous renderer
HTML_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
SyncRenderer(*args, **kw)

Create an associated synchronous HTML renderer

Return:
  • a new synchronous renderer
XML_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
a

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

action(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?
add_sessionid_in_form(form)

Add the session and continuation ids into a <form>

Forward this call to the sessions manager

In:
  • form – the form tag
add_sessionid_in_url(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
area

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

button

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

classmethod class_init(specialTags)

Class initialisation

In:
special_tags – tags that have a special factory
content_type

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
decorate_error(element, error)

During the rendering, highlight an element that has an error

In:
  • element – the element in error
  • error – the error text
doctype

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
form

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

head_renderer_factory

alias of HeadRenderer

img

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

input

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

label

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

makeelement(tag)

Make a tag

In:
  • tag – name of the tag to create
Return:
  • the new tag
option

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

parse_html(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
parse_xml(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
register_callback(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
script

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

select

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

start_rendering(component, model)

Method called before to render a component

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

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

textarea

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

class nagare.namespaces.xhtml.Script

Bases: nagare.namespaces.xhtml_base._HTMLTag

class nagare.namespaces.xhtml.Select

Bases: nagare.namespaces.xhtml._HTMLActionTag

<select> tags

action(*args, **kw)
async_action(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?
classmethod normalize_input(action, args, v, **kw)
classmethod normalize_input_with_request(action, args, request, response, v, **kw)
class nagare.namespaces.xhtml.Style

Bases: nagare.namespaces.xhtml_base._HTMLTag

class nagare.namespaces.xhtml.SubmitInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

<input> tags with type=submit attributes

class nagare.namespaces.xhtml.TextArea

Bases: nagare.namespaces.xhtml._HTMLActionTag

<textarea> tags

action(*args, **kw)
async_action(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?
classmethod clean_input(action, args, v, **kw)
classmethod clean_input_with_request(action, args, request, response, v, **kw)
class nagare.namespaces.xhtml.TextInput

Bases: nagare.namespaces.xhtml._HTMLActionTag

Dispatcher class for all the <input> tags

async_action(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?
nagare.namespaces.xhtml.absolute_url(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
nagare.namespaces.xhtml.add_ajax_attribute(self, name, value)

Add an attribute with a ajax.Update value

In:
  • self – the tag
  • name – name of the attribute
  • valueajax.Update value
nagare.namespaces.xhtml.add_attribute(next_method, self, name, value)
nagare.namespaces.xhtml.add_function_attribute(self, name, value)

Add an attribute with a function value

In:
  • self – the tag
  • name – name of the attribute
  • value – function value
nagare.namespaces.xhtml.add_js_attribute(self, name, value)

Add an attribute with a ajax.JS value

In:
  • self – the tag
  • name – name of the attribute
  • valueajax.JS value
nagare.namespaces.xhtml.add_method_attribute(self, name, value)

Add an attribute with a method value

In:
  • self – the tag
  • name – name of the attribute
  • value – method value
nagare.namespaces.xhtml.add_script_child(next_method, self, script)

Add a <script> to a tag

In:
  • self – the tag
  • script – the script to add
nagare.namespaces.xhtml.add_style_child(next_method, self, style)

Add a <style> to a tag

In:
  • self – the tag
  • style – the style to add
nagare.namespaces.xhtml.render(self, h, *args)

Generate the <head> tree

In:
  • hnot used
Return:
  • the <head> tree
nagare.namespaces.xhtml.render_async_head(self, h, *args)

Generate a javascript view of the head

In:
  • h – the current renderer
Return:
  • a javascript string

nagare.namespaces.xhtml5 module

The XHTML5 renderer

class nagare.namespaces.xhtml5.AsyncRenderer(parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/', async_header=False)

Bases: nagare.namespaces.xhtml.AsyncRenderer, nagare.namespaces.xhtml5.Renderer

The XHTML5 asynchronous renderer

SyncRenderer(*args, **kw)

Create an associated synchronous HTML renderer

Return:
  • a new synchronous renderer
class nagare.namespaces.xhtml5.Input

Bases: nagare.namespaces.xhtml._HTMLActionTag

Class of all the new input types of HTML5

async_action(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 nagare.namespaces.xhtml5.ObsoleteTagProp(name, authorized_attribs=None, factory=None)

Bases: nagare.namespaces.xml.TagProp

Class of all the HTML4 tags obsolete in HTML5

class nagare.namespaces.xhtml5.Renderer(parent=None, session=None, request=None, response=None, static_url='', static_path='', url='/')

Bases: nagare.namespaces.xhtml.Renderer

The XHTML5 synchronous renderer

AsyncRenderer(*args, **kw)

Create an associated asynchronous HTML renderer

Return:
  • a new asynchronous renderer
HTML_DOCTYPE = '<!DOCTYPE html>'
XML_DOCTYPE = '<!DOCTYPE html>'
acronym

Class of all the HTML4 tags obsolete in HTML5

applet

Class of all the HTML4 tags obsolete in HTML5

article

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

aside

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

audio

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

basefont

Class of all the HTML4 tags obsolete in HTML5

big

Class of all the HTML4 tags obsolete in HTML5

canvas

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

center

Class of all the HTML4 tags obsolete in HTML5

classmethod class_init(specialTags)

Class initialisation

In:
special_tags – tags that have a special factory
command

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

datalist

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

details

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

dir

Class of all the HTML4 tags obsolete in HTML5

embed

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

figcaption

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

figure

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

font

Class of all the HTML4 tags obsolete in HTML5

footer

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

frame

Class of all the HTML4 tags obsolete in HTML5

frameset

Class of all the HTML4 tags obsolete in HTML5

header

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

hgroup

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

input_type = 'color'
isindex

Class of all the HTML4 tags obsolete in HTML5

keygen

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

main

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

mark

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

meta

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

meter

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

nav

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

noframes

Class of all the HTML4 tags obsolete in HTML5

output

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

progress

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

rp

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

rt

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

ruby

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

section

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

source

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

strike

Class of all the HTML4 tags obsolete in HTML5

summary

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

time

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

track

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

tt

Class of all the HTML4 tags obsolete in HTML5

video

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

wbr

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

class nagare.namespaces.xhtml5.Source

Bases: nagare.namespaces.xhtml_base._HTMLTag

The <source> tag

add_child(child)

Add child and attributes

nagare.namespaces.xhtml_base module

The XHTML renderer

This renderer only depends of the nagare.namespaces.xml module. Having not dependencies to the framework make it suitable to be used in others frameworks.

class nagare.namespaces.xhtml_base.HeadRenderer(parent=None)

Bases: nagare.namespaces.xml.XmlRenderer

The XHTML head Renderer

This renderer knows about the possible tags of a html <head>

base

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

classmethod class_init(specialTags)

Class initialisation

In:
special_tags – tags that have a special factory
head

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

meta

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

script

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

style

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

title

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

class nagare.namespaces.xhtml_base.Renderer(parent=None, **kw)

Bases: nagare.namespaces.xml.XmlRenderer

a

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

abbr

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

acronym

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

address

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

allattrs = ('id', 'class', 'style', 'title', 'lang', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmousemove', 'onmouseover', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup')
applet

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

area

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

b

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

basefont

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

bdo

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

big

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

blockquote

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

body

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

br

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

button

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

caption

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

cellhalignattrs = ('align', 'char', 'charoff')
cellvalignattrs = ('valign',)
center

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

cite

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

classmethod class_init(specialTags)

Class initialisation

In:
special_tags – tags that have a special factory
code

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

col

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

colgroup

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

componentattrs = ('id', 'class', 'style', 'title')
dd

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

del_

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

dfn

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

dir

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

div

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

dl

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

dt

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

em

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

embed

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

eventattrs = ('onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmousemove', 'onmouseover', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup')
fieldset

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

focusattrs = ('accesskey', 'tabindex', 'onfocus', 'onblur')
font

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

form

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

frame

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

frameset

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h1

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h2

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h3

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h4

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h5

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

h6

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

head_renderer_factory

alias of HeadRenderer

hr

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

html

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

i

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

i18nattrs = ('lang', 'dir')
iframe

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

img

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

input

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

ins

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

isindex

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

kbd

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

label

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

legend

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

li

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

makeelement(tag)

Make a tag

In:
  • tag – name of the tag to create
Return:
  • the new tag
map

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

menu

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

noframes

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

noscript

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

object

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

ol

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

optgroup

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

option

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

p

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

param

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

parse_html(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
parse_htmlstring(text, fragment=False, no_leading_text=False, xhtml=False, **kw)

Parse a (X)HTML string

In:
  • text – can be a str or unicode strings
  • 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
pre

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

q

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

s

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

samp

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

script

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

select

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

small

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

span

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

strike

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

strong

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

style

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

sub

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

sup

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

table

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

tbody

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

td

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

textarea

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

tfoot

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

th

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

thead

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

tr

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

tt

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

u

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

ul

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

var

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

nagare.namespaces.xhtml_base.add_attribute(next_method, self, name, value)
nagare.namespaces.xhtml_base.add_child(next_method, self, element)

Add a tag to a tag

In:
  • self – the tag
  • element – the tag to add

nagare.namespaces.xml module

XML renderer

class nagare.namespaces.xml.Renderer(parent=None)

Bases: nagare.namespaces.xml.XmlRenderer

The XML Renderer

This renderer generate any tags you give

>>> xml = xml.Renderer()
>>> xml.foo(xml.bar).write_xmlstring()
'<foo><bar/></foo>'
class nagare.namespaces.xml.RendererMetaClass

Bases: type

Meta class for the renderer class

Discover the tags that have a special factory and pass them to the class_init() method of the class

class nagare.namespaces.xml.TagProp(name, authorized_attribs=None, factory=None)

Bases: object

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

class nagare.namespaces.xml.XmlRenderer(parent=None)

Bases: nagare.namespaces.common.Renderer

The base class of all the renderers that generate a XML dialect

classmethod class_init(special_tags)

Class initialisation

In:
special_tags – tags that have a special factory
comment(text='')

Create a comment element

In:
  • text – text of the comment
Return:
  • the new comment element
content_type = 'text/xml'
default_namespace

Return the default_namespace

Return:
  • the default namespace or None if no default namespace was set
doctype = ''
enter(current)

A new tag is pushed by a with statement

In:
  • current – the tag
Return:
  • current
exit()

End of a with statement

makeelement(tag)

Make a tag, in the default namespace set

In:
  • tag – name of the tag to create
Return:
  • the new tag
parse_xml(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
parse_xmlstring(text, fragment=False, no_leading_text=False, **kw)

Parse a XML string

In:
  • text – can be a str or unicode string
  • 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
processing_instruction(target, text=None, **kw)

Create a processing instruction element

In:
  • target – the PI target
  • text – the PI text
  • kw – pseudo attributes
Return:
  • the new processing instruction element
root

Return the first tag(s) sent to the renderer

Warning

A list of tags can be returned

Return:
  • the tag(s)
nagare.namespaces.xml.add_attribute(self, name, value)

Default method to add an attribute to a tag

In:
  • self – the tag
  • name – name of the attribute to add
  • value – value of the attribute to add
nagare.namespaces.xml.add_child(self, o)

Default method to add an object to a tag

In:
  • self – the tag
  • o – object to add

Try to add the result of o.render() to the tag

nagare.namespaces.xsl module

XSL renderer

class nagare.namespaces.xsl.Renderer(parent=None)

Bases: nagare.namespaces.xml.XmlRenderer

The XSL renderer

apply_imports

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

apply_templates

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

attribute

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

attribute_set

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

call_template

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

choose

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

comment

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

content_type = 'text/xsl'
copy

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

copy_of

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

decimal_format

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

element

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

fallback

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

for_each

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

if_

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

import_

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

include

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

key

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

message

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

namespace_alias

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

number

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

otherwise

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

output

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

param

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

preserve_space

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

processing_instruction

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

sort

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

strip_space

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

stylesheet

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

template

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

text

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

transform

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

value_of

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

variable

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

when

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

with_param

Tag factory with a behavior of an object attribute

Each time this attribute is read, a new tag is created

Module contents