try / except pour démarrer sans Solr.
[Plinn.git] / skins / control / save_search_as_topic.py
1 ##parameters=
2 from Products.CMFCore.utils import getToolByName
3 from Products.Plinn.utils import makeValidId
4 from Products.Plinn.utils import translate
5 _ = lambda msg: translate(msg, context)
6 mtool = getToolByName(context, 'portal_membership')
7 homedir = mtool.getHomeFolder()
8
9 form = context.REQUEST.form.copy()
10 for k, v in form.items() :
11 if hasattr(v, 'has_key') :
12 form[k] = dict(v)
13
14 title = form.pop('topic_title')
15 topic_id = makeValidId(homedir, title)
16 id = homedir.invokeFactory('Topic', topic_id, title=title)
17 topic = getattr(homedir, id)
18 topic.loadSearchQuery(form)
19
20 context.setStatus(True, _('Topic added.'))
21 try :
22 ajax = form.pop('ajax')
23 except KeyError :
24 ajax = ''
25 return context.setRedirect(topic, 'object/view', ajax=ajax, syncFragments = ['Breadcrumbs', 'rightCell'])