Paramétrage des dépendances.
[Plinn.git] / skins / content / changes_history.py
1 ##parameters=compare=''
2
3 from Products.Plinn.utils import getAdapterByInterface
4 options = {}
5 form = context.REQUEST.form
6 history = getAdapterByInterface(context, 'Products.Plinn.interfaces.IContentHistory', None)
7 comparison = None
8 resultsLength = 20
9 start = form.get('first_transaction',0)
10 stop = start + resultsLength
11 batchNavigation = None
12
13 if history is not None :
14 entries = history.listEntries(first=start, last=stop+1)
15
16 previous, next = None, None
17 if len(entries) == resultsLength + 1 :
18 entries = entries[0:-1]
19 next = start + resultsLength
20
21 if start > 0 :
22 previous = start - resultsLength
23
24 batchNavigation = {'previous':previous, 'next':next, 'current':start}
25
26 options['entries'] = entries
27 r = form.get('rightkey', entries[0]['key'])
28 try :
29 l = form.get('leftkey', entries[1]['key'])
30 except IndexError :
31 l = r
32
33 options['leftkey'] = l
34 options['rightkey'] = r
35 if compare :
36 comparison = history.compare(l, r)
37 else :
38 options['entries'] = None
39
40 options['comparison'] = comparison
41 options['batchNavigation'] = batchNavigation
42
43 return context.changes_history_template(**options)