[Checkins]
SVN: grok/branches/jspaans-traversableattrs/doc/reference/directives.rst
Added documentation for grok.traversable
Reinout van Rees
reinout at vanrees.org
Fri May 2 05:33:07 EDT 2008
Log message for revision 86057:
Added documentation for grok.traversable
Changed:
U grok/branches/jspaans-traversableattrs/doc/reference/directives.rst
-=-
Modified: grok/branches/jspaans-traversableattrs/doc/reference/directives.rst
===================================================================
--- grok/branches/jspaans-traversableattrs/doc/reference/directives.rst 2008-05-02 09:30:40 UTC (rev 86056)
+++ grok/branches/jspaans-traversableattrs/doc/reference/directives.rst 2008-05-02 09:33:07 UTC (rev 86057)
@@ -239,7 +239,7 @@
class ModelBase(grok.Model):
pass
-
+
class ViewBase(grok.View):
def render(self):
return "hello world"
@@ -463,7 +463,7 @@
class ViewPainting(grok.Permission):
grok.name('grok.ViewPainting')
-
+
.. seealso::
:class:`grok.Permission` component, :func:`@grok.require` decorator
@@ -535,3 +535,33 @@
grok.context(IMammoth)
name = index.Field()
+
+
+:func:`grok.traversable`
+========================
+
+A class level directive used to mark attributes or methods as traversable. An
+optional `name` argument can be used to give the attribute a different name in
+the URL.
+
+.. function:: grok.traversable(attr, name=None)
+
+ **Example**
+
+ .. code-block:: python
+
+
+ class Foo(grok.Model):
+ grok.traversable('bar')
+ grok.traversable('foo')
+ grok.traversable(attr='bar', name='namedbar')
+
+ def __init__(self, name):
+ self.name = name
+
+ foo = Bar('foo')
+ def bar(self):
+ return Bar('bar')
+
+The result is that you can now access http://localhost/foo/bar,
+http://localhost/foo/foo and http://localhost/foo/namedbar.
\ No newline at end of file
More information about the Checkins
mailing list