本文整理汇总了Python中eea.facetednavigation.interfaces.ICriteria.edit方法的典型用法代码示例。如果您正苦于以下问题:Python ICriteria.edit方法的具体用法?Python ICriteria.edit怎么用?Python ICriteria.edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eea.facetednavigation.interfaces.ICriteria
的用法示例。
在下文中一共展示了ICriteria.edit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import edit [as 别名]
def edit(self, cid, **kwargs):
""" See IFacetedCriterionHandler
"""
criteria = ICriteria(self.context)
widget = criteria.widget(cid=cid)
criterion = criteria.get(cid)
if kwargs.pop('__new__', False):
criterion = criterion.__class__(cid='c0')
widget = widget(self.context, self.request, criterion)
wid = kwargs.pop('widget', None)
properties = self.extractData(widget, **kwargs)
if wid:
properties['widget'] = wid
update = {}
for prop, value in properties.items():
form_key = 'faceted.%s.%s' % (cid, prop)
if form_key not in kwargs and value is None:
continue
update[prop] = value
if update:
criteria.edit(cid, **update)
if widget.hidden:
notify(FacetedGlobalSettingsChangedEvent(self.context))
elif set(['hidden', 'operator']).intersection(update.keys()):
notify(FacetedGlobalSettingsChangedEvent(self.context))
return self._redirect('Changes saved')
示例2: edit
# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import edit [as 别名]
def edit(self, cid, **kwargs):
""" See IFacetedCriterionHandler
"""
kwargs = self._request_form(kwargs)
criteria = ICriteria(self.context)
widget = criteria.widget(cid=cid)
fields = widget.edit_schema.keys()[:]
update = {}
for prop in fields:
new_value = kwargs.get(prop, None)
if new_value is None:
continue
update[prop] = new_value
if update:
criteria.edit(cid, **update)
if widget.hidden:
notify(FacetedGlobalSettingsChangedEvent(self.context))
elif set(['hidden', 'operator']).intersection(update.keys()):
notify(FacetedGlobalSettingsChangedEvent(self.context))
return self._redirect('Changes saved')