183 bootstrap_schema = True |
183 bootstrap_schema = True |
184 |
184 |
185 # check user's state at login time |
185 # check user's state at login time |
186 consider_user_state = True |
186 consider_user_state = True |
187 |
187 |
188 # XXX hooks control stuff should probably be on the session, not on the config |
|
189 |
|
190 # hooks activation configuration |
|
191 # all hooks should be activated during normal execution |
|
192 disabled_hooks_categories = set() |
|
193 enabled_hooks_categories = set() |
|
194 ALLOW_ALL = object() |
|
195 DENY_ALL = object() |
|
196 hooks_mode = ALLOW_ALL |
|
197 |
|
198 @classmethod |
|
199 def set_hooks_mode(cls, mode): |
|
200 assert mode is cls.ALLOW_ALL or mode is cls.DENY_ALL |
|
201 oldmode = cls.hooks_mode |
|
202 cls.hooks_mode = mode |
|
203 return oldmode |
|
204 |
|
205 @classmethod |
|
206 def disable_hook_category(cls, *categories): |
|
207 changes = set() |
|
208 if cls.hooks_mode is cls.DENY_ALL: |
|
209 for category in categories: |
|
210 if category in cls.enabled_hooks_categories: |
|
211 cls.enabled_hooks_categories.remove(category) |
|
212 changes.add(category) |
|
213 else: |
|
214 for category in categories: |
|
215 if category not in cls.disabled_hooks_categories: |
|
216 cls.disabled_hooks_categories.add(category) |
|
217 changes.add(category) |
|
218 return changes |
|
219 |
|
220 @classmethod |
|
221 def enable_hook_category(cls, *categories): |
|
222 changes = set() |
|
223 if cls.hooks_mode is cls.DENY_ALL: |
|
224 for category in categories: |
|
225 if category not in cls.enabled_hooks_categories: |
|
226 cls.enabled_hooks_categories.add(category) |
|
227 changes.add(category) |
|
228 else: |
|
229 for category in categories: |
|
230 if category in cls.disabled_hooks_categories: |
|
231 cls.disabled_hooks_categories.remove(category) |
|
232 changes.add(category) |
|
233 return changes |
|
234 |
|
235 @classmethod |
|
236 def is_hook_activated(cls, hook): |
|
237 return cls.is_hook_category_activated(hook.category) |
|
238 |
|
239 @classmethod |
|
240 def is_hook_category_activated(cls, category): |
|
241 if cls.hooks_mode is cls.DENY_ALL: |
|
242 return category in cls.enabled_hooks_categories |
|
243 return category not in cls.disabled_hooks_categories |
|
244 |
|
245 # should some hooks be deactivated during [pre|post]create script execution |
188 # should some hooks be deactivated during [pre|post]create script execution |
246 free_wheel = False |
189 free_wheel = False |
247 |
190 |
248 # list of enables sources when sources restriction is necessary |
191 # list of enables sources when sources restriction is necessary |
249 # (eg repository initialization at least) |
192 # (eg repository initialization at least) |