def getTextContentHistoryRevisionDictList(self, limit=100): """ TODO """ history_dict_list = self._p_jar.db().history(self._p_oid, size=limit) if history_dict_list is None: # Storage doesn't support history return () from struct import unpack from OFS.History import historicalRevision previous_text_content = None result = [] for history_dict in history_dict_list: text_content = historicalRevision(self, history_dict['tid']).getTextContent() if text_content and text_content != previous_text_content: history_dict['time'] = history_dict['time'] history_dict['user_name'] = history_dict['user_name'].strip() history_dict['key'] = '.'.join(map(str, unpack(">HHHH", history_dict['tid']))) del history_dict['tid'] del history_dict['size'] result.append(history_dict) previous_text_content = text_content return result
def getTextContentHistory(self, key): """Returns the text content of a previous version of the document. """ from struct import pack from OFS.History import historicalRevision serial = pack(*('>HHHH', ) + tuple(map(int, key.split('.')))) rev = historicalRevision(self, serial) return rev._baseGetTextContent()
def getTextContentHistory(self, key): """ TODO """ from struct import pack from OFS.History import historicalRevision serial = apply(pack, ('>HHHH',) + tuple(map(int, key.split('.')))) rev = historicalRevision(self, serial) return rev.getTextContent()
def pageRevision(self, rev): """ Get one of the previous revisions of this page object. The argument increases to select older revisions, eg revision 1 is the most recent version prior to the current one, revision 2 is the version before that, etc. """ rev = int(rev) try: historyentry = self.history()[rev] except (IndexError, AttributeError): # IndexError - we don't have a version that old # AttributeError - new object, no history yet, # due to creation of page in unit tests without # editing them yet - doesn't really happen in real use # I guess return None key = historyentry['key'] serial = apply(pack, ('>HHHH',)+tuple(map(atoi, split(key,'.')))) return historicalRevision(self, serial)