Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(452)

Delta Between Two Patch Sets: doc/topics/models/index.rst

Issue 907042: First snapshot of trytond documentation refactoring (Closed)
Left Patch Set: Update Created 14 years, 11 months ago
Right Patch Set: Fix last comments Created 14 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « doc/topics/install.rst ('k') | doc/topics/modules/index.rst » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 .. _topics-models: 1 .. _topics-models:
2 2
3 ====== 3 ======
4 Models 4 Models
5 ====== 5 ======
6
7 .. module:: trytond.model
8 6
9 A model represents a single business logic or concept. It contains fields and 7 A model represents a single business logic or concept. It contains fields and
10 defines the behaviors of the data. Most of the time, each model stores data in 8 defines the behaviors of the data. Most of the time, each model stores data in
11 a single database table. 9 a single database table.
12 10
13 The basics: 11 The basics:
14 12
15 * Each model is a Python class that subclasses one of 13 * Each model is a Python class that subclasses one of
16 :class:`trytond.model.Model`. 14 :class:`trytond.model.model.Model`.
17 15
18 * :ref:`Fields <topics-fields>` are defined as model attributes. 16 * :ref:`Fields <ref-models-fields>` are defined as model attributes.
19 17
20 * Tryton generates the tables definition and provides an API to access the 18 * Tryton generates the table definitions and provides an API to access the
21 data. 19 data.
22 20
23 Tryton provides a set of Models that can be used to compose a model: 21 Example
22 =======
24 23
25 .. toctree:: 24 This example defines a ``Party`` model which has a ``name`` and a ``code``
26 :maxdepth: 1 25 fields::
27
28 model
29 modelview
30 modelstorage
31 modelsql
32 modelworkflow
33 modelsingleton
34
35 Quick example
36 =============
37
38 This example model defines a ``Party`` which has a ``name`` and a ``code``::
39 26
40 from trytond.model import ModelView, ModelSQL, fields 27 from trytond.model import ModelView, ModelSQL, fields
41 28
42 class Party(ModelSQL, ModelView): 29 class Party(ModelSQL, ModelView):
43 "Party" 30 "Party"
44 _description = __doc__ 31 _description = __doc__
45 _name = "party.party" 32 _name = "party.party"
46 name = fields.Char('Name') 33 name = fields.Char('Name')
47 code = fields.Char('Code') 34 code = fields.Char('Code')
48 35
49 Party() 36 Party()
50 37
51 Instantiating the class registers the model class in the framework. Later the 38 Instantiating the class registers the model class in the framework. Later the
52 class will be instantiated once per database and stored in the 39 class will be instantiated once per database and stored in the
53 :ref:`Pool <topics-pool>`. Model instances are essentially accessors to 40 :ref:`Pool <topics-pool>`. Model instances are essentially accessors to
54 records. 41 records.
55 42
56 Model properties define meta-information of the model, they are class 43 Model attributes define meta-information of the model. They are class
57 attributes starting with an underscore. Some Model Properties are instance 44 attributes starting with an underscore. Some model properties are instance
58 attributes allowing to update them at other places in the framework. 45 attributes allowing to update them at other places in the framework.
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b