[Zope-CMF] modification date should not be bobobase_modification_time

Florent Guillaume fg@nuxeo.com
Mon, 22 Apr 2002 17:49:20 +0000 (UTC)


Ah, the convergence of ideas :-)

I'm using pretty much the exact same code, with the following
differences:

- modified() sets modification_date to the bobobase_modification_time()
  if it didn't exist,

- setModificationDate's argument is optionnal, meaning set the current
  date.

- _editMetadata always calls setModificationDate() as a policy.

Florent

Rémi Houdaille  <remi.houdaille@akeirou.com> wrote:
> Summary
> 
>    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.
> 
> Problem encountered
> 
>    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 :(
> 
> Proposed solution
> 
>    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 :
> 
>    def Date(self):
>        "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()
>        return date.ISO()
> 
>    def ModificationDate(self):
>        """
>        Dublin Core element - date resource last modified.
>        """
>        return self.modified().ISO()
> 
>    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()
> 
>    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.
> 
> Discussion
> 
>    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.
> 
> Rémi Houdaille
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
> 
> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
> requests
> 


-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com