278 if is_main_entity: # only execute linkto for the main entity |
278 if is_main_entity: # only execute linkto for the main entity |
279 self.execute_linkto(entity.eid) |
279 self.execute_linkto(entity.eid) |
280 return eid |
280 return eid |
281 |
281 |
282 def handle_formfield(self, form, field, rqlquery=None): |
282 def handle_formfield(self, form, field, rqlquery=None): |
283 eschema = form.edited_entity.e_schema |
283 entity = form.edited_entity |
|
284 eschema = entity.e_schema |
284 try: |
285 try: |
285 for field, value in field.process_posted(form): |
286 for field, value in field.process_posted(form): |
286 if not ( |
287 if not ( |
287 (field.role == 'subject' and field.name in eschema.subjrels) |
288 (field.role == 'subject' and field.name in eschema.subjrels) |
288 or |
289 or |
289 (field.role == 'object' and field.name in eschema.objrels)): |
290 (field.role == 'object' and field.name in eschema.objrels)): |
290 continue |
291 continue |
|
292 |
291 rschema = self._cw.vreg.schema.rschema(field.name) |
293 rschema = self._cw.vreg.schema.rschema(field.name) |
292 if rschema.final: |
294 if rschema.final: |
293 rqlquery.set_attribute(field.name, value) |
295 rqlquery.set_attribute(field.name, value) |
|
296 continue |
|
297 |
|
298 if entity.has_eid(): |
|
299 origvalues = set(data[0] for data in entity.related(field.name, field.role).rows) |
294 else: |
300 else: |
295 if form.edited_entity.has_eid(): |
301 origvalues = set() |
296 origvalues = set(entity.eid for entity in form.edited_entity.related(field.name, field.role, entities=True)) |
302 |
297 else: |
303 if value is None or value == origvalues: |
298 origvalues = set() |
304 continue # not edited / not modified / to do later |
299 if value is None or value == origvalues: |
305 |
300 continue # not edited / not modified / to do later |
306 if rschema.inlined and rqlquery is not None and field.role == 'subject': |
301 if rschema.inlined and rqlquery is not None and field.role == 'subject': |
307 self.handle_inlined_relation(form, field, value, origvalues, rqlquery) |
302 self.handle_inlined_relation(form, field, value, origvalues, rqlquery) |
308 elif form.edited_entity.has_eid(): |
303 elif form.edited_entity.has_eid(): |
309 self.handle_relation(form, field, value, origvalues) |
304 self.handle_relation(form, field, value, origvalues) |
310 else: |
305 else: |
311 form._cw.data['pending_others'].add( (form, field) ) |
306 form._cw.data['pending_others'].add( (form, field) ) |
312 |
307 except ProcessFormError as exc: |
313 except ProcessFormError as exc: |
308 self.errors.append((field, exc)) |
314 self.errors.append((field, exc)) |
309 |
315 |
310 def handle_inlined_relation(self, form, field, values, origvalues, rqlquery): |
316 def handle_inlined_relation(self, form, field, values, origvalues, rqlquery): |
311 """handle edition for the (rschema, x) relation of the given entity |
317 """handle edition for the (rschema, x) relation of the given entity |