summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki/definingmodels.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/wiki/definingmodels.rst')
-rw-r--r--docs/tutorials/wiki/definingmodels.rst36
1 files changed, 18 insertions, 18 deletions
diff --git a/docs/tutorials/wiki/definingmodels.rst b/docs/tutorials/wiki/definingmodels.rst
index 49372179f..e973cfdfe 100644
--- a/docs/tutorials/wiki/definingmodels.rst
+++ b/docs/tutorials/wiki/definingmodels.rst
@@ -1,9 +1,11 @@
+.. _wiki_defining_the_domain_model:
+
=========================
Defining the Domain Model
=========================
-The first change we'll make to our stock pcreate-generated application will be
-to define two :term:`resource` constructors, one representing a wiki page,
+The first change we'll make to our stock cookiecutter-generated application will
+be to define two :term:`resource` constructors, one representing a wiki page,
and another representing the wiki as a mapping of wiki page names to page
objects. We'll do this inside our ``models.py`` file.
@@ -15,7 +17,7 @@ single instance of the "Wiki" class will serve as a container for "Page"
objects, which will be instances of the "Page" class.
-Delete the Database
+Delete the database
-------------------
In the next step, we're going to remove the ``MyModel`` Python model
@@ -32,17 +34,25 @@ Edit ``models.py``
.. note::
- There is nothing automagically special about the filename ``models.py``. A
+ There is nothing special about the filename ``models.py``. A
project may have many models throughout its codebase in arbitrarily named
- files. Files implementing models often have ``model`` in their filenames,
+ files. Files implementing models often have ``model`` in their filenames
or they may live in a Python subpackage of your application package named
``models``, but this is only by convention.
+Open ``tutorial/models.py`` file and edit it to look like the following:
+
+.. literalinclude:: src/models/tutorial/models.py
+ :linenos:
+ :language: python
+
The first thing we want to do is remove the ``MyModel`` class from the
generated ``models.py`` file. The ``MyModel`` class is only a sample and
we're not going to use it.
-Then, we'll add a ``Wiki`` class. We want it to inherit from the
+Then we'll add an import at the top for the :class:`persistent.Persistent` class. We'll use this for a new ``Page`` class in a moment.
+
+Then we'll add a ``Wiki`` class. We want it to inherit from the
:class:`persistent.mapping.PersistentMapping` class because it provides
mapping behavior, and it makes sure that our Wiki page is stored as a
"first-class" persistent object in our ZODB database.
@@ -70,17 +80,7 @@ front page) into the Wiki within the ``appmaker``. This will provide
:term:`traversal` a :term:`resource tree` to work against when it attempts to
resolve URLs to resources.
-Look at the Result of Our Edits to ``models.py``
-------------------------------------------------
-
-The result of all of our edits to ``models.py`` will end up looking
-something like this:
-
-.. literalinclude:: src/models/tutorial/models.py
- :linenos:
- :language: python
-
-View the Application in a Browser
+View the application in a browser
---------------------------------
We can't. At this point, our system is in a "non-runnable" state; we'll need
@@ -91,6 +91,6 @@ up with a Python traceback on your console that ends with this exception:
.. code-block:: text
- ImportError: cannot import name MyModel
+ ImportError: cannot import name MyModel
This will also happen if you attempt to run the tests.