@@ -31,13 +31,29 @@ create a module:
31
31
.. patch ::
32
32
:hidden:
33
33
34
- This builds a basic module for you, ignore anything in the ``models `` and
35
- ``security `` directories for now.
34
+ This builds a basic module for you:
35
+
36
+ .. code-block :: text
37
+
38
+ academy
39
+ ├── __init__.py
40
+ ├── __openerp__.py
41
+ ├── controllers
42
+ │ ├── __init__.py
43
+ │ └── my_controller.py
44
+ ├── models
45
+ │ ├── __init__.py
46
+ │ └── my_model.py
47
+ └── security
48
+ └── ir.model.access.csv
49
+
50
+ Ignore anything in the ``models `` and ``security `` directories for now.
36
51
37
52
.. todo ::
38
53
39
54
* instructions for start & install
40
55
* db handling
56
+
41
57
- if existing db, automatically selected
42
58
- if no existing db, nodb -> login -> login of first db
43
59
- dbfilter
@@ -46,6 +62,8 @@ Now start your OpenERP server and install your module in it, open a web
46
62
browser and navigate to http://localhost:8069. A page should appear with just
47
63
the words "Hello, world!" on it.
48
64
65
+ .. todo :: screenshot?
66
+
49
67
Let's prettify things a bit: instead of returning just a bit of text,
50
68
we can return a page, and use a tool like bootstrap _ to get a
51
69
nicer rendering than the default.
@@ -57,21 +75,28 @@ returned by the ``index`` method to get a more page-ish output:
57
75
58
76
.. note ::
59
77
60
- this example requires internet access at all time, as we're accessing a
61
- :abbr: `CDN ( Content Delivery Network, large distributed networks hosting
62
- static files and trying to provide high-performance and high-availability
63
- of these files ) `-hosted file.
78
+ this example requires internet access as we're accessing a :abbr: `CDN
79
+ ( Content Delivery Network, large distributed networks hosting static files
80
+ and trying to provide high-performance and high-availability of these
81
+ files ) `-hosted file.
82
+
83
+ .. todo :: screenshot
64
84
65
85
Data input: URL and query
66
86
=========================
67
87
68
88
Being able to build a static page in code is nice, but makes for limited
69
- usefulness (you could do that with static files in the first place).
89
+ usefulness (you could do that with static files).
90
+
91
+ You can also create dynamic pages which use data provided in the URL,
92
+ for instance so a single controller generates multiple pages. Any
93
+ query parameter (``?name=value ``) is passed as a string parameter to the
94
+ controller method.
70
95
71
- You can also create controllers which use data provided in the access URL,
72
- for instance so you have a single controller generating multiple pages. Any
73
- query parameter (`` ?name=value ``) is passed as a parameter to the controller
74
- function, and is a string.
96
+ For instance, the index page can display a list of teaching assistants linking
97
+ to a page for each assistant through their index in a global array. Each
98
+ assistant's page will simply print their name by applying the index to the
99
+ array:
75
100
76
101
.. patch ::
77
102
@@ -89,16 +114,14 @@ This can be done by adding `converter patterns`_ to the URL in
89
114
These patterns can perform conversions directly (in this case the conversion
90
115
from a string URL section to a python integer) and will perform a some
91
116
validation (if the ``id `` is not a valid integer, the converter will return a
92
- ``404 Not Found `` instead of generating a server error when the conversion
93
- fails).
117
+ ``404 Not Found `` instead of a 500 server error when the conversion fails).
94
118
95
119
Templating: better experience in editing
96
120
========================================
97
121
98
- So far we've created HTML output by munging together Python strings using
99
- string concatenation and formatting. It works, but is not exactly fun to edit
100
- (and somewhat unsafe to boot) as even advanced text editors have a hard time
101
- understanding they're dealing with HTML embedded in Python code.
122
+ So far we've output HTML by munging strings. It works, but is not exactly fun
123
+ to edit (and somewhat unsafe to boot) as even advanced text editors have a
124
+ hard time understanding they're dealing with HTML embedded in Python code.
102
125
103
126
The usual solution is to use templates _, documents with placeholders which can
104
127
be "rendered" to produce final pages (or others). OpenERP lets you use any
0 commit comments