def blogPostMoved(post, event): id = getUtility(IIntIds).queryId(removeAllProxies(post)) if id is None: return if IBlog.providedBy(event.oldParent): removeSecurityProxy(event.oldParent).remove(post) if IBlog.providedBy(event.newParent): removeSecurityProxy(event.newParent).update(post)
def __call__(self, context): while True: if IBlog.providedBy(context): break if IDraftContent.providedBy(context): context = context.getLocation() if ISpace.providedBy(context): context = context.get('blog') break context = getattr(context, '__parent__', None) if context is None: break if context is None: return SimpleVocabulary(()) ids = getUtility(IIntIds) categories = [] for category in context['category'].values(): try: id = ids.getId(removeAllProxies(category)) except: continue term = SimpleTerm(id, str(id), category.title) term.description = category.description categories.append((category.title, term)) categories.sort() return SimpleVocabulary([term for title, term in categories])
def blogPostModified(post, event): post = removeAllProxies(post) blog = post.__parent__ if IBlog.providedBy(blog): blog.update(post)
def blogPostRemoved(post, event): if not sameProxiedObjects(post, event.original_event.object): return if IBlog.providedBy(post.__parent__): removeSecurityProxy(post.__parent__).remove(post)