The heart of PyXWF is beating in the Site instance. It accepts requests and passes them through the tree defined in the sitemap xml.
Represent and maintain a complete PyXWF framework instance. The sitemap is loaded from sitemap_file. Optionally, one can specify a default_url_root which is used if no URL root is specified in the sitemap XML.
An instance of ParserRegistry local to the current site. This is the preferred method to access parsers.
An instance of HookRegistry for this site. See Hooks available on Site objects for a reference of existing hooks.
Add the given crumb to the Sites crumb registry. May throw a ValueError if the ID is invalied or duplicated with an already existing registry entry.
Handle a NotFound exception if it occurs while traversing the sitetree in the search for a node to handle the current request.
Nodes may have IDs under which they can be referred using the Site. This method is used to register the node under a given ID. This will raise a ValueError if the ID is duplicated.
Transform the attribute attrname on the ETree node node as if it was a possibly local url. If it is local and relative, it gets transformed so that it points to the same location independent of the current URL.
Do PyXWF specific transformations on the XHTML tree body. This includes transforming local a tags, local img tags and placing crumbs.
Note that the tree body is not bound to be an actual XHTML body. This method will iterate over all matching elements, so it can also be a whole XHTML html document or just a snippet or something completely outside the XHTML namespace.
See <py-namespace> for documentation on what can be done with in that XML namespace.
Transform all <py:author /> elements in tree which have an @id attribute by copying all relevant attributes of the Author object referred to by the @id to the element. This overrides existing attributes.
If the @id is not known to the site, the text of the element is replaced with a easy-to-recognize placeholder and the element is converted to a <h:span /> element.
The following hooks are available on every Site instance. They’re called with the specified arguments and their return value is ignored. See PyXWF.Registry.HookRegistry for more information on hooking.
All nodes in <site:tweaks /> have been processed. This is useful to do something smart with the configuration you received.
The tree root has been found in the sitemap and is completely loaded. This implies that all node IDs are accessible by the time this hook is called.
The whole <site:crumbs /> has been processed.
The whole sitemap was successfully processed.
getMessage() has just been called, no lookup has been done yet. This is useful to place site-wide redirects.
ctx is the Context instance of the request.