author | sylvain.thenault@logilab.fr |
Tue, 05 May 2009 17:11:51 +0200 | |
branch | tls-sprint |
changeset 1665 | 14a8f9d434c8 |
parent 1355 | 8a3102fb4760 |
permissions | -rw-r--r-- |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
2 |
|
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
3 |
|
297
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
4 |
Data as objects |
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
5 |
=============== |
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
6 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
7 |
In this chapter, we will introduce the objects that are used to handle |
297
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
8 |
the data stored in the database. |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
9 |
|
1355
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
10 |
Class `Entity` and `AnyEntity` |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
11 |
------------------------------ |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
12 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
13 |
To provide a specific behavior for each entity, we have to define |
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
14 |
a class inheriting from `cubicweb.entities.AnyEntity`. In general, we |
1355
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
15 |
define this class in a module of `mycube.entities` package of an application |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
16 |
so that it will be available on both server and client side. |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
17 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
18 |
The class `AnyEntity` is loaded dynamically from the class `Entity` |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
19 |
(`cubciweb.common.entity`). We define a sub-class to add methods or to |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
20 |
specialize the handling of a given entity type |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
21 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
22 |
Descriptors are added when classes are registered in order to initialize the class |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
23 |
according to its schema: |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
24 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
25 |
* we can access the defined attributes in the schema thanks to the attributes of |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
26 |
the same name on instances (typed value) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
27 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
28 |
* we can access the defined relations in the schema thanks to the relations of |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
29 |
the same name on instances (entities instances list) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
30 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
31 |
The methods defined for `AnyEntity` or `Entity` are the following ones: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
32 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
33 |
* `has_eid()`, returns true is the entity has an definitive eid (e.g. not in the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
34 |
creation process) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
35 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
36 |
* `check_perm(action)`, checks if the user has the permission to execute the |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
37 |
requested action on the entity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
38 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
39 |
:Formatting and output generation: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
40 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
41 |
* `view(vid, **kwargs)`, applies the given view to the entity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
42 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
43 |
* `absolute_url(**kwargs)`, returns an absolute URL to access the primary view |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
44 |
of an entity |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
45 |
|
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
46 |
* `rest_path()`, returns a relative REST URL to get the entity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
47 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
48 |
* `format(attr)`, returns the format (MIME type) of the field given un parameter |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
49 |
|
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
50 |
* `printable_value(attr, value=_marker, attrtype=None, format='text/html')`, |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
51 |
returns a string enabling the display of an attribute value in a given format |
301 | 52 |
(the value is automatically recovered if necessary) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
53 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
54 |
* `display_name(form='')`, returns a string to display the entity type by |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
55 |
specifying the preferred form (`plural` for a plural form) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
56 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
57 |
:Data handling: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
58 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
59 |
* `as_rset()`, converts the entity into an equivalent result set simulating the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
60 |
request `Any X WHERE X eid _eid_` |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
61 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
62 |
* `complete(skip_bytes=True)`, executes a request that recovers in one time |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
63 |
all the missing attributes of an entity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
64 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
65 |
* `get_value(name)`, returns the value associated to the attribute name given |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
66 |
in parameter |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
67 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
68 |
* `related(rtype, x='subject', limit=None, entities=False)`, returns a list |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
69 |
of entities related to the current entity by the relation given in parameter |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
70 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
71 |
* `unrelated(rtype, targettype, x='subject', limit=None)`, returns a result set |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
72 |
corresponding to the entities not related to the current entity by the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
73 |
relation given in parameter and satisfying its constraints |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
74 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
75 |
* `set_attributes(**kwargs)`, updates the attributes list with the corresponding |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
76 |
values given named parameters |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
77 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
78 |
* `copy_relations(ceid)`, copies the relations of the entities having the eid |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
79 |
given in the parameters on the current entity |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
80 |
|
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
81 |
* `last_modified(view)`, returns the date the object has been modified |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
82 |
(used by HTTP cache handling) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
83 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
84 |
* `delete()` allows to delete the entity |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
85 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
86 |
:Standard meta-data (Dublin Core): |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
87 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
88 |
* `dc_title()`, returns a unicode string corresponding to the meta-data |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
89 |
`Title` (used by default the first attribute non-meta of the entity |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
90 |
schema) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
91 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
92 |
* `dc_long_title()`, same as dc_title but can return a more |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
93 |
detailled title |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
94 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
95 |
* `dc_description(format='text/plain')`, returns a unicode string |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
96 |
corresponding to the meta-data `Description` (look for a description |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
97 |
attribute by default) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
98 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
99 |
* `dc_authors()`, returns a unicode string corresponding to the meta-data |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
100 |
`Authors` (owners by default) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
101 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
102 |
* `dc_date(date_format=None)`, returns a unicode string corresponding to |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
103 |
the meta-data `Date` (update date by default) |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
104 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
105 |
:Vocabulary control on relations: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
106 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
107 |
* `vocabulary(rtype, x='subject', limit=None)`, called by the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
108 |
editing views, it returns a list of couples (label, eid) of entities |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
109 |
that could be related to the entity by the relation `rtype` |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
110 |
* `subject_relation_vocabulary(rtype, limit=None)`, called internally |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
111 |
by `vocabulary` in the case of a subject relation |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
112 |
* `object_relation_vocabulary(rtype, limit=None)`, called internally |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
113 |
by `vocabulary` in the case of an object relation |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
114 |
* `relation_vocabulary(rtype, targettype, x, limit=None)`, called |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
115 |
internally by `subject_relation_vocabulary` and `object_relation_vocabulary` |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
116 |
|
1355
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
117 |
Class `TreeMixIn` |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
118 |
----------------- |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
119 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
120 |
This class provides a tree interface. This mixin has to be inherited |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
121 |
explicitly and configured using the tree_attribute, parent_target and |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
122 |
children_target class attribute to benefit from this default implementation. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
123 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
124 |
This class provides the following methods: |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
125 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
126 |
* `different_type_children(entities=True)`, returns children entities |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
127 |
of different type as this entity. According to the `entities` parameter, |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
128 |
returns entity objects (if entity=True) or the equivalent result set. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
129 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
130 |
* `same_type_children(entities=True)`, returns children entities of |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
131 |
the same type as this entity. According to the `entities` parameter, |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
132 |
return entity objects (if entity=True) or the equivalent result set. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
133 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
134 |
* `iterchildren( _done=None)`, iters on the children of the entity. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
135 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
136 |
* `prefixiter( _done=None)` |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
137 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
138 |
* `path()`, returns the list of eids from the root object to this object. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
139 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
140 |
* `iterparents()`, iters on the parents of the entity. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
141 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
142 |
* `notification_references(view)`, used to control References field |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
143 |
of email send on notification for this entity. `view` is the notification view. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
144 |
Should return a list of eids which can be used to generate message ids |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
145 |
of previously sent email. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
146 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
147 |
`TreeMixIn` implements also the ITree interface (``cubicweb.interfaces``): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
148 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
149 |
* `parent()`, returns the parent entity if any, else None (e.g. if we are on the |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
150 |
root) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
151 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
152 |
* `children(entities=True, sametype=False)`, returns children entities |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
153 |
according to the `entities` parameter, return entity objects or the |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
154 |
equivalent result set. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
155 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
156 |
* `children_rql()`, returns the RQL query corresponding to the children |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
157 |
of the entity. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
158 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
159 |
* `is_leaf()`, returns True if the entity does not have any children. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
160 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
161 |
* `is_root()`, returns True if the entity does not have any parent. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
162 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
163 |
* `root()`, returns the root object of the tree representation of |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
164 |
the entity and its related entities. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
165 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
166 |
Example of use |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
167 |
`````````````` |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
168 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
169 |
Imagine you defined three types of entities in your schema, and they |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
170 |
relates to each others as follows in ``schema.py``:: |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
171 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
172 |
class Entity1(EntityType): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
173 |
title = String() |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
174 |
is_related_to = SubjectRelation('Entity2', 'subject') |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
175 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
176 |
class Entity2(EntityType): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
177 |
title = String() |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
178 |
belongs_to = SubjectRelation('Entity3', 'subject') |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
179 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
180 |
class Entity3(EntityType): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
181 |
name = String() |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
182 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
183 |
You would like to create a view that applies to both entity types |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
184 |
`Entity1` and `Entity2` and which lists the entities they are related to. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
185 |
That means when you view `Entity1` you want to list all `Entity2`, and |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
186 |
when you view `Entity2` you want to list all `Entity3`. |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
187 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
188 |
In ``entities.py``:: |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
189 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
190 |
class Entity1(TreeMixIn, AnyEntity): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
191 |
id = 'Entity1' |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
192 |
__implements__ = AnyEntity.__implements__ + (ITree,) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
193 |
__rtags__ = {('is_related_to', 'Entity2', 'object'): 'link'} |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
194 |
tree_attribute = 'is_related_to' |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
195 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
196 |
def children(self, entities=True): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
197 |
return self.different_type_children(entities) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
198 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
199 |
class Entity2(TreeMixIn, AnyEntity): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
200 |
id = 'Entity2' |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
201 |
__implements__ = AnyEntity.__implements__ + (ITree,) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
202 |
__rtags__ = {('belongs_to', 'Entity3', 'object'): 'link'} |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
203 |
tree_attribute = 'belongs_to' |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
204 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
205 |
def children(self, entities=True): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
206 |
return self.different_type_children(entities) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
207 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
208 |
Once this is done, you can define your common view as follows:: |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
209 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
210 |
class E1E2CommonView(baseviews.PrimaryView): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
211 |
accepts = ('Entity11, 'Entity2') |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
212 |
|
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
213 |
def render_entity_relations(self, entity, siderelations): |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
214 |
self.wview('list', entity.children(entities=False)) |
8a3102fb4760
[doc] Adds description and example of TreeMixIn.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
1222
diff
changeset
|
215 |
|
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
216 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
217 |
*rtags* |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
218 |
------- |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
219 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
220 |
*rtags* allow to specify certain behaviors of relations relative to a given |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
221 |
entity type (see later). They are defined on the entity class by the attribute |
1222
0d5035525a23
[doc] spelling : dictionary
Emile Anclin <emile.anclin@logilab.fr>
parents:
1207
diff
changeset
|
222 |
`rtags` which is a dictionary with as keys the triplets :: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
223 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
224 |
<relation type>, <target entity type>, <context position ("subject" ou "object")> |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
225 |
|
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
226 |
and as values a `set` or a tuple of markers defining the properties that |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
227 |
apply to this relation. |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
228 |
|
1222
0d5035525a23
[doc] spelling : dictionary
Emile Anclin <emile.anclin@logilab.fr>
parents:
1207
diff
changeset
|
229 |
It is possible to simplify this dictionary: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
230 |
|
301 | 231 |
* if we want to specifiy a single marker, it is not necessary to |
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
232 |
use a tuple as value, the marker by itself (character string) |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
233 |
is enough |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
234 |
* if we only care about a single type of relation and not about the target |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
235 |
and the context position (or when this one is not ambigous), we can simply |
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
236 |
use the name of the relation type as key |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
237 |
* if we want a marker to apply independently from the target entity type, |
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
238 |
we have to use the string `*` as target entity type |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
239 |
|
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
240 |
|
1222
0d5035525a23
[doc] spelling : dictionary
Emile Anclin <emile.anclin@logilab.fr>
parents:
1207
diff
changeset
|
241 |
Please note that this dictionary is *treated at the time the class is created*. |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
242 |
It is automatically merged with the parent class(es) (no need to copy the |
1222
0d5035525a23
[doc] spelling : dictionary
Emile Anclin <emile.anclin@logilab.fr>
parents:
1207
diff
changeset
|
243 |
dictionary from the parent class to modify it). Also, modifying it after the |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
244 |
class is created will not have any effect... |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
245 |
|
292
2d9e83c34b23
[doc] Renaming of part II sub-sections accordingly.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
287
diff
changeset
|
246 |
.. include:: B0031-define-entities.en.txt |
1207
33d0e08a931a
[doc] trying to get it a little bit more readable
Emile Anclin <emile.anclin@logilab.fr>
parents:
301
diff
changeset
|
247 |