diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-07-24 20:40:32 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-07-24 20:40:32 +0000 |
| commit | 3b8435279d9eef5bc0fe97af840686fd226dfad5 (patch) | |
| tree | ac1d9565c59e077a32641ae250601984921bccc6 /docs | |
| parent | 8d9f2f8b3f3aea9358063b26766bb2ea35dfdf36 (diff) | |
| download | pyramid-3b8435279d9eef5bc0fe97af840686fd226dfad5.tar.gz pyramid-3b8435279d9eef5bc0fe97af840686fd226dfad5.tar.bz2 pyramid-3b8435279d9eef5bc0fe97af840686fd226dfad5.zip | |
Location proxies.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/models.rst | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/docs/narr/models.rst b/docs/narr/models.rst index addbdd9ea..40d52ca99 100644 --- a/docs/narr/models.rst +++ b/docs/narr/models.rst @@ -51,11 +51,26 @@ instance nodes in the graph: Location-Aware Model Instances ------------------------------ - - For :mod:`repoze.bfg` security and convenience URL-generation - functions to work properly against a model instance graph, all - nodes in the graph should have two attributes:: ``__parent__`` and - ``__name__``. The ``__parent__`` attribute should be a reference - to the node's parent model instance in the graph. The ``__name__`` - attribute should be the name that a node's parent refers to the - node by via ``__getitem__``. + For :mod:`repoze.bfg` security and convenience URL-generation + functions to work properly against a model instance graph, all nodes + in the graph should have two attributes:: ``__parent__`` and + ``__name__``. The ``__parent__`` attribute should be a reference to + the node's parent model instance in the graph. The ``__name__`` + attribute should be the name that a node's parent refers to the node + by via ``__getitem__``. + If you choose not to manage the ``__name__`` and ``__parent__`` + attributes of your models "by hand", :mod:``repoze.bfg`` is willing + to help you do this. If your "root" node claims it implements the + interface ``zope.location.interfaces.ILocation``, you don't need to + manage these attributes by hand. During traversal, if the root node + says it implements ``ILocation``, bfg will wrap each child in a + LocationProxy which will dynamically assign a ``__name__`` and a + ``__parent__`` to it, recursively. + + If you choose to make use of the dynamic assignment of ``__parent__`` + and ``__name__``, the root node must have a ``__parent__`` and a + ``__name__`` that are both None, and it must provide the + ``ILocation`` interface. The easiest way to do this is to claim that + the class representing the root node + ``implements(ILocation)``. |
