author | Graziella Toutoungis <graziella.toutoungis@logilab.fr> |
Tue, 31 Mar 2009 17:09:38 +0200 | |
changeset 1194 | e224f064a268 |
parent 301 | e47150482ac1 |
child 1207 | 33d0e08a931a |
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 |
|
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
7 |
We will in this chapter introduce the objects that are used to handle |
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 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
10 |
Classes `Entity` and `AnyEntity` |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
11 |
-------------------------------- |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
12 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
13 |
To provide a specific behavior for each entity, we just need to define |
297
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
14 |
a class inheriting from `cubicweb.entities.AnyEntity`. In general, we have |
ac86aaaaad08
[doc] Better title? Brief introduction of the chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
292
diff
changeset
|
15 |
to defined those classes in a module of `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 |
|
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
25 |
* we can access the defined attributes in the schema thanks the attributes of |
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 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
36 |
* `check_perm(action)`, checks if the user has the permission to execcute the |
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 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
41 |
* `view(vid, **kwargs)`, apply 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 |
|
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
117 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
118 |
*rtags* |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
119 |
------- |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
120 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
121 |
*rtags* allows to specify certain behaviors of relations relative to a given |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
122 |
entity type (see later). They are defined on the entity class by the attribute |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
123 |
`rtags` which is a dictionnary with as its keys the triplet :: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
124 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
125 |
<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
|
126 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
127 |
and as the values a `set` or a tuple of markers defining the properties that |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
128 |
apply to this relation. |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
129 |
|
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
130 |
It is possible to simplify this dictionnary: |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
131 |
|
301 | 132 |
* if we want to specifiy a single marker, it is not necessary to |
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
133 |
use a tuple as the value, the marker by itself (characters string) |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
134 |
is enough |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
135 |
* 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
|
136 |
and the context position (or when this one is not ambigous), we can simply |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
137 |
use the name of the relation type as the key |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
138 |
* if we want a marker to apply independently from the target entity type, |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
139 |
we have to use the string `*` as the target entity type |
93
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
140 |
|
9c919a47e140
[doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff
changeset
|
141 |
|
130
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
142 |
Please note that this dictionnary is *treated at the time the class is created*. |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
143 |
It is automatically merged with the parent class(es) (no need to copy the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
144 |
dictionnary from the parent class to modify it). Also, modify it after the |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
145 |
class is created will not have any effect... |
213f07dffde3
[doc] Translation to english.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
127
diff
changeset
|
146 |
|
292
2d9e83c34b23
[doc] Renaming of part II sub-sections accordingly.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
287
diff
changeset
|
147 |
.. include:: B0031-define-entities.en.txt |