Back to index

plone3  3.1.7
update.py
Go to the documentation of this file.
00001 from Acquisition import aq_inner
00002 from Products.Archetypes.interfaces import IBaseObject
00003 from Products.CMFCore.utils import getToolByName
00004 from Products.CMFPlone import PloneMessageFactory as _
00005 from Products.Five import BrowserView
00006 from Products.statusmessages.interfaces import IStatusMessage
00007 from plone.app.linkintegrity.handlers import modifiedArchetype
00008 
00009 
00010 class UpdateView(BrowserView):
00011 
00012     def __call__(self):
00013         context = aq_inner(self.context)
00014         request = aq_inner(self.request)
00015         clicked = request.form.has_key
00016         if clicked('update') or clicked('delete_all'):
00017             count = self.update()
00018             msg = _(u'linkintegrity_update_info',
00019                 default=u'Link integrity information updated for ${count} item(s).',
00020                 mapping={'count': count})
00021             IStatusMessage(request).addStatusMessage(msg, type='info')
00022             request.RESPONSE.redirect(getToolByName(context, 'portal_url')())
00023         elif clicked('cancel'):
00024             msg = _(u'Update cancelled.')
00025             IStatusMessage(request).addStatusMessage(msg, type='info')
00026             request.RESPONSE.redirect(getToolByName(context, 'portal_url')())
00027         else:
00028             return self.index()
00029 
00030     def update(self):
00031         catalog = getToolByName(self.context, 'portal_catalog')
00032         count = 0
00033         for brain in catalog(Language='all'):
00034             obj = brain.getObject()
00035             if IBaseObject.providedBy(obj):
00036                 modifiedArchetype(obj, 'dummy event parameter')
00037                 count += 1
00038         return count
00039