Esempio n. 1
0
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)
Esempio n. 2
0
    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])
Esempio n. 3
0
def blogPostModified(post, event):
    post = removeAllProxies(post)

    blog = post.__parent__
    if IBlog.providedBy(blog):
        blog.update(post)
Esempio n. 4
0
def blogPostRemoved(post, event):
    if not sameProxiedObjects(post, event.original_event.object):
        return

    if IBlog.providedBy(post.__parent__):
        removeSecurityProxy(post.__parent__).remove(post)