def __iter__(self): for item in self.previous: pathkey = self.pathkey(*item.keys())[0] if not pathkey: yield item; continue type_ = item.get(self.flagkey, None) newtype = item.get('_type', None) if type_ != 'Blog' and newtype != 'Large Plone Folder': yield item; continue path = item[pathkey] obj = self.context.unrestrictedTraverse(path, None) if obj is None: # path doesn't exist yield item; continue if type_ == 'Blog' and newtype == 'Large Plone Folder': # mark as blog if not IWeblogEnhanced.providedBy(obj) and \ IPossibleWeblog.providedBy(obj): alsoProvides(obj, IWeblogEnhanced) event.notify(WeblogActivationEvent(obj)) yield item # reindex provided interfaces catalog = utils.getToolByName(self.context, 'portal_catalog') catalog.reindexIndex('object_provides', None)
def __call__(self): if IWeblogEnhanced.providedBy(self.context): # deactivate blog event.notify(WeblogDeactivationEvent(self.context)) noLongerProvides(self.context, IWeblogEnhanced) msg = 'blog deactivated' elif IPossibleWeblog.providedBy(self.context): alsoProvides(self.context, IWeblogEnhanced) event.notify(WeblogActivationEvent(self.context)) msg = 'blog activated' else: msg = 'not bloggable' # XXX This should set the status message with something like: # from Products.statusmessages.interfaces import IStatusMessage # IStatusMessage(self.request).addStatusMessage(msg, type='info') url = self.context.absolute_url() + '?portal_status_message=' + msg self.request.response.redirect(url)
def render(self): if not IWeblogEnhanced.providedBy(self.context): return super(ConditionalViewletManager, self).render() return u''
def can_deactivate(self): return IWeblogEnhanced.providedBy(self.context)
def can_activate(self): return IPossibleWeblog.providedBy(self.context) and \ not IWeblogEnhanced.providedBy(self.context)