Beispiel #1
0
def deferflatten(stan, ctx, writer):
    finished = Deferred()

    iterable = flat.iterflatten(
        stan, ctx, writer, lambda D: isinstance(D, Deferred))

    def drive():
        try:
            deferred, returner = iterable.next()
            def cb(result):
                returner(result)
                drive()
                return result
            def eb(failure):
                finished.errback(failure)
                return failure
            cfac = getCtx('CursorFactory')
            if cfac:
                deferred.addCallback(cfac.store.transback, cb).addErrback(cfac.store.transback, eb)
            else:
                deferred.addCallback(cb).addErrback(eb)
        except StopIteration:
            finished.callback('')

    drive()
    return finished
Beispiel #2
0
def deferflatten(stan, ctx, writer):
    finished = Deferred()

    iterable = flat.iterflatten(stan, ctx, writer,
                                lambda D: isinstance(D, Deferred))

    def drive():
        try:
            deferred, returner = iterable.next()

            def cb(result):
                returner(result)
                drive()
                return result

            def eb(failure):
                finished.errback(failure)
                return failure

            cfac = getCtx('CursorFactory')
            if cfac:
                deferred.addCallback(cfac.store.transback,
                                     cb).addErrback(cfac.store.transback, eb)
            else:
                deferred.addCallback(cb).addErrback(eb)
        except StopIteration:
            finished.callback('')

    drive()
    return finished
Beispiel #3
0
 def renderSynchronously(self):
     """Render this page synchronously, returning a string result immediately.
     Raise an exception if a Deferred is required to complete the rendering
     process.
     """
     io = StringIO()
     ctx = PageContext(tag=self)
     self.rememberStuff(ctx)
     doc = self.docFactory.load(ctx)
     ctx =  WovenContext(ctx, tags.invisible[doc])
     def raiseAlways(item):
         raise NotImplementedError("renderSynchronously can not support"
             " rendering: %s" % (item, ))
     list(flat.iterflatten(doc, ctx, io.write, raiseAlways))
     return io.getvalue()
Beispiel #4
0
    def renderSynchronously(self, ctx=None):
        """Render this page synchronously, returning a string result immediately.
        Raise an exception if a Deferred is required to complete the rendering
        process.
        """
        io = StringIO()

        ctx = PageContext(parent=ctx, tag=self)
        self.rememberStuff(ctx)
        doc = self.docFactory.load(ctx)
        ctx = WovenContext(ctx, tags.invisible[doc])

        def raiseAlways(item):
            raise NotImplementedError("renderSynchronously can not support"
                                      " rendering: %s" % (item, ))

        list(flat.iterflatten(doc, ctx, io.write, raiseAlways))

        return io.getvalue()
Beispiel #5
0
def deferflatten(stan, ctx, writer):
    finished = defer.Deferred()
    iterable = flat.iterflatten(stan, ctx, writer, _isDeferred)
    _drive(iterable, finished)
    return finished
Beispiel #6
0
def deferflatten(stan, ctx, writer):
    finished = defer.Deferred()
    iterable = flat.iterflatten(stan, ctx, writer, _isDeferred)
    _drive(iterable, finished)
    return finished