1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 '''
20 Backends should derive from this class.
21
22 Created on Jun 27, 2011
23
24 @author: tmetsch
25 '''
26
27
38
39
41 '''
42 Checks if an attribute is mutable. Return True if so.
43
44 category -- The category which defines the attribute.
45 attribute_name -- The name of the attribute.
46 '''
47 if category.attributes[attribute_name] == 'mutable':
48 return True
49 else:
50 return False
51
52
54 '''
55 Checks if an attribute is required. Return True if so.
56
57 category -- The category which defines the attribute.
58 attribute_name -- The name of the attribute.
59 '''
60 if category.attributes[attribute_name] == 'required':
61 return True
62 else:
63 return False
64
65
67 '''
68 Returns true if the action is currently applicable.
69
70 entity -- The current entity.
71 action -- The action to test for.
72 '''
73 if action in entity.actions and action in entity.kind.actions:
74 return True
75 else:
76 return False
77
78
80 '''
81 A prototype backend which essentially does nothing.
82
83 Use this Backend for your Resource and Link types.
84
85 Note that it can happen that an entity has more than one backend assigned
86 (this is the case when it has a couple of mixins). But you can assign
87 multiple kinds to one backend.
88 '''
89
90 - def create(self, entity, extras):
91 '''
92 Call the Resource Management and create this entity.
93
94 entity -- The entity which is to be created.
95 extras -- Any extra arguments which are defined by the user.
96 '''
97 pass
98
100 '''
101 Call the Resource Management and refresh this entity so the client gets
102 up to date information.
103
104 entity -- The entity which is to be retrieved.
105 extras -- Any extra arguments which are defined by the user.
106 '''
107 pass
108
109 - def update(self, old, new, extras):
110 '''
111 Call the Resource Management and update this entity.
112
113 It is up to the backend implementation to decide which information from
114 new if copied into old.
115
116 Note that the new entity might no have all the information the old one
117 had.
118
119 old -- The old entity which is to be updated.
120 new -- The new entity holding the updated information.
121 extras -- Any extra arguments which are defined by the user.
122 '''
123 pass
124
125 - def replace(self, old, new, extras):
126 '''
127 Call the Resource Management and update this entity. This is
128 essentially a full update (Which allows removal of attributes for
129 example).
130
131 It is up to the backend implementation to decide which information from
132 new if copied into old. So if you really want to replace old with new
133 you need to have an old.* = new.* somewhere here (RECOMMENDED).
134
135 old -- The old entity which is to be updated.
136 new -- The new entity holding the updated information.
137 extras -- Any extra arguments which are defined by the user.
138 '''
139 pass
140
141 - def delete(self, entity, extras):
142 '''
143 Call the Resource Management and delete this entity.
144
145 entity -- The entity which is to be deleted.
146 extras -- Any extra arguments which are defined by the user.
147 '''
148 pass
149
150
152 '''
153 A prototype backend which essentially does nothing.
154
155 Use this Backend for Action types.
156 '''
157
158
159
160
161 - def action(self, entity, action, attributes, extras):
162 '''
163 Call the Resource Management and perform this action.
164
165 entity -- The entity on which the action is going to be performed.
166 action -- The action category definition.
167 attributes -- The acctributes for this action.
168 extras -- Any extra arguments which are defined by the user.
169 '''
170 pass
171
172
174 '''
175 A prototype backend which essentially does nothing.
176
177 Use this Backend for Mixin types.
178 '''
179
180 pass
181
182
184 '''
185 A Backend for mixins defined by users.
186
187 DO NOT USE THIS CLASS IN YOUR IMPLEMENTATION!
188 '''
189
190 pass
191