Interface n.i.IQ(Interface):

Part of nevow.inevow View Source View In Hierarchy

Known implementations: nevow.query.QueryContext, nevow.stan.Tag

Interface for querying. Adapters implement this for objects which may appear in the stan DOM to allow introspecting the DOM and finding nodes with certain qualities.
Line # Kind Name Docs
15 Method patternGenerator Returns a pseudo-Tag which will generate clones of matching
33 Method allPatterns Return a list of all matching pattern tags, cloned.
42 Method onePattern Return a single matching pattern, cloned.
51 Method keyed Locate the node with the key 'key', clone it, call fillSlots(key, clone)
def patternGenerator(pattern, default=None): (source)

Returns a pseudo-Tag which will generate clones of matching pattern tags forever, looping around to the beginning when running out of unique matches.

If no matches are found, and default is None, raise an exception, otherwise, generate clones of default forever.

You can use the normal stan syntax on the return value.

Useful to find repeating pattern elements. Example rendering function:
>>> def simpleSequence(context, data):
...   pattern = IQ(context).patternGenerator('item')
...   return [pattern(data=element) for element in data]
def allPatterns(pattern): (source)

Return a list of all matching pattern tags, cloned.

Useful if you just want to insert them in the output in one place.

E.g. the sequence renderer's header and footer are found with this.
def onePattern(pattern): (source)

Return a single matching pattern, cloned. If there is more than one matching pattern or no matching patterns, raise an exception.

Useful in the case where you want to locate one and only one sub-tag and do something with it.
def keyed(key): (source)

Locate the node with the key 'key', clone it, call fillSlots(key, clone) and return the clone.

This method lets you effectively locate and mutate a node in the DOM. It is useful for setting the data special on a specific node, and also for calling fillSlots on a specific node, as well as other node-mutation operations such as setting a handler or assigning a class or id to a node.
API Documentation for Nevow, generated by pydoctor.