[Zope-CMF] modification date should not be bobobase_modification_time
Wed, 10 Apr 2002 11:06:34 +0200
The DefaultDublinCoreImpl class in CFMDefault relies on
bobobase_modification_time() when determining the modification
time of an object. This is not quite appropriate,
and I believe that using a specific attribute to store the
modification time would be better.
I have built a simple application based on the CMF for management
of shared information with our customers. We recently moved our
web site from one server to another. For some reason, the move
was made by exporting the (CMF) sites to a .zexp and importing
it on the new Zope server.
From then on, the modification times of all content appeared
to be the date of the import. This not only impacts the
information you see when looking at a specific document,
but also makes news box and such things display the wrong list
of objects :(
I solved the problem by modifying the DefaultDublinCoreImpl
class and some dtml, in the following way :
1. Use an attribute modification_date to store and retrieve
the proper information. The modified() method relies on
this attribute, other methods call it and I added a method
to perform modification of the attribute.
The modified code is shown below :
"Dublin Core element - default date"
# Return effective_date if set, modification date otherwise
date = getattr(self, 'effective_date', None )
if date is None:
date = self.modified()
Dublin Core element - date resource last modified.
Dublin Core element - date resource last modified,
returned as DateTime.
# keep compatibility with old instances
# which do not have the modification_date attr
if hasattr(self, 'modification_date'):
def setModificationDate(self, date):
Dublin Core element - date resource was last modified
self.modification_date = self._datify(date)
2. Modify the xxx_edit.dtml files (I was based on CMF1.1
now it would be xxx_edit.py) so as to make a call to
setModificationDate(DateTime.DateTime()). I also have
specific creation script that I modified.
I did it this way because I didn't want to modifiy the
CMF itself (only my own application). If the modification
was to be included in the CMF, it should where appropriate
in the python code.
What do you think guys about this proposal?
One question which comes to me is when exactly the
modification_time should be changed: I currently do
not change it when only metadata changes. It is not
changed either when the object is cut/pasted somewhere.
Another one is to call setModificationDate() at appropriate
places in the code so that it is always kept at a correct value.