-
Notifications
You must be signed in to change notification settings - Fork 56
/
versions.txt
155 lines (117 loc) · 5.37 KB
/
versions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Faceted versions (invalidate squid cache)
=========================================
As there is practical impossible to generate all combinations of parameters
for faceted_query, faceted_counter and tagscloud_counter and you can not
invalidate squid cache by regular expressions a version control system was
implemented. This way a version string like an eTag is added to query.
Squid or any other proxy cache system will see this as a new request and will
return it from memcache or zope and then will cache it with the new key.
This is invisible for end users and even for managers.
Other advantage of this solution is that it is ''proxy cache system'' independent
and, let's say that, by mistake, you edit a hidden widget, for example you hit
'''Unhide''' button. In the '''Purging''' implementation you would lose all
squid cache just because your mouse jumps from time to time :).
With this versioning system, you can just '''Hide''' the widget back and
everyting is like before. Why? Because this version eTag is generated from
hidden widgets default values, so you'll always be able to return to a
previous version without loosing proxy cache.
What if I want to generate another version id even if faceted configuration
didn't change?
You can do that by adding an ETag widget. See ETag section in this document.
Set up
------
Setup sandbox
>>> self.loginAsPortalOwner()
>>> fid = portal.invokeFactory('Folder', 'sandbox')
>>> sandbox = portal._getOb(fid)
>>> sandbox.setLanguage('en')
>>> request = sandbox.REQUEST
>>> from zope.component import getMultiAdapter
>>> subtyper = getMultiAdapter((sandbox, request), name=u'faceted_subtyper')
>>> subtyper.enable()
Let's cleanup default criteria to avoid surprises
>>> from eea.facetednavigation.interfaces import ICriteria
>>> cids = ICriteria(sandbox).keys()
>>> for cid in cids:
... ICriteria(sandbox).delete(cid)
>>> ICriteria(sandbox).keys()
[]
Add some criteria
>>> handler = getMultiAdapter((sandbox, request), name=u'faceted_configure')
>>> _ = handler(addPropertiesWidget_button='Add',
... wtype='text', wposition='left', title='Text widget',
... index='Title', default='water')
>>> _ = handler(addPropertiesWidget_button='Add',
... wtype='radio', wposition='right', title='Radio widget',
... index='portal_type', catalog='portal_catalog', default='Folder')
Versions
--------
If there is no hidden widget there is no version
>>> version = getMultiAdapter((sandbox, request), name=u'faceted_version')
>>> version.key
''
Let's hide/unhide widgets
>>> _ = handler(updateCriterion_button='Update', cid='c1', hidden=1)
>>> version.key
'89f6018fbb8f5926acea2139621744cc'
>>> _ = handler(updateCriterion_button='Update', cid='c0', hidden=1)
>>> version.key
'7cf3781dbb4527d35ecf23fac66922bc'
>>> _ = handler(updateCriterion_button='Update', cid='c0', hidden=False)
>>> version.key
'89f6018fbb8f5926acea2139621744cc'
Version key is computed by widget visibility and default value. So let's check
version remain the same if we change other widget properties:
>>> _ = handler(updateCriterion_button='Update', cid='c1', title='Another title')
>>> version.key
'89f6018fbb8f5926acea2139621744cc'
>>> _ = handler(updateCriterion_button='Update', cid='c1', catalog='')
>>> version.key
'89f6018fbb8f5926acea2139621744cc'
Ok, now let's change the default value
>>> _ = handler(updateCriterion_button='Update', cid='c1', default='Document')
>>> version.key
'107f7c650d8e638bba3f3ef5120379fd'
Also, if there is no default value for hidden widgets there is no version
>>> _ = handler(updateCriterion_button='Update', cid='c1', default='')
>>> version.key
''
Same for 'all' value for default
>>> _ = handler(updateCriterion_button='Update', cid='c1', default='all')
>>> version.key
''
Some widgets use operator (AND/OR) in their query and this can affect results
even if they are visible widgets
>>> _ = handler(addPropertiesWidget_button='Add',
... wtype='checkbox', wposition='left', title='Checkbox widget',
... index='object_provides', operator='and',
... catalog='portal_catalog', default='')
>>> version.key
'354a959cafede303b6c0557b4ddbcfa5'
>>> _ = handler(updateCriterion_button='Update', cid='c2', operator='or')
>>> version.key
'ce44ef2db1e18aa150d87ef70e0d2b5d'
>>> _ = handler(updateCriterion_button='Update', cid='c2', operator='')
>>> version.key
''
ETag widget
-----------
There is a special faceted widget called ETag that you can use in order to
generate another version id.
>>> _ = handler(addPropertiesWidget_button='Add',
... wtype='etag', wposition='left', title='ETag',
... default='1.0', hidden=1)
>>> version.key
'5160e24ff850c88f366f31e36572c528'
It is not displayed in view mode even if it's not hidden but in order to be
used by versioning generator it has to be hidden.
>>> _ = handler(updateCriterion_button='Update', cid='c3', hidden=0)
>>> version.key
''
>>> _ = handler(updateCriterion_button='Update', cid='c3', hidden=1)
>>> version.key
'5160e24ff850c88f366f31e36572c528'
Changing it's default value will generate another version id, of course
>>> _ = handler(updateCriterion_button='Update', cid='c3', default='1.1')
>>> version.key
'5a4eb6b31c9d4f08af3df7ac689d9ef1'