view piecrust/sources/interfaces.py @ 363:dd25bd3ce1f9

serve: Refactoring and fixes to be able to serve taxonomy pages. * Page sources' `findPagePath` is renamed to `findPageFactory`, so that it also returns source metadata. * Page refs now store possible hits more properly, and use the previous point to also store metadata. As a result, they can also return a proper factory. * Implement `findPageFactory` correctly in all built-in sources. * When the Chef server matches a taxonomy page, get the source metadata from the page ref in order to make a more proper page. * Make the `getRoute(s)` functions explicitely say if they want taxonomy routes or not.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 26 Apr 2015 15:07:40 -0700
parents f130365568ff
children 0c74a6c4533d
line wrap: on
line source



class IPaginationSource(object):
    """ Defines the interface for a source that can be used as the data
        for an iterator or a pagination.
    """
    def getItemsPerPage(self):
        raise NotImplementedError()

    def getSourceIterator(self):
        raise NotImplementedError()

    def getSorterIterator(self, it):
        raise NotImplementedError()

    def getTailIterator(self, it):
        raise NotImplementedError()

    def getPaginationFilter(self, page):
        raise NotImplementedError()

    def getSettingAccessor(self):
        raise NotImplementedError()


class IListableSource:
    """ Defines the interface for a source that can be iterated on in a
        hierarchical manner, for use with the `family` data endpoint.
    """
    def listPath(self, rel_path):
        raise NotImplementedError()

    def getDirpath(self, rel_path):
        raise NotImplementedError()

    def getBasename(self, rel_path):
        raise NotImplementedError()


class IPreparingSource:
    """ Defines the interface for a source whose pages can be created by the
        `chef prepare` command.
    """
    def setupPrepareParser(self, parser, app):
        raise NotImplementedError()

    def buildMetadata(self, args):
        raise NotImplementedError()