Commit 9c95618d authored by Jérome Perrin's avatar Jérome Perrin

Enable History tab and ZMI comparision

add utility methods



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10437 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87d40636
...@@ -26,14 +26,15 @@ ...@@ -26,14 +26,15 @@
# #
############################################################################## ##############################################################################
from struct import unpack
import warnings import warnings
import ExtensionClass import ExtensionClass
from Globals import InitializeClass, DTMLFile, PersistentMapping from Globals import InitializeClass, DTMLFile, PersistentMapping
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permission import pname, Permission from AccessControl.Permission import pname, Permission
from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain
import OFS.History
from OFS.History import Historical
from Products.CMFCore.PortalContent import PortalContent from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
...@@ -330,7 +331,11 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -330,7 +331,11 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
method = WorkflowMethod(method, method_id) method = WorkflowMethod(method, method_id)
setattr(prop_holder, method_id, method) setattr(prop_holder, method_id, method)
class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5PropertyManager ): class Base( CopyContainer,
PortalContent,
ActiveObject,
OFS.History.Historical,
ERP5PropertyManager ):
""" """
This is the base class for all ERP5 Zope objects. This is the base class for all ERP5 Zope objects.
It defines object attributes which are necessary to implement It defines object attributes which are necessary to implement
...@@ -416,6 +421,14 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -416,6 +421,14 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
return None return None
def manage_historyCompare(self, rev1, rev2, REQUEST,
historyComparisonResults=''):
return Base.inheritedAttribute('manage_historyCompare')(
self, rev1, rev2, REQUEST,
historyComparisonResults=OFS.History.html_diff(
pformat(rev1.showDict()),
pformat(rev2.showDict())))
def _aq_dynamic(self, id): def _aq_dynamic(self, id):
ptype = self.portal_type ptype = self.portal_type
...@@ -540,6 +553,14 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -540,6 +553,14 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
from ZODB.utils import oid_repr from ZODB.utils import oid_repr
return oid_repr(self._p_oid) return oid_repr(self._p_oid)
def getSerial(self):
"""Return ODB Serial."""
return self._p_serial
def getHistorySerial(self):
"""Return ODB Serial, in the same format used for history keys"""
return '.'.join([str(x) for x in unpack('>HHHH', self._p_serial)])
# Utils # Utils
def _getCategoryTool(self): def _getCategoryTool(self):
return aq_inner(self.getPortalObject().portal_categories) return aq_inner(self.getPortalObject().portal_categories)
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_self from Acquisition import aq_base, aq_self
from OFS.History import Historical
import ExtensionClass import ExtensionClass
from Products.CMFCore.utils import _getAuthenticatedUser from Products.CMFCore.utils import _getAuthenticatedUser
...@@ -293,6 +294,7 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn): ...@@ -293,6 +294,7 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
manage_options = ( CMFBTreeFolder.manage_options + manage_options = ( CMFBTreeFolder.manage_options +
Historical.manage_options +
CMFCatalogAware.manage_options CMFCatalogAware.manage_options
) )
# Declarative properties # Declarative properties
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment