42 but you'll use this one rarely. |
42 but you'll use this one rarely. |
43 """ |
43 """ |
44 |
44 |
45 __docformat__ = "restructuredtext en" |
45 __docformat__ = "restructuredtext en" |
46 |
46 |
|
47 |
47 from warnings import warn |
48 from warnings import warn |
|
49 |
|
50 import time |
48 |
51 |
49 from logilab.common import dictattr, tempattr |
52 from logilab.common import dictattr, tempattr |
50 from logilab.common.decorators import iclassmethod, cached |
53 from logilab.common.decorators import iclassmethod, cached |
51 from logilab.common.textutils import splitstrip |
54 from logilab.common.textutils import splitstrip |
52 from logilab.common.deprecation import deprecated |
55 from logilab.common.deprecation import deprecated |
347 self.uicfg_aff = self._cw.vreg['uicfg'].select( |
350 self.uicfg_aff = self._cw.vreg['uicfg'].select( |
348 'autoform_field', self._cw, entity=self.edited_entity) |
351 'autoform_field', self._cw, entity=self.edited_entity) |
349 self.uicfg_affk = self._cw.vreg['uicfg'].select( |
352 self.uicfg_affk = self._cw.vreg['uicfg'].select( |
350 'autoform_field_kwargs', self._cw, entity=self.edited_entity) |
353 'autoform_field_kwargs', self._cw, entity=self.edited_entity) |
351 self.add_hidden('__type', self.edited_entity.cw_etype, eidparam=True) |
354 self.add_hidden('__type', self.edited_entity.cw_etype, eidparam=True) |
|
355 |
352 self.add_hidden('eid', self.edited_entity.eid) |
356 self.add_hidden('eid', self.edited_entity.eid) |
|
357 self.add_generation_time() |
353 # mainform default to true in parent, hence default to True |
358 # mainform default to true in parent, hence default to True |
354 if kwargs.get('mainform', True) or kwargs.get('mainentity', False): |
359 if kwargs.get('mainform', True) or kwargs.get('mainentity', False): |
355 self.add_hidden(u'__maineid', self.edited_entity.eid) |
360 self.add_hidden(u'__maineid', self.edited_entity.eid) |
356 # If we need to directly attach the new object to another one |
361 # If we need to directly attach the new object to another one |
357 if '__linkto' in self._cw.form: |
362 if '__linkto' in self._cw.form: |
361 msg = self._cw._('entity linked') |
366 msg = self._cw._('entity linked') |
362 if msg: |
367 if msg: |
363 msgid = self._cw.set_redirect_message(msg) |
368 msgid = self._cw.set_redirect_message(msg) |
364 self.add_hidden('_cwmsgid', msgid) |
369 self.add_hidden('_cwmsgid', msgid) |
365 |
370 |
|
371 def add_generation_time(self): |
|
372 # NB repr is critical to avoid truncation of the timestamp |
|
373 self.add_hidden('__form_generation_time', repr(time.time()), |
|
374 eidparam=True) |
|
375 |
366 def add_linkto_hidden(self): |
376 def add_linkto_hidden(self): |
367 """add the __linkto hidden field used to directly attach the new object |
377 """add the __linkto hidden field used to directly attach the new object |
368 to an existing other one when the relation between those two is not |
378 to an existing other one when the relation between those two is not |
369 already present in the form. |
379 already present in the form. |
370 |
380 |