예제 #1
0
 def remove(self):
     tag = self.request.form.get('tag')
     catalog = api.portal.get_tool('portal_catalog')
     for brain in catalog(Subject=tag)[:self.remove_size]:
         obj = brain.getObject()
         bdata = ICategorization(obj, None)
         if bdata:
             if tag in bdata.subjects:
                 tags = list(bdata.subjects)
                 tags.remove(tag)
                 bdata.subjects = tuple(tags)
                 obj.reindexObject(idxs=['Subject'])
     try:
         total = len(catalog._catalog.getIndex('Subject')._index[tag])
     except Exception:
         total = 0
     return {'success': True, 'tag': tag, 'total': total}