PyXWF.Crumbs – Crumb baseclass

class PyXWF.Crumbs.CrumbBase(site, node)[source]

Usually, you’ll inherit from this baseclass to implement a Crumb. It takes two arguments. site must be the Site instance to which the crumb belongs and node must be the lxml.etree._Element instance which triggered instanciaton of the crumb.

Note that to create a crumb, you have to use the CrumbMeta metaclass, which requires some attributes:

class SomeFancyCrumb(CrumbBase):
    __metaclass__ = Registry.CrumbMeta

    # xml namespace
    namespace = "http://example.com/some-fancy-crumb"

    # list of xml local-names to register for in the above namespace
    names = ["crumb"]
render(ctx, parent)[source]

Return an iterable of nodes which are to be inserted into the node parent. As indicated by the lack of hint on where to insert, an implementor of this method should not insert the nodes by itself.

It is perfectly fine (and even recommended) to implement this as a generator function.

Previous topic

PyXWF.Nodes – Nodes for the sitemap tree

Next topic

PyXWF.Parsers – Parser baseclass

This Page