From 74e3c499bec027c08326de7428e99f94aa166c67 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 24 Jul 2008 23:58:03 +0000 Subject: Various tweaks. --- docs/tutorials/lxmlgraph/step02.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'docs/tutorials') diff --git a/docs/tutorials/lxmlgraph/step02.rst b/docs/tutorials/lxmlgraph/step02.rst index a9edbae15..b53fd0eff 100644 --- a/docs/tutorials/lxmlgraph/step02.rst +++ b/docs/tutorials/lxmlgraph/step02.rst @@ -14,7 +14,7 @@ data. We will leverage the following ``repoze.bfg`` machinery: Our application will need to do these things: - - Use lxml Element classes to inject ``repoze.bfg`` behavior into + - Use ``lxml`` Element classes to inject ``repoze.bfg`` behavior into ``lxml`` nodes - That model class needs to implement the ``repoze.bfg`` publishing @@ -39,24 +39,24 @@ your package: #. In lines 3-4, the ```` contains 2 top-level children: a and b. These are provided as an element name ````. This, - also, is meaningfless as far as ``repoze.bfg`` is concerned. + also, is meaningless as far as ``repoze.bfg`` is concerned. However, this is where you compose the information model you are publishing. -The only special constraint is that a node that wants to be "found" by -``repoze.bfg`` in during traversal *must* have an ``name`` attribute. -(The use of ``@name`` corresponds to ``__name__`` in the -``repoze.bfg`` sense of ``repoze.bfg`` :term:`location`). Each hop in -the URL tries to grab a child with an attribute matching the next hop. -Also, the value of the ``@name`` should be unique in its containing -node. +The only special constraint is that an XML node that wants to be +"found" by ``repoze.bfg`` in during traversal *must* have a ``name`` +attribute. (The use of ``@name`` corresponds to ``__name__`` in the +``repoze.bfg`` sense of ``repoze.bfg`` :term:`location` ). Each hop +in the URL tries to grab a child with an attribute matching the next +hop. Also, the value of the ``@name`` should be unique in its +containing node. Module ``models.py`` ------------------------------ -At a high level, we make write a class that "extends" lxml Element -nodes, create an lxml parser, and register the custom class with the +At a high level, we make write a class that "extends" ``lxml`` Element +nodes, create an ``lxml`` parser, and register the custom class with the parser. Replace the contents of the autogenerated ``models.py`` with the content we show below. @@ -66,7 +66,7 @@ the content we show below. #. Line 4 imports lxml. #. Line 9 creates the custom class we are going to use to extend - etree.ElementBase. The lxml website has great documentation on the + etree.ElementBase. The ``lxml`` website has great documentation on the various ways to inject custom Python behavior into XML. #. Just as before, line 12 says that instances of this class support a @@ -84,7 +84,7 @@ the content we show below. return it. If not, or if more than one is found, raise an error. #. As before, ``get_root`` is the function that is expected to return - the top of the model. In lines 30+ we do the lxml magic to get the + the top of the model. In lines 30+ we do the ``lxml`` magic to get the custom Python class registered. We then load some XML and return the top of the tree. -- cgit v1.2.3