Class n.a.ObjectContainer(tpc.Adapter):

Part of nevow.accessors View Source View In Hierarchy

Implements interfaces: nevow.inevow.IContainer

Retrieve object attributes in response to a data directive; providing easy access to your application objects' attributes.

ObjectContainer is not registered as an adapter for any objects by default. It must be registered for each type you want to adapt.

The adapter will cowardly refuse to get any attributes that start with an underscore.

For example:
>>> class Image:
...     def __init__(self, filename, comments):
...         self.filename = filename    # A string
...         self.comments = comments    # A sequence of strings
... 
>>> registerAdapter(ObjectContainer, Image, IContainer)
Registering the adapter allows Nevow to retrieve attributes from the Image instance returned by the data_image method when rendering the following XHTML template:
   <div n:data="image">
     <p n:data="filename" n:render="string">filename</p>
     <ul n:data="comments" n:render="sequence">
       <li n:pattern="item" n:render="string">comment</li>
     </ul>
   </div>

Split Table into Classes Show Methods in One Table

Line # Kind Name Docs
109 Method child Return a conceptual child; an attribute, or a key,

Inherited from Adapter:

Line # Kind Name Docs
168 Method __init__ Set my 'original' attribute to be the object I am adapting.
173 Method __conform__ I forward __conform__ to self.original if it has it, otherwise I
182 Method isuper Forward isuper to self.original
Line # Kind Name Docs
173 Method __conform__ I forward __conform__ to self.original if it has it, otherwise I
168 Method __init__ Set my 'original' attribute to be the object I am adapting.
109 Method child Return a conceptual child; an attribute, or a key,
182 Method isuper Forward isuper to self.original
def child(self, context, name): (source)

Return a conceptual child; an attribute, or a key, or the result of a function call.

Returns any object; the result may be adapted to IGettable if possible.

Return None if the adaptee does not have a child with the given name.

TODO: Maybe returning None is bad, and .child should just raise whatever exception is natural
API Documentation for Nevow, generated by pydoctor.