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('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.attributes
set(['year'])
>>> YEAR.bound_attributes
{}
>>> YEAR.free_attributes
set(['year'])
>>> YEAR.construct(year=2010)
'2010'
>>> YEAR.construct(year=4)
'0004'
>>> MONTH.attributes
set(['month'])
>>> MONTH.bound_attributes
{}
>>> MONTH.free_attributes
set(['month'])
>>> MONTH.construct(month=10)
'10'
>>> MONTH.construct(month=3)
'03'
>>> DAY.attributes
set(['day'])
>>> DAY.bound_attributes
{}
>>> DAY.free_attributes
set(['day'])
>>> DAY.construct(day=15)
'15'
>>> DAY.construct(day=1)
'01'
>>> SLUG.attributes
set(['slug'])
>>> SLUG.bound_attributes
{}
>>> SLUG.free_attributes
set(['slug'])
>>> SLUG.construct(slug='foobar')
'foobar'
>>> PATH.attributes
set(['path'])
>>> PATH.bound_attributes
{}
>>> PATH.free_attributes
set(['path'])
>>> PATH.construct(path='foo/bar')
'foo/bar'
>>> PAGENO.attributes
set(['page'])
>>> PAGENO.bound_attributes
{}
>>> PAGENO.free_attributes
set(['page'])
>>> PAGENO.construct(page=1) is None
True
>>> PAGENO.construct(page=2)
'page2'