[Zope-CMF] modification date should not be bobobase_modification_time
Tres Seaver
tseaver@zope.com
Wed, 10 Apr 2002 07:42:57 -0400
R=E9mi Houdaille wrote:
> Summary
>=20
> 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.
>=20
> Problem encountered
>=20
> 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.
>=20
> 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 :(
>=20
> Proposed solution
>=20
> I solved the problem by modifying the DefaultDublinCoreImpl
> class and some dtml, in the following way :
>=20
> 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 :
>=20
> def Date(self):
> "Dublin Core element - default date"
> # Return effective_date if set, modification date otherwise
> date =3D getattr(self, 'effective_date', None )
> if date is None:
> date =3D self.modified()
> return date.ISO()
>=20
> def ModificationDate(self):
> """
> Dublin Core element - date resource last modified.
> """
> return self.modified().ISO()
>=20
> def modified(self):
> """
> 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'):
> return self.modification_date
> return self.bobobase_modification_time()
>=20
> def setModificationDate(self, date):
> """
> Dublin Core element - date resource was last modified
> """
> self.modification_date =3D self._datify(date)
>=20
> 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.
>=20
> 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.
>=20
> Discussion
>=20
> What do you think guys about this proposal?
I like it very much -- I have been regretting the choice to use=20
'bobobase_modification_time' almost from the first day I made it!
> 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.
If we call 'setModificationDate' in the skins (the PythonScripts which , =
then
different sites can vary the policy by customizing. Perhaps calling it on=
ly
in the skin methods which update the content (not the metadata, nor workf=
low)
is the Right Thing (TM) for a default? To do anything more complicated, w=
e
would have to add policy, and UI for administering it, to the metadata to=
ol.
> Another one is to call setModificationDate() at appropriate places in =
the
> code so that it is always kept at a correct value.
Tres.
--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com