5 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from mx.DateTime import now |
10 from datetime import datetime |
11 |
11 |
12 from cubicweb import UnknownProperty, ValidationError, BadConnectionId |
12 from cubicweb import UnknownProperty, ValidationError, BadConnectionId |
13 |
13 |
14 from cubicweb.common.uilib import soup2xhtml |
14 from cubicweb.common.uilib import soup2xhtml |
15 |
15 |
28 """before create a new entity -> set creation and modification date |
28 """before create a new entity -> set creation and modification date |
29 |
29 |
30 this is a conveniency hook, you shouldn't have to disable it |
30 this is a conveniency hook, you shouldn't have to disable it |
31 """ |
31 """ |
32 if not 'creation_date' in entity: |
32 if not 'creation_date' in entity: |
33 entity['creation_date'] = now() |
33 entity['creation_date'] = datetime.now() |
34 if not 'modification_date' in entity: |
34 if not 'modification_date' in entity: |
35 entity['modification_date'] = now() |
35 entity['modification_date'] = datetime.now() |
36 |
36 |
37 def setmtime_before_update_entity(session, entity): |
37 def setmtime_before_update_entity(session, entity): |
38 """update an entity -> set modification date""" |
38 """update an entity -> set modification date""" |
39 if not 'modification_date' in entity: |
39 if not 'modification_date' in entity: |
40 entity['modification_date'] = now() |
40 entity['modification_date'] = datetime.now() |
41 |
41 |
42 class SetCreatorOp(PreCommitOperation): |
42 class SetCreatorOp(PreCommitOperation): |
43 |
43 |
44 def precommit_event(self): |
44 def precommit_event(self): |
45 if self.eid in self.session.query_data('pendingeids', ()): |
45 if self.eid in self.session.query_data('pendingeids', ()): |