Example #1
0
    def test_preprocessorCollection(self):
        """
        Test that preprocessors from all the base classes of an instance are
        found, and that a preprocessor instance attribute overrides all of
        these.
        """
        a, b, c = object(), object(), object()

        class Base(object):
            preprocessors = [a]

        class OtherBase(object):
            preprocessors = [b]

        class Derived(Base, OtherBase):
            preprocessors = [c]

        inst = Derived()
        self.assertEqual(
            rend._getPreprocessors(inst),
            [a, b, c])

        d = object()
        inst.preprocessors = [d]
        self.assertEqual(
            rend._getPreprocessors(inst),
            [d])
Example #2
0
File: page.py Project: jpunwin/tums
 def rend(self, context, data):
     """
     Backwards compatibility stub.  This is only here so that derived
     classes can upcall to it.  It is not otherwise used in the rendering
     process.
     """
     context.remember(_OldRendererFactory(self), IRendererFactory)
     docFactory = self.docFactory
     if docFactory is None:
         raise MissingDocumentFactory(self)
     return docFactory.load(None, _getPreprocessors(self))
Example #3
0
File: page.py Project: StetHD/nevow
 def rend(self, context, data):
     """
     Backwards compatibility stub.  This is only here so that derived
     classes can upcall to it.  It is not otherwise used in the rendering
     process.
     """
     context.remember(_OldRendererFactory(self), IRendererFactory)
     docFactory = self.docFactory
     if docFactory is None:
         raise MissingDocumentFactory(self)
     return docFactory.load(None, _getPreprocessors(self))
Example #4
0
File: page.py Project: jpunwin/tums
    def render(self, request):
        """
        Load and return C{self.docFactory}.
        """
        rend = self.rend
        if rend.im_func is not Element.__dict__['rend']:
            context = _ctxForRequest(request, [], self, False)
            return rend(context, None)

        docFactory = self.docFactory
        if docFactory is None:
            raise MissingDocumentFactory(self)
        return docFactory.load(None, _getPreprocessors(self))
Example #5
0
File: page.py Project: StetHD/nevow
    def render(self, request):
        """
        Load and return C{self.docFactory}.
        """
        rend = self.rend
        if rend.im_func is not Element.__dict__['rend']:
            context = _ctxForRequest(request, [], self, False)
            return rend(context, None)

        docFactory = self.docFactory
        if docFactory is None:
            raise MissingDocumentFactory(self)
        return docFactory.load(None, _getPreprocessors(self))
Example #6
0
File: page.py Project: calston/tums
    def rend(self, ctx, data):
        # Unfortunately, we still need a context to make the rest of the
        # rendering process work.  A goal should be to elimate this completely.
        context = WovenContext()

        if self.docFactory is None:
            raise MissingDocumentFactory(self)

        preprocessors = _getPreprocessors(self)

        doc = self.docFactory.load(context, preprocessors)

        context.remember(self, IData)
        context.remember(self, IRenderer)
        context.remember(self, IRendererFactory)
        context.tag = invisible[doc]
        return context