from zeit.edit.rule import glob
import itertools
import zeit.content.cp.interfaces
import zope.component
import zope.interface


class CenterPageValidator(zeit.edit.rule.RecursiveValidator):

    zope.component.adapts(zeit.content.cp.interfaces.ICenterPage)

    @property
    def children(self):
        areas = self.context.values()
        return itertools.chain(areas, *[a.values() for a in areas])


@glob(zeit.content.cp.interfaces.IRegion)
def is_region(context):
    return True


@glob(zope.interface.Interface)
def is_region(context):
    return False


@glob(zeit.content.cp.interfaces.IElement)
def region(context):
    return zeit.content.cp.interfaces.IRegion(context).__name__


@glob(zope.interface.Interface)
def region(context):
    return None


@glob(zeit.content.cp.interfaces.ITeaserBlock)
def layout(context):
    return context.layout.id


@glob(zope.interface.Interface)
def layout(context):
    return None


@glob(zeit.content.cp.interfaces.IBlock)
def content(context):
    return list(
        zeit.content.cp.interfaces.ICMSContentIterable(context, []))


@glob(zope.interface.Interface)
def cp_type(context):
    cp = zeit.content.cp.interfaces.ICenterPage(context, None)
    if cp is None:
        return None
    return cp.type

@@ -290,16 +290,140 @@
 (self):%0A
+        # WARNING: Does not include modules, only regions and areas.%0A        # Therefore rules for modules aren't executed.%0A
         

Add comment