예제 #1
0
 def testHTML(self):
     t = '<a href="#"><nevow:attr name="href">href</nevow:attr>label</a>'
     doc = flat.flatten(loaders.htmlstr(t).load())
     self.assertEqual(doc, '<a href="href">label</a>')
     t = '<a href="#"><nevow:attr name="href"><nevow:slot name="href"/></nevow:attr>label</a>'
     precompiled = loaders.htmlstr(t).load()
     ctx = context.WovenContext(tag=tags.invisible[precompiled])
     ctx.fillSlots('href', 'href')
     result = flat.flatten(precompiled, ctx)
     self.assertEqual(result, '<a href="href">label</a>')
예제 #2
0
 def testHTML(self):
     t = '<a href="#"><nevow:attr name="href">href</nevow:attr>label</a>'
     doc = flat.flatten(loaders.htmlstr(t).load())
     self.assertEqual(doc, '<a href="href">label</a>')
     t = '<a href="#"><nevow:attr name="href"><nevow:slot name="href"/></nevow:attr>label</a>'
     ctx = context.WovenContext()
     ctx.fillSlots('href', 'href')
     precompiled = flat.precompile(loaders.htmlstr(t).load())
     result = flat.flatten(precompiled, ctx)
     self.assertEqual(result, '<a href="href">label</a>')
예제 #3
0
파일: handler.py 프로젝트: 2mf/pyicqt
    def render_content(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()
        if config.admins.count(username) == 0:
            return loaders.htmlstr("""
<B>Access Restricted</B>
""")
        else:
            return loaders.htmlstr("""
<B>Configuration</B>
<HR />
<SPAN nevow:render="config" />
""")
예제 #4
0
    def render_content(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()
        if config.admins.count(username) == 0:
            return loaders.htmlstr("""
<B>Access Restricted</B>
""")
        else:
            return loaders.htmlstr("""
<B>Configuration</B>
<HR />
<SPAN nevow:render="config" />
""")
예제 #5
0
파일: handler.py 프로젝트: 2mf/pyicqt
    def render_content(self, ctx):
        return loaders.htmlstr("""
<P CLASS="intro">Welcome to the PyICQ-t web interface.  At
present, these interfaces are very limited, mostly providing miscellaneous
information about the transport.  Eventually, this interface will do more,
but for now, enjoy the statistics and such!</P>
""")
예제 #6
0
파일: main.py 프로젝트: myaut/tsload
class TopMenu(rend.Fragment):
    docFactory = loaders.htmlstr("""
    <div class="pull-right">
        <ul class="nav">
            <li><a>Welcome, <span nevow:render="userName">Guest</span></a></li>
        </ul>
        <span nevow:render="menu">Menu</span>
    </div>
    """)
    
    def __init__(self):
        self.menu = Menu()
                
        self.userName = '******'
        
        rend.Fragment.__init__(self)
        
    def setUserName(self, userName):
        self.userName = userName
        
    def render_menu(self, ctx, data):
        return self.menu
    
    def render_userName(self, ctx, data):
        return self.userName
예제 #7
0
파일: test_rend.py 프로젝트: schwabe/nevow
 def test_htmlStringInStanTree(self):
     """
     Test that an htmlstr loader in a stan document is flattened by
     having its document loaded and flattened.
     """
     return self._testDocFactoryInStanTree(loaders.htmlstr('<p>fi</p>'),
                                           '<p>fi</p>')
예제 #8
0
    def test_docFactoryInStanTree(self):
        class Page(rend.Page):
            def __init__(self, included):
                self.included = included
                rend.Page.__init__(self)

            def render_included(self, context, data):
                return self.included

            docFactory = loaders.stan(
                div[invisible(render=directive('included'))])

        doc = '<p>fum</p>'
        temp = self.mktemp()
        f = file(temp, 'w')
        f.write(doc)
        f.close()

        result = deferredRender(Page(loaders.stan(p['fee'])))
        self.assertEquals(result, '<div><p>fee</p></div>')
        result = deferredRender(Page(loaders.htmlstr('<p>fi</p>')))
        self.assertEquals(result, '<div><p>fi</p></div>')
        result = deferredRender(Page(loaders.xmlstr('<p>fo</p>')))
        self.assertEquals(result, '<div><p>fo</p></div>')
        result = deferredRender(Page(loaders.htmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
        result = deferredRender(Page(loaders.xmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
예제 #9
0
    def render_content(self, ctx):
        return loaders.htmlstr("""
<P CLASS="intro">Welcome to the PyAIM-t web interface.  At
present, these interfaces are very limited, mostly providing miscellaneous
information about the transport.  Eventually, this interface will do more,
but for now, enjoy the statistics and such!</P>
""")
예제 #10
0
    def test_docFactoryInStanTree(self):

        class Page(rend.Page):

            def __init__(self, included):
                self.included = included
                rend.Page.__init__(self)

            def render_included(self, context, data):
                return self.included
            
            docFactory = loaders.stan(div[invisible(render=directive('included'))])

        doc = '<p>fum</p>'
        temp = self.mktemp()
        f = file(temp, 'w')
        f.write(doc)
        f.close()

        result = deferredRender(Page(loaders.stan(p['fee'])))
        self.assertEquals(result, '<div><p>fee</p></div>')
        result = deferredRender(Page(loaders.htmlstr('<p>fi</p>')))
        self.assertEquals(result, '<div><p>fi</p></div>')
        result = deferredRender(Page(loaders.xmlstr('<p>fo</p>')))
        self.assertEquals(result, '<div><p>fo</p></div>')
        result = deferredRender(Page(loaders.htmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
        result = deferredRender(Page(loaders.xmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
예제 #11
0
    def render_content(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()
        if config.admins.count(username) == 0:
            return loaders.htmlstr("""
<B>Access Restricted</B>
""")
        else:
            return loaders.htmlstr("""
<B>Transport Statistics</B>
<HR />
<SPAN nevow:render="statistics" />
<BR /><BR />
<B>Sessions</B>
<HR />
<SPAN nevow:render="sessions" />
""")
 def test_htmlStringInStanTree(self):
     """
     Test that an htmlstr loader in a stan document is flattened by
     having its document loaded and flattened.
     """
     return self._testDocFactoryInStanTree(
         loaders.htmlstr('<p>fi</p>'),
         '<p>fi</p>')
예제 #13
0
파일: handler.py 프로젝트: 2mf/pyicqt
    def render_content(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()
        if config.admins.count(username) == 0:
            return loaders.htmlstr("""
<B>Access Restricted</B>
""")
        else:
            return loaders.htmlstr("""
<B>Transport Statistics</B>
<HR />
<SPAN nevow:render="statistics" />
<BR /><BR />
<B>Sessions</B>
<HR />
<SPAN nevow:render="sessions" />
""")
예제 #14
0
    def render_content(self, ctx, data):
        return loaders.htmlstr("""
<B>Your Account</B>
<HR />
<SPAN nevow:render="info" />
<BR /><BR />
<B>Roster</B>
<HR />
<SPAN nevow:render="roster" />
""")
예제 #15
0
파일: handler.py 프로젝트: 2mf/pyicqt
    def render_content(self, ctx, data):
        return loaders.htmlstr("""
<B>Your Account</B>
<HR />
<SPAN nevow:render="info" />
<BR /><BR />
<B>Roster</B>
<HR />
<SPAN nevow:render="roster" />
""")
예제 #16
0
파일: test_rend.py 프로젝트: msdemlei/nevow
 class R(rend.Page):
     docFactory = loaders.htmlstr(xhtml)
     def data_numbers(self, context, data):
         return [
             ['one', 'un/une'],
             ['two', 'deux'],
             ['three', 'trois'],
             ]
     def render_row(self, context, data):
         context.fillSlots('english', data[0])
         context.fillSlots('french', data[1])
         return context.tag
예제 #17
0
class TreeRenderer(rend.Page):
    implements(ITreeEdit)
    addSlash = True
    docFactory = loaders.htmlstr("""
<html>
<head><title>Tree Editor</title></head>
<body><h1><span nevow:data="description"
                nevow:render="string">Tree Description</span></h1>
<span nevow:render="descriptionForm"/>
<ol nevow:data="children" nevow:render="sequence">
<li nevow:pattern="item"><span nevow:render="childLink"/>
<span nevow:render="childDel"/>
</li>
</ol>
<a href="..">Up</a>
</body>
</html>
    """)

    def setDescription(self, description):
        self.original.description = description

    def addChild(self, name, description):
        self.original.add(Tree(name, description))

    def deleteChild(self, name):
        del self.original[name]

    def data_description(self, context, data):
        return self.original.description

    def data_children(self, context, data):
        return self.original.items()

    def render_childLink(self, context, data):
        return T.a(href='subtree_%s/' % data[0])[data[1].description]

    def childFactory(self, ctx, name):
        if name.startswith('subtree_'):
            return self.original[name[len('subtree_'):]]

    def render_descriptionForm(self, context, data):
        return webform.renderForms()

    def render_childDel(self, context, (name, _)):
        ret = T.form(
            action="./freeform_post!!deleteChild",
            enctype="multipart/form-data",
            method="POST")[T.input(type="hidden", name="name", value=name),
                           T.input(type="submit", value="Delete")]
        return ret
예제 #18
0
 def test_htmlstr(self):
     loader = loaders.htmlstr(self.doc)
     self.assertEquals( id(loader.load()), id(loader.load()) )
     loader = loaders.htmlstr(self.doc, pattern='1')
     self.assertEquals( id(loader.load()), id(loader.load()) )
     l1 = loaders.htmlstr(self.doc, pattern='1')
     l2 = loaders.htmlstr(self.doc, pattern='1')
     self.assertNotEqual( id(l1.load()), id(l2.load()) )
     l1 = loaders.htmlstr(self.doc, pattern='1')
     l2 = loaders.htmlstr(self.doc, pattern='2')
     self.assertNotEqual( id(l1.load()), id(l2.load()) )
예제 #19
0
class Pg(rend.Page):
    docFactory = loaders.htmlstr("""
		<html><head><title>Name</title></head>
		    <body>
		        <ul nevow:data="dct" nevow:render="sequence">
                    <li nevow:pattern="item" nevow:render="mapping">
                    	<span><nevow:slot name="name">&nbsp;</span>
                    </li>
		        </ul>
		        <H1></H1>
		    </body>
		</html>
		""")

    def __init__(self, dct):
        self.data_dct = dct
        rend.Page.__init__(self)
예제 #20
0
    def test_htmlstr(self):
        loader = loaders.htmlstr(self.doc)
        self.assertEquals( id(loader.load()), id(loader.load()) )

        loader = loaders.htmlstr(self.doc, pattern='1')
        self.assertEquals( id(loader.load()), id(loader.load()) )

        l1 = loaders.htmlstr(self.doc, pattern='1')
        l2 = loaders.htmlstr(self.doc, pattern='1')
        self.assertNotEqual( id(l1.load()), id(l2.load()) )

        l1 = loaders.htmlstr(self.doc, pattern='1')
        l2 = loaders.htmlstr(self.doc, pattern='2')
        self.assertNotEqual( id(l1.load()), id(l2.load()) )
예제 #21
0
 def test_simple(self):
     xhtml = '<ul id="nav"><li>one</li><li>two</li><li>three</li></ul>'
     r = rend.Page(docFactory=loaders.htmlstr(xhtml))
     result = deferredRender(r)
     self.assertEquals(result, xhtml)
예제 #22
0
 def render_rst(self, context, data):
     if data.body:
         return loaders.htmlstr(data.body)
     else:
         return ''
예제 #23
0
def document_factory(file):
    parser = Parser(file)
    return loaders.htmlstr(
        parser.parse()
    );
예제 #24
0
class StatSite(rend.Page):
    addSlash = True  ## This is a directory-like resource
    docFactory = loaders.htmlstr(TEMPLATE % INDEX_HTML)

    #child_sources = static.File('./mud/statserver/website/', defaultType='text/plain')
    #child_sources.processors['.py'] = Sources
    #child_sources.contentTypes = {}
    #child_cssfile = static.File(os.path.abspath('.')+'/mud/statserver/website/prairiegames.css')

    def child_index(self, ctx):
        return TEMPLATE % INDEX_HTML

    def child_richestfol(self, ctx):
        r = CACHED.get("richestfol", None)
        if r:
            return r
        rank = 1
        html = """<p class="smallheader">Richest FoL Players</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Platinum</th>
            <th>Gold</th>
            <th>Silver</th>
            <th>Copper</th>
            <th>Tin</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("folrichest", None)
        text = ""
        if highest:
            for playerName, tin, copper, silver, gold, platinum in highest:
                if playerName in FILTERED_PLAYERS:
                    continue
                text += str(
                    """<tr><td>%i. %s</td> <td>%i</td> <td>%i</td> <td>%i</td> <td>%i</td> <td>%i</td> </tr>"""
                    % (rank, playerName, platinum, gold, silver, copper, tin))
                rank += 1

        r = CACHED["richestfol"] = TEMPLATE % (html % text)
        return r

    def child_richestmod(self, ctx):

        r = CACHED.get("richestmod", None)
        if r:
            return r

        rank = 1

        html = """<p class="smallheader">Richest MoD Players</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Platinum</th>
            <th>Gold</th>
            <th>Silver</th>
            <th>Copper</th>
            <th>Tin</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("modrichest", None)
        text = ""
        if highest:
            for playerName, tin, copper, silver, gold, platinum in highest:
                if playerName in FILTERED_PLAYERS:
                    continue
                text += str(
                    """<tr><td>%i. %s</td> <td>%i</td> <td>%i</td> <td>%i</td> <td>%i</td> <td>%i</td> </tr>"""
                    % (rank, playerName, platinum, gold, silver, copper, tin))
                rank += 1

        r = CACHED["richestmod"] = TEMPLATE % (html % text)
        return r

    def child_highestpresence(self, ctx):
        r = CACHED.get("highestpresence", None)
        if r:
            return r

        rank = 1
        html = """<p class="smallheader">Characters by Highest Presence</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Presence</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            <th>Realm</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("presence", None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal, realm, presence in highest:
                if playerName in FILTERED_PLAYERS:
                    continue
                if realm == 1:
                    realm = "FoL"
                else:
                    realm = "MoD"
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td><td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s</td></tr>"""
                        % (rank, playerName, name, presence, pclassInternal,
                           plevel, sclassInternal, slevel, tclassInternal,
                           tlevel, realm))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td><td>%s (%s)</td> <td>%s (%s)</td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, presence, pclassInternal,
                           plevel, sclassInternal, slevel, realm))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td><td>%s (%s)</td> <td></td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, presence, pclassInternal,
                           plevel, realm))
                rank += 1

        r = CACHED["highestpresence"] = TEMPLATE % (html % text)
        return r

    def child_highestprimary(self, ctx):

        r = CACHED.get("highestprimary", None)
        if r:
            return r

        rank = 1
        html = """<p class="smallheader">Characters by Highest Primary Level</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            <th>Realm</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("levels", None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal, realm in highest:
                if playerName in FILTERED_PLAYERS:
                    continue
                if realm == 1:
                    realm = "FoL"
                else:
                    realm = "MoD"
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel, tclassInternal, tlevel,
                           realm))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel, realm))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td></td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           realm))
                rank += 1

        r = CACHED["highestprimary"] = TEMPLATE % (html % text)
        return r

    def child_highestcombined(self, ctx):

        r = CACHED.get("highestcombined", None)
        if r:
            return r
        rank = 1
        html = """<p class="smallheader">Characters by Highest Combined Level</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Combined</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            <th>Realm</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("totallevels", None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal, realm in highest:
                if playerName in FILTERED_PLAYERS:
                    continue

                combined = int(plevel) + int(slevel) + int(tlevel)
                if realm == 1:
                    realm = "FoL"
                else:
                    realm = "MoD"
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s</td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel, sclassInternal, slevel, tclassInternal,
                           tlevel, realm))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td>%s (%s)</td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel, sclassInternal, slevel, realm))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td></td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel, realm))
                rank += 1

        r = CACHED["highestcombined"] = TEMPLATE % (html % text)
        return r

    def highestprimaryrealm(self, ctx, realm):
        if realm == "fol":
            r = "FoL"
        else:
            r = "MoD"

        rank = 1
        html = """<p class="smallheader">Characters by Highest Primary Level - %s</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("%slevels" % realm, None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal in highest:
                if playerName in FILTERED_PLAYERS:
                    continue
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel, tclassInternal, tlevel))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td></td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td></td> <td></td> </tr>"""
                        % (rank, playerName, name, pclassInternal, plevel))
                rank += 1

        return TEMPLATE % (html % (r, text))

    def child_highestprimaryfol(self, ctx):
        r = CACHED.get("highestprimaryfol", None)
        if r:
            return r
        r = CACHED["highestprimaryfol"] = self.highestprimaryrealm(ctx, "fol")
        return r

    def child_highestprimarymod(self, ctx):
        r = CACHED.get("highestprimarymod", None)
        if r:
            return r
        r = CACHED["highestprimarymod"] = self.highestprimaryrealm(ctx, "mod")
        return r

    def highestcombinedrealm(self, ctx, realm):
        if realm == "fol":
            r = "FoL"
        else:
            r = "MoD"

        rank = 1
        html = """<p class="smallheader">Characters by Highest Combined Level - %s</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Combined</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            </tr>
            %s
            </table>
            """

        highest = STATS.get("%stotallevels" % realm, None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal in highest:
                if playerName in FILTERED_PLAYERS:
                    continue

                combined = int(plevel) + int(slevel) + int(tlevel)
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel, sclassInternal, slevel, tclassInternal,
                           tlevel))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td>%s (%s)</td> <td></td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel, sclassInternal, slevel))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%i</td> <td>%s (%s)</td> <td></td> <td></td></tr>"""
                        % (rank, playerName, name, combined, pclassInternal,
                           plevel))
                rank += 1

        return TEMPLATE % (html % (r, text))

    def child_highestcombinedfol(self, ctx):
        r = CACHED.get("highestcombinedfol", None)
        if r:
            return r
        r = CACHED["highestcombinedfol"] = self.highestcombinedrealm(
            ctx, "fol")
        return r

    def child_highestcombinedmod(self, ctx):
        r = CACHED.get("highestcombinedmod", None)
        if r:
            return r
        r = CACHED["highestcombinedmod"] = self.highestcombinedrealm(
            ctx, "mod")
        return r

    def highestprimaryclass(self, ctx, klass):
        html = """<p class="smallheader">%s by Highest Primary Level</p>
            <a href="index">Back</a><br><br>
            
            <table border="1" class="features">
            <tr>
            <th>Player</th>
            <th>Character</th>
            <th>Primary</th>
            <th>Secondary</th>
            <th>Tertiary</th>
            <th>Realm</th>
            </tr>
            %s
            </table>
            """

        rank = 1
        highest = STATS.get("%slevels" % klass.lower(), None)
        text = ""
        if highest:
            for playerName, name, plevel, slevel, tlevel, pclassInternal, sclassInternal, tclassInternal, realm in highest:
                if playerName in FILTERED_PLAYERS:
                    continue

                if realm == 1:
                    realm = "FoL"
                else:
                    realm = "MoD"
                if sclassInternal and tclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s (%s)</td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel, tclassInternal, tlevel,
                           realm))
                elif sclassInternal:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td>%s (%s)</td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           sclassInternal, slevel, realm))
                else:
                    text += str(
                        """<tr><td>%i. %s</td> <td>%s</td> <td>%s (%s)</td> <td></td> <td></td> <td>%s</td></tr>"""
                        % (rank, playerName, name, pclassInternal, plevel,
                           realm))
                rank += 1

        return TEMPLATE % (html % (klass, text))

    def child_highestpaladin(self, ctx):
        r = CACHED.get("highestpaladin", None)
        if r:
            return r
        r = CACHED["highestpaladin"] = self.highestprimaryclass(ctx, "Paladin")
        return r

    def child_highestwizard(self, ctx):
        r = CACHED.get("highestwizard", None)
        if r:
            return r
        r = CACHED["highestwizard"] = self.highestprimaryclass(ctx, "Wizard")
        return r

    def child_highestdruid(self, ctx):
        r = CACHED.get("highestdruid", None)
        if r:
            return r
        r = CACHED["highestdruid"] = self.highestprimaryclass(ctx, "Druid")
        return r

    def child_highestnecromancer(self, ctx):
        r = CACHED.get("highestnecromancer", None)
        if r:
            return r
        r = CACHED["highestnecromancer"] = self.highestprimaryclass(
            ctx, "Necromancer")
        return r

    def child_highesttempest(self, ctx):
        r = CACHED.get("highesttempest", None)
        if r:
            return r
        r = CACHED["highesttempest"] = self.highestprimaryclass(ctx, "Tempest")
        return r

    def child_highestwarrior(self, ctx):
        r = CACHED.get("highestwarrior", None)
        if r:
            return r
        r = CACHED["highestwarrior"] = self.highestprimaryclass(ctx, "Warrior")
        return r

    def child_highestbarbarian(self, ctx):
        r = CACHED.get("highestbarbarian", None)
        if r:
            return r
        r = CACHED["highestbarbarian"] = self.highestprimaryclass(
            ctx, "Barbarian")
        return r

    def child_highestranger(self, ctx):
        r = CACHED.get("highestranger", None)
        if r:
            return r
        r = CACHED["highestranger"] = self.highestprimaryclass(ctx, "Ranger")
        return r

    def child_highestbard(self, ctx):
        r = CACHED.get("highestbard", None)
        if r:
            return r
        r = CACHED["highestbard"] = self.highestprimaryclass(ctx, "Bard")
        return r

    def child_highestrevealer(self, ctx):
        r = CACHED.get("highestrevealer", None)
        if r:
            return r
        r = CACHED["highestrevealer"] = self.highestprimaryclass(
            ctx, "Revealer")
        return r

    def child_highestcleric(self, ctx):
        r = CACHED.get("highestcleric", None)
        if r:
            return r
        r = CACHED["highestcleric"] = self.highestprimaryclass(ctx, "Cleric")
        return r

    def child_highestassassin(self, ctx):
        r = CACHED.get("highestassassin", None)
        if r:
            return r
        r = CACHED["highestassassin"] = self.highestprimaryclass(
            ctx, "Assassin")
        return r

    def child_highestthief(self, ctx):
        r = CACHED.get("highestthief", None)
        if r:
            return r
        r = CACHED["highestthief"] = self.highestprimaryclass(ctx, "Thief")
        return r

    def child_highestshaman(self, ctx):
        r = CACHED.get("highestshaman", None)
        if r:
            return r
        r = CACHED["highestshaman"] = self.highestprimaryclass(ctx, "Shaman")
        return r

    def child_highestmonk(self, ctx):
        r = CACHED.get("highestmonk", None)
        if r:
            return r
        r = CACHED["highestmonk"] = self.highestprimaryclass(ctx, "Monk")
        return r

    def child_highestdoomknight(self, ctx):
        r = CACHED.get("highestdoomknight", None)
        if r:
            return r
        r = CACHED["highestdoomknight"] = self.highestprimaryclass(
            ctx, "Doom Knight")
        return r
예제 #25
0
 def test_stringTemplate(self):
     r = rend.Page(docFactory=loaders.htmlstr(self.xhtml))
     return deferredRender(r).addCallback(
         lambda result: self.assertEquals(result, self.xhtml))
예제 #26
0
파일: nevowdriver.py 프로젝트: alex/t-web
    def render_nextversion(self, ctx, data):
        # assume unstable is latest
        if not self.unstableversion:
            return "No next version! Not unstable."
        return ctx.tag.clear()[
            self.unstableversion[
                : self.unstableversion.find(self.unstabletype)
                ]
            ]

tmpage = None
def TMPage(docFactory):
    """
    Hack for having a persistent Page instance.
    """
    global tmpage
    if tmpage:
        tmpage.docFactory = docFactory
        return tmpage
    else:
        tmpage = Page(docFactory=docFactory)
        return tmpage


if __name__ == '__main__':
    tmpage = TMPage(
        docFactory=loaders.htmlstr(
        '<html><body> <span nevow:render="stableversion"/></body></html>'))
    from twisted.trial.util import wait
    print wait(tmpage.renderString())
예제 #27
0
 def test_stringTemplate(self):
     r = rend.Page(docFactory=loaders.htmlstr(self.xhtml))
     result = deferredRender(r)
     self.assertEquals(result, self.xhtml)
예제 #28
0
파일: test_rend.py 프로젝트: schwabe/nevow
        class R(rend.Page):
            docFactory = loaders.htmlstr(xhtml)

            def data_numbers(self, context, data):
                return ['one', 'two', 'three']
예제 #29
0
 def test_stringTemplate(self):
     r = rend.Page(docFactory=loaders.htmlstr(self.xhtml))
     return deferredRender(r).addCallback(
         lambda result: self.assertEqual(result, self.xhtml))
예제 #30
0
파일: test_rend.py 프로젝트: schwabe/nevow
 def test_simple(self):
     xhtml = '<ul id="nav"><li>one</li><li>two</li><li>three</li></ul>'
     r = rend.Page(docFactory=loaders.htmlstr(xhtml))
     return deferredRender(r).addCallback(
         lambda result: self.assertEqual(result, xhtml))
예제 #31
0
파일: test_rend.py 프로젝트: schwabe/nevow
 class R(rend.Page):
     docFactory = loaders.htmlstr(xhtml)
예제 #32
0
 def render_rst(self, context, data):
     if data.body:
         return loaders.htmlstr(data.body)
     else:
         return ''
예제 #33
0
파일: test_rend.py 프로젝트: schwabe/nevow
        class R(rend.Page):
            docFactory = loaders.htmlstr(xhtml)

            def render_replace(self, context, data):
                return context.tag.clear()['abc']
예제 #34
0
파일: test_rend.py 프로젝트: schwabe/nevow
        class R(rend.Page):
            docFactory = loaders.htmlstr('<p nevow:render="foo"></p>')

            def render_foo(self, ctx, data):
                return ctx.tag.clear()[data]
def document_factory(file):
    parser = Parser(file)
    return loaders.htmlstr(
        parser.parse()
    );
예제 #36
0
 def test_htmlstr(self):
     doc = '<p>hello</p>'
     self._withAndWithout(loaders.htmlstr(doc))
예제 #37
0
 def test_htmlstr(self):
     doc = '<ul id="nav"><li>a</li><li>b</li><li>c</li></ul>'
     df = loaders.htmlstr(doc)
     self.assertEquals(df.load()[0], doc)
예제 #38
0
파일: nevowdriver.py 프로젝트: wallrj/t-web
    def render_nextversion(self, ctx, data):
        # assume unstable is latest
        if not self.unstableversion:
            return "No next version! Not unstable."
        return ctx.tag.clear()[self.unstableversion[:self.unstableversion.
                                                    find(self.unstabletype)]]


tmpage = None


def TMPage(docFactory):
    """
    Hack for having a persistent Page instance.
    """
    global tmpage
    if tmpage:
        tmpage.docFactory = docFactory
        return tmpage
    else:
        tmpage = Page(docFactory=docFactory)
        return tmpage


if __name__ == '__main__':
    tmpage = TMPage(docFactory=loaders.htmlstr(
        '<html><body> <span nevow:render="stableversion"/></body></html>'))
    from twisted.trial.util import wait
    print wait(tmpage.renderString())
 def test_simple(self):
     xhtml = '<ul id="nav"><li>one</li><li>two</li><li>three</li></ul>'
     r = rend.Page(docFactory=loaders.htmlstr(xhtml))
     return deferredRender(r).addCallback(
         lambda result: self.assertEquals(result, xhtml))
예제 #40
0
 def test_stringTemplate(self):
     r = rend.Page(docFactory=loaders.htmlstr(self.xhtml))
     result = deferredRender(r)
     self.assertEquals(result, self.xhtml)