equal
deleted
inserted
replaced
75 """Returns the logic of the enclosing scope |
75 """Returns the logic of the enclosing scope |
76 """ |
76 """ |
77 |
77 |
78 return self._scope_logic |
78 return self._scope_logic |
79 |
79 |
|
80 def getScopeDepth(self): |
|
81 """ |
|
82 """ |
|
83 |
|
84 if self._scope_logic: |
|
85 return 1 + self._scope_logic.logic.getScopeDepth() |
|
86 |
|
87 return 0 |
|
88 |
80 def _updateField(self, model, name, value): |
89 def _updateField(self, model, name, value): |
81 """Hook called when a field is updated. |
90 """Hook called when a field is updated. |
82 |
91 |
83 Base classes should override if any special actions need to be |
92 Base classes should override if any special actions need to be |
84 taken when a field is updated. The field is not updated if the |
93 taken when a field is updated. The field is not updated if the |
224 """ |
233 """ |
225 |
234 |
226 key_name = self.getKeyNameForFields(kwargs) |
235 key_name = self.getKeyNameForFields(kwargs) |
227 |
236 |
228 if key_name: |
237 if key_name: |
229 entity = self._model.get_by_key_name(key_name) |
238 entity = self.getFromKeyName(key_name) |
230 else: |
239 else: |
231 entity = None |
240 entity = None |
232 |
241 |
233 return entity |
242 return entity |
234 |
|
235 |
243 |
236 def getFromFieldsOr404(self, **fields): |
244 def getFromFieldsOr404(self, **fields): |
237 """Like getFromFields but expects to find an entity. |
245 """Like getFromFields but expects to find an entity. |
238 |
246 |
239 Raises: |
247 Raises: |
256 'There is no "%(name)s" where %(pairs)s.') % { |
264 'There is no "%(name)s" where %(pairs)s.') % { |
257 'name': self._name, 'pairs': joined_pairs} |
265 'name': self._name, 'pairs': joined_pairs} |
258 |
266 |
259 raise out_of_band.Error(msg, status=404) |
267 raise out_of_band.Error(msg, status=404) |
260 |
268 |
261 |
|
262 def getIfFields(self, fields): |
269 def getIfFields(self, fields): |
263 """Like getFromFieldsOr404 but returns None if not all fields are set |
270 """Like getFromFieldsOr404 but returns None if not all fields are set |
264 |
271 |
265 Raises: |
272 Raises: |
266 out_of_band.Error if no User entity is found and all fields were set |
273 out_of_band.Error if no User entity is found and all fields were set |
268 |
275 |
269 if not all(fields.values()): |
276 if not all(fields.values()): |
270 return None |
277 return None |
271 |
278 |
272 return self.getFromFieldsOr404(**fields) |
279 return self.getFromFieldsOr404(**fields) |
273 |
|
274 |
280 |
275 def getKeyNameForFields(self, fields): |
281 def getKeyNameForFields(self, fields): |
276 """Return a Datastore key_name for a Entity from the specified fields. |
282 """Return a Datastore key_name for a Entity from the specified fields. |
277 |
283 |
278 Args: |
284 Args: |