firmant.routing.components

Predefined path components for use with URLMapper.

Each of these pre-built components is meant for exactly one use case. The attributes (both free and bound) are shown, and then the various behaviors are shown. All should be self-explanatory.

TYPE

>>> TYPE('post').attributes
set(['type'])
>>> TYPE('post').bound_attributes
{'type': 'post'}
>>> TYPE('post').free_attributes
set([])

>>> TYPE('post').match(type='post')
True
>>> TYPE('post').match(type='tag')
False

YEAR

>>> YEAR.attributes
set(['year'])
>>> YEAR.bound_attributes
{}
>>> YEAR.free_attributes
set(['year'])

>>> YEAR.construct(year=2010)
'2010'
>>> YEAR.construct(year=4)
'0004'

MONTH

>>> MONTH.attributes
set(['month'])
>>> MONTH.bound_attributes
{}
>>> MONTH.free_attributes
set(['month'])

>>> MONTH.construct(month=10)
'10'
>>> MONTH.construct(month=3)
'03'

DAY

>>> DAY.attributes
set(['day'])
>>> DAY.bound_attributes
{}
>>> DAY.free_attributes
set(['day'])

>>> DAY.construct(day=15)
'15'
>>> DAY.construct(day=1)
'01'

SLUG

>>> SLUG.attributes
set(['slug'])
>>> SLUG.bound_attributes
{}
>>> SLUG.free_attributes
set(['slug'])

>>> SLUG.construct(slug='foobar')
'foobar'

PATH

>>> PATH.attributes
set(['path'])
>>> PATH.bound_attributes
{}
>>> PATH.free_attributes
set(['path'])

>>> PATH.construct(path='foo/bar')
'foo/bar'

PAGENO

>>> PAGENO.attributes
set(['page'])
>>> PAGENO.bound_attributes
{}
>>> PAGENO.free_attributes
set(['page'])

>>> PAGENO.construct(page=1) is None
True
>>> PAGENO.construct(page=2)
'page2'

Functions

firmant.routing.components._page_conv(value)
Conversion function for page numbers.

Table Of Contents

Previous topic

firmant.routing.components

Next topic

firmant.settings

This Page