author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Mon, 25 May 2009 16:11:30 +0200 | |
branch | stable |
changeset 1924 | dc903af1a34e |
parent 108 | 60faaa480f02 |
child 2789 | 39712da6f397 |
permissions | -rw-r--r-- |
43
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
2 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
3 |
Définir l'interface utilisateur avec des vues |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
4 |
============================================= |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
5 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
6 |
`LAX` provides out-of-the-box a web interface that is generated from |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
7 |
the schema definition: entities can be created, displayed, updated and |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
8 |
deleted. As display views are not very fancy, it is usually necessary |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
9 |
to develop your own. |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
10 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
11 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
12 |
With `LAX`, views are defined by Python classes. A view includes : |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
13 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
14 |
- an identifier (all objects in `LAX` are entered in a registry |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
15 |
and this identifier will be used as a key) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
16 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
17 |
- a filter to select the resulsets it can be applied to |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
18 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
19 |
`LAX` provides a lot of standard views, for a complete list, you |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
20 |
will have to read the code in directory views (XXX improve doc). |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
21 |
For example, the view named ``primary`` is the one used to display |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
22 |
a single entity. |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
23 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
24 |
If you want to change the way a ``BlogEntry`` is displayed, just |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
25 |
override the view ``primary`` in ``BlogDemo/views.py`` :: |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
26 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
27 |
from ginco.web.views import baseviews |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
28 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
29 |
class BlogEntryPrimaryView(baseviews.PrimaryView): |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
30 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
31 |
accepts = ('BlogEntry',) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
32 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
33 |
def cell_call(self, row, col): |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
34 |
entity = self.entity(row, col) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
35 |
self.w(u'<h1>%s</h1>' % entity.title) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
36 |
self.w(u'<div>%s</div>' % entity.publish_date) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
37 |
self.w(u'<div>%s</div>' % entity.category) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
38 |
self.w(u'<div>%s</div>' entity.content) |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
39 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
40 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
41 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
42 |
* Defining views with selection/views |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
43 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
44 |
* implementing interfaces, calendar for blog entries |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
45 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
46 |
* show that a calendar view can export data to ical |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
47 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
48 |
* create view "blogentry table" with title, publish_date, category |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
49 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
50 |
* in view blog, select blogentries and apply view "blogentry table" |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
51 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
52 |
* demo ajax by filtering blogentry table on category |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
53 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
54 |
Components |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
55 |
=========== |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
56 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
57 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
58 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
59 |
* explain the component architecture |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
60 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
61 |
* add comments to the blog by importing the comments component |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
62 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
63 |
MainTemplate |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
64 |
============ |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
65 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
66 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
67 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
68 |
* customize MainTemplate and show that everything in the user |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
69 |
interface can be changed |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
70 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
71 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
72 |
RSS Channel |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
73 |
=========== |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
74 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
75 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
76 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
77 |
* show that the RSS view can be used to display an ordered selection |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
78 |
of blog entries, thus providing a RSS channel |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
79 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
80 |
* show that a different selection (by category) means a different channel |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
81 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
82 |
RQL |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
83 |
==== |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
84 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
85 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
86 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
87 |
* talk about the Relation Query Language |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
88 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
89 |
URL Rewriting |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
90 |
============= |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
91 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
92 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
93 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
94 |
* show how urls are mapped to selections and views and explain URLRewriting |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
95 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
96 |
Security |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
97 |
========= |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
98 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
99 |
[WRITE ME] |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
100 |
|
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
101 |
* talk about security access rights and show that security is defined |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
102 |
using RQL |
c1a51436db9c
Add references chapter and lax-book-fr but this is temporary, until content is sorted.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
103 |