Example #1
0
 def __init__(self, *a, **kw):
     LivePage.__init__(self)
     # Update the mapping of known JavaScript modules so that the
     # client-side code for this example can be found and served to the
     # browser.
     self.jsModules.mapping['CalculatorDemo'] = sibling(
         'calculator.js').path
Example #2
0
 def __init__(self, *a, **kw):
     LivePage.__init__(self)
     # Update the mapping of known JavaScript modules so that the
     # client-side code for this example can be found and served to the
     # browser.
     self.jsModules.mapping[u'CalculatorDemo'] = sibling(
         'calculator.js').path
Example #3
0
 def locateChild(self, ctx, segments):
     if segments[0]=='js':
         s=list(segments)
         p=website.child(s.pop(0))
         while p.exists() and s:
             p=p.child(s.pop(0))
         if p.exists:
             if p.isdir():
                 return DirectoryLister(p.path), ()
             return File(p.path), s
         else:
             return LivePage.locateChild(self, ctx, segments)
     if segments[0] == '':
         return self, ()
     return LivePage.locateChild(self, ctx, segments)
Example #4
0
    def doRendering(self, fragmentClass):
        """
        Verify that the given fragment class will render without raising an
        exception.
        """
        siteStore = Store()

        loginSystem = LoginSystem(store=siteStore)
        installOn(loginSystem, siteStore)
        p = Product(store=siteStore, types=["xmantissa.webadmin.LocalUserBrowser",
                                            "xmantissa.signup.SignupConfiguration"])
        account = loginSystem.addAccount(u'testuser', u'localhost', None)
        p.installProductOn(account.avatars.open())
        f = fragmentClass(None, u'testuser', account)

        p = LivePage(
            docFactory=stan(
                html[
                    head(render=directive('liveglue')),
                    body(render=lambda ctx, data: f)]))
        f.setFragmentParent(p)

        ctx = WovenContext()
        req = FakeRequest()
        ctx.remember(req, IRequest)

        d = p.renderHTTP(ctx)
        def rendered(ign):
            p.action_close(None)
        d.addCallback(rendered)
        return d
Example #5
0
def renderLiveFragment(fragment):
    """
    Render the given fragment in a LivePage.

    This can only work for fragments which can be rendered synchronously.
    Fragments which involve Deferreds will be silently rendered incompletely.

    @type fragment: L{nevow.athena.LiveFragment} or L{nevow.athena.LiveElement}
    @param fragment: The page component to render.

    @rtype: C{str}
    @return: The result of rendering the fragment.
    """
    page = LivePage(docFactory=stan(fragment))
    fragment.setFragmentParent(page)
    (request, context) = _makeContext()
    page.renderHTTP(context)
    page.action_close(context)
    return request.v
Example #6
0
    def test_rendering(self):
        """
        Test that L{webadmin.UserInteractionFragment} renders without raising
        any exceptions.
        """
        f = UserInteractionFragment(self.browser)

        p = LivePage(docFactory=stan(html[head(render=directive("liveglue")), body(render=lambda ctx, data: f)]))
        f.setFragmentParent(p)

        ctx = WovenContext()
        req = FakeRequest()
        ctx.remember(req, IRequest)

        d = p.renderHTTP(ctx)

        def rendered(ign):
            p.action_close(None)

        d.addCallback(rendered)
        return d
Example #7
0
    def child_live(self, ctx):
        """
        The 'live' namespace is reserved for Athena LivePages.  By default in
        Athena applications these resources are child resources of whatever URL
        the live page ends up at, but this root URL is provided so that the
        reliable message queuing logic can sidestep all resource traversal, and
        therefore, all database queries.  This is an important optimization,
        since Athena's implementation assumes that HTTP hits to the message
        queue resource are cheap.

        @return: an L{athena.LivePage} instance.
        """
        return LivePage(None, None)
Example #8
0
    def test_rendering(self):
        """
        Test that L{webadmin.UserInteractionFragment} renders without raising
        any exceptions.
        """
        f = UserInteractionFragment(self.browser)

        p = LivePage(
            docFactory=stan(
                html[
                    head(render=directive('liveglue')),
                    body(render=lambda ctx, data: f)]))
        f.setFragmentParent(p)

        ctx = WovenContext()
        req = FakeRequest()
        ctx.remember(req, IRequest)

        d = p.renderHTTP(ctx)
        def rendered(ign):
            p.action_close(None)
        d.addCallback(rendered)
        return d
Example #9
0
    def _render(self, element):
        """
        Put the given L{IRenderer} provider into an L{athena.LivePage} and
        render it.  Return a Deferred which fires with the request object used
        which is an instance of L{nevow.testutil.FakeRequest}.
        """
        p = LivePage(docFactory=stan(html[head(
            render=directive('liveglue')), body[invisible(
                render=lambda ctx, data: element)]]))
        element.setFragmentParent(p)

        ctx = WovenContext()
        req = FakeRequest()
        ctx.remember(req, IRequest)

        d = p.renderHTTP(ctx)

        def rendered(ign):
            p.action_close(None)
            return req

        d.addCallback(rendered)
        return d
Example #10
0
    def _render(self, element):
        """
        Put the given L{IRenderer} provider into an L{athena.LivePage} and
        render it.  Return a Deferred which fires with the request object used
        which is an instance of L{nevow.testutil.FakeRequest}.
        """
        p = LivePage(
            docFactory=stan(
                html[
                    head(render=directive('liveglue')),
                    body[
                        invisible(render=lambda ctx, data: element)]]))
        element.setFragmentParent(p)

        ctx = WovenContext()
        req = FakeRequest()
        ctx.remember(req, IRequest)

        d = p.renderHTTP(ctx)
        def rendered(ign):
            p.action_close(None)
            return req
        d.addCallback(rendered)
        return d
Example #11
0
def renderLiveFragment(fragment):
    """
    Render the given fragment in a LivePage.

    This can only work for fragments which can be rendered synchronously.
    Fragments which involve Deferreds will be silently rendered incompletely.

    @type fragment: L{nevow.athena.LiveFragment} or L{nevow.athena.LiveElement}
    @param fragment: The page component to render.

    @rtype: C{str}
    @return: The result of rendering the fragment.
    """
    page = LivePage(docFactory=stan(fragment))
    fragment.setFragmentParent(page)
    (request, context) = _makeContext()
    page.renderHTTP(context)
    page.action_close(context)
    return request.v
Example #12
0
 def __init__(self, element):
     LivePage.__init__(self)
     self.element = element
Example #13
0
 def __init__(self, element):
     LivePage.__init__(self)
     self.element = element
Example #14
0
 def __init__(self, *args):
     LivePage.__init__(self, *args)
     self.jsModules.mapping[u'TestPage'] = js.child('testPage.js').path
     self.jsModules.mapping[u'PyPyWorker'] = js.child('PyPyWorker.js').path
     self.jsModules.mapping[u'jqconsole'] = js.child('jqconsole.min.js').path
     self.jsModules.mapping[u'pypyDrawThread'] = js.child('pypyDrawThread.js').path
Example #15
0
 def __init__(self, elementFactory):
     """
     Initialize the resource with the passwed plugin element.
     """
     LivePage.__init__(self)
     self.elementFactory = elementFactory
Example #16
0
 def __init__(self, *a, **kw):
     LivePage.__init__(self)
     self.jsModules.mapping[u'pyinabox'] = sibling(
         'PyInABox.js').path
Example #17
0
 def renderHTTP(self, *args):
         return LivePage.renderHTTP(self, *args)
Example #18
0
 def __init__(self, elementFactory):
     """
     Initialize the resource with the passwed plugin element.
     """
     LivePage.__init__(self)
     self.elementFactory = elementFactory