Package nevow :: Module rend :: Class ChildLookupMixin
[show private | hide private]
[frames | no frames]

Class ChildLookupMixin

FreeformChildMixin --+
                     |
                    ChildLookupMixin

Known Subclasses:
Page

Method Summary
  childFactory(self, ctx, name)
Used by locateChild to return children which are generated dynamically.
  locateChild(self, ctx, segments)
Locate a child page of this one.
  putChild(self, name, child)
    Inherited from FreeformChildMixin
  child_freeform_hand(self, ctx)

Class Variable Summary
Implements __implemented__ = <implementedBy nevow.rend.ChildLookupM...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
NoneType children = None                                                                  
    Inherited from FreeformChildMixin
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...

Method Details

childFactory(self, ctx, name)

Used by locateChild to return children which are generated dynamically. Note that higher level interfaces use only locateChild, and only nevow.rend.Page.locateChild uses this.

segment is a string represnting one element of the URI. Request is a nevow.appserver.NevowRequest.

The default implementation of this always returns None; it is intended to be overridden.

locateChild(self, ctx, segments)

Locate a child page of this one. ctx is a nevow.context.PageContext representing the parent Page, and segments is a tuple of each element in the URI. An tuple (page, segments) should be returned, where page is an instance of nevow.rend.Page and segments a tuple representing the remaining segments of the URI. If the child is not found, return NotFound instead.

locateChild is designed to be easily overridden to perform fancy lookup tricks. However, the default locateChild is useful, and looks for children in three places, in this order:
  • in a dictionary, self.children
  • a member of self named child_<childname>. This can be either an attribute or a method. If an attribute, it should be an object which can be adapted to IResource. If a method, it should take the context and return an object which can be adapted to IResource.
  • by calling self.childFactory(ctx, name). Name is a single string instead of a tuple of strings. This should return an object that can be adapted to IResource.
Overrides:
nevow.rend.FreeformChildMixin.locateChild

Class Variable Details

__implemented__

Type:
Implements
Value:
<implementedBy nevow.rend.ChildLookupMixin>                            

__provides__

Type:
ClassProvides
Value:
<zope.interface.declarations.ClassProvides object at 0x40a8e30c>       

children

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Sun Oct 1 10:49:46 2006 http://epydoc.sf.net