Mercurial > piecrust2
comparison piecrust/sources/base.py @ 226:e9dc18a275ff
data: Add ability for `IPaginationSource`s to specify how to get settings.
The `IPaginationSource` has a new `getSettingAccessor` method that returns how
to access settings values on items in the pagination source. A default accessor
is also available, which uses standard attribute lookup.
Also clean some stuff in `LazyPageConfigData`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Feb 2015 23:49:52 -0800 |
parents | 0b2d8f6df4ce |
children | 016d42c23ba9 |
comparison
equal
deleted
inserted
replaced
225:a75d024ee839 | 226:e9dc18a275ff |
---|---|
292 f = PaginationFilter() | 292 f = PaginationFilter() |
293 f.addClausesFromConfig(conf) | 293 f.addClausesFromConfig(conf) |
294 return f | 294 return f |
295 return None | 295 return None |
296 | 296 |
297 def getSettingAccessor(self): | |
298 return lambda i, n: i.config.get(n) | |
299 | |
297 | 300 |
298 class ArraySource(PageSource, SimplePaginationSourceMixin): | 301 class ArraySource(PageSource, SimplePaginationSourceMixin): |
299 def __init__(self, app, inner_source, name='array', config=None): | 302 def __init__(self, app, inner_source, name='array', config=None): |
300 super(ArraySource, self).__init__(app, name, config or {}) | 303 super(ArraySource, self).__init__(app, name, config or {}) |
301 self.inner_source = inner_source | 304 self.inner_source = inner_source |