[Zope-CMF] Historical revisions in CMF (was Re: CMF newbie questions)

Ausum Studio ausum_studio@hotmail.com
Wed, 26 Mar 2003 11:32:08 -0500


----- Original Message -----
From: "Terry Kerr" <terry@adroit.net>
(...)
> I would like the 'old' version of the article to remain published until
the new
> one is reviewd and published.  I realise this is probably quite difficult
to
> achieve since it would mean that the article object (which I actually
haven't
> created yet but will most likely be a python product) will need some sort
of
> versioning.  Simply creating a custom workflow cannot accomodate my
requirements
> I don't think.  Has anybody else solved a problem similar to this with the
CMF?

I've enabled CMF to handle revisions by allowing it to inherit from
OFS.History, on a experimental basis, and it works fine so far. If you want
to try it, open CMFCore/PortalContent.py with any editor an perform the
changes indicated down below. After you restart Zope, the "History" tab will
appear for all contentish objects, in the management interface. Starting
that point you'll need to provide methods (or modify existing ones) to
access those revisions. I'm including a simple history-viewer script.

A simple and general workaround in your case is to modify the view methods
of your content types to make them render the closest published revision (or
any other you indicate, based on your site's policy), when the object's
state is 'retracted' (yes, create that one). As currently there's no
relation between revisions and the workflow's review_history, as provided by
'portal_workflow.getInfoFor', one of your to-write methods might be one that
compares timestamps and returns the mentioned revision object.

I'll publish a How-to on this subject, provided there's no code conflicts
I'm not aware of. :)



Ausum




Modifications to PortalContent.py:

....................
    NoWL = 0
except ImportError:
    NoWL = 1

from OFS.History import Historical        # added line

class PortalContent(DynamicType, Historical, CMFCatalogAware, SimpleItem):
# added 'Historical'

    """
        Base class for portal objects.

        Provides hooks for reviewing, indexing, and CMF UI.
.......

and:
.........
                     + CMFCatalogAware.manage_options
                     + SimpleItem.manage_options
                     + Historical.manage_options     # added line
                     )

    security = ClassSecurityInfo()
.......

A basic python script to view the history information of any contentish
object:

# HistoryWatcher:
for item in context.manage_change_history():
    print
    for k,v in item.items():
        print k, ":", v
    historical_object = context.HistoricalRevisions[item['key']]
    print historical_object

return printed