Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Static Private Attributes
ATContentTypes.lib.historyaware.HistoryAwareMixin Class Reference
Inheritance diagram for ATContentTypes.lib.historyaware.HistoryAwareMixin:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.lib.historyaware.HistoryAwareMixin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getHistorySource
def getLastEditor
def getDocumentComparisons

Static Public Attributes

tuple security = ClassSecurityInfo()
tuple actions

Static Private Attributes

tuple __implements__ = (IHistoryAware ,)

Detailed Description

History aware mixin class

Shows a unified diff history of the content

This mixin is using some low level functions of the ZODB to get the last
transaction states (versions) of the current object. Older histories will
disapear after packing the database so DO NOT rely on the history
functionality. It's more a gimmick and nice helper to reviewers and site
managers.

Definition at line 39 of file historyaware.py.


Member Function Documentation

def ATContentTypes.lib.historyaware.HistoryAwareMixin.getDocumentComparisons (   self,
  max = 10,
  filterComment = 0 
)
Get history as unified diff

Definition at line 89 of file historyaware.py.

00089 
00090     def getDocumentComparisons(self, max=10, filterComment=0):
00091         """Get history as unified diff
00092         """
00093         mTool = getToolByName(self, 'portal_membership')
00094 
00095         histories = list(self.getHistories())
00096         if max > len(histories):
00097             max = len(histories)
00098 
00099         lst = []
00100 
00101         for revisivon in range(1, max):
00102 
00103             oldObj, oldTime, oldDesc, oldUser = histories[revisivon]
00104             newObj, newTime, newDesc, newUser = histories[revisivon-1]
00105 
00106             oldText  = oldObj.getHistorySource().split("\n")
00107             newText  = newObj.getHistorySource().split("\n")
00108             # newUser is a string 'user' or 'folders to acl_users user'
00109             member   = mTool.getMemberById(newUser.split(' ')[-1])
00110 
00111             lines = [
00112                      html_quote(line)
00113                      for line in difflib.unified_diff(oldText, newText)
00114                     ][3:]
00115 
00116             description = newDesc
00117             if filterComment:
00118                 relativUrl = self.absolute_url(1)
00119                 description = '<br />\n'.join(
00120                               [line
00121                                for line in description.split('\n')
00122                                if line.find(relativUrl) != -1]
00123                               )
00124             else:
00125                 description.replace('\n', '<br />\n')
00126 
00127             if lines:
00128                 lst.append({
00129                             'lines'       : lines,
00130                             'oldTime'     : oldTime,
00131                             'newTime'     : newTime,
00132                             'description' : description,
00133                             'user'        : newUser,
00134                             'member'      : member
00135                            })
00136         return lst
00137 
00138 InitializeClass(HistoryAwareMixin)

Here is the call graph for this function:

get source for HistoryAwareMixin

Must return a (raw) string

Definition at line 65 of file historyaware.py.

00065 
00066     def getHistorySource(self):
00067         """get source for HistoryAwareMixin
00068 
00069         Must return a (raw) string
00070         """
00071         primary = self.getPrimaryField()
00072         if primary:
00073             return primary.getRaw(self)
00074         else:
00075             return ''

Here is the call graph for this function:

Returns the user name of the last editor.

Returns None if no last editor is known.

Definition at line 77 of file historyaware.py.

00077 
00078     def getLastEditor(self):
00079         """Returns the user name of the last editor.
00080 
00081         Returns None if no last editor is known.
00082         """
00083         histories = list(self.getHistories(1))
00084         if not histories:
00085             return None
00086         user = histories[0][3].split(" ")[-1].strip()
00087         return  user

Here is the call graph for this function:


Member Data Documentation

tuple ATContentTypes.lib.historyaware.HistoryAwareMixin.__implements__ = (IHistoryAware ,) [static, private]

Definition at line 51 of file historyaware.py.

Initial value:
({
        'id'          : 'history',
        'name'        : 'History',
        'action'      : 'string:${object_url}/atct_history',
        'permissions' : (ATCTPermissions.ViewHistory, ),
        'visible' : False,
         },
    )

Definition at line 55 of file historyaware.py.

tuple ATContentTypes.lib.historyaware.HistoryAwareMixin.security = ClassSecurityInfo() [static]

Definition at line 53 of file historyaware.py.


The documentation for this class was generated from the following file: