Esempio n. 1
0
def guild_stances(request):
    contentLength = request.headers.getheader("Content-Length")
    if contentLength:
        if request.path.startswith("/guildstance"):
            # client POSTed, form a cookie, and set it, and then redirect them to nonPOST version
            postData = request.rfile.read(int(contentLength))
            guildStances = dict(
                urlparse.parse_qsl(postData, strict_parsing=True))
            cookie = Cookie.SimpleCookie()
            cookie["guildStance"] = ",".join("|".join(a)
                                             for a in guildStances.iteritems())
            request.send_response(303)  # See Other (GET)
            request.wfile.write(cookie.output() + '\r\n')
            request.send_header("Location", self.headers.getheader("Referer"))
            request.end_headers()
            return
    doc = context.htmldoc
    world = context.get_selected_world()
    with doc.open_tag("form", attrs={
            "method": "post",
    }):  #"action": "/setcookie"}):
        with doc.open_tag("table"):
            with doc.open_tag("tr"):
                for heading in ("Guild Name", ) + STANCE_VALUES:
                    doc.add_tag("th", heading)
                if not world:
                    doc.add_tag("th", "World")
            for guild, guildWorld in dbiface.list_guilds():
                if not world or world == guildWorld:
                    with doc.open_tag("tr", inline=False):
                        doc.newline()
                        doc.add_tag(
                            "td",
                            guild_link(guild, context.get_guild_stance(guild)))
                        for stance in STANCE_VALUES:
                            doc.newline()
                            with doc.open_tag("td", inline=True):
                                attrs = dict(type="radio",
                                             name=guild,
                                             value=stance)
                                if stance == context.get_guild_stance(guild):
                                    attrs["checked"] = None
                                doc.add_tag("input", attrs=attrs, inline=True)
                        if not world:
                            doc.add_tag("td", guildWorld)


#        doc.add_tag("input", attrs={"type": "hidden", "name": "NEXT_LOCATION", "value": "/whoisonline"})
        doc.add_tag("input", attrs={"type": "submit"})
Esempio n. 2
0
def guild_stances(request):
    contentLength = request.headers.getheader("Content-Length")
    if contentLength:
        if request.path.startswith("/guildstance"):
            # client POSTed, form a cookie, and set it, and then redirect them to nonPOST version
            postData = request.rfile.read(int(contentLength))
            guildStances = dict(urlparse.parse_qsl(postData, strict_parsing=True))
            cookie = Cookie.SimpleCookie()
            cookie["guildStance"] = ",".join("|".join(a) for a in guildStances.iteritems())
            request.send_response(303) # See Other (GET)
            request.wfile.write(cookie.output() + '\r\n')
            request.send_header("Location", self.headers.getheader("Referer"))
            request.end_headers()
            return
    doc = context.htmldoc
    world = context.get_selected_world()
    with doc.open_tag("form", attrs={"method": "post",}): #"action": "/setcookie"}):
        with doc.open_tag("table"):
            with doc.open_tag("tr"):
                for heading in ("Guild Name",) + STANCE_VALUES:
                    doc.add_tag("th", heading)
                if not world:
                    doc.add_tag("th", "World")
            for guild, guildWorld in dbiface.list_guilds():
                if not world or world == guildWorld:
                    with doc.open_tag("tr", inline=False):
                        doc.newline()
                        doc.add_tag("td", guild_link(guild, context.get_guild_stance(guild)))
                        for stance in STANCE_VALUES:
                            doc.newline()
                            with doc.open_tag("td", inline=True):
                                attrs = dict(type="radio", name=guild, value=stance)
                                if stance == context.get_guild_stance(guild):
                                    attrs["checked"] = None
                                doc.add_tag("input", attrs=attrs, inline=True)
                        if not world:
                            doc.add_tag("td", guildWorld)

#        doc.add_tag("input", attrs={"type": "hidden", "name": "NEXT_LOCATION", "value": "/whoisonline"})
        doc.add_tag("input", attrs={"type": "submit"})
Esempio n. 3
0
def guild_stances(outfile, context):
    doc = outfile
    world = context.get_selected_world()
    doc.add_tag("p", 'Here are listed the guilds for the world you have selected. You may set your personal "stance" toward that guild, F=Friend, A=Ally, U=Unspecified, E=Enemy. The guild is then appropriately colored on any page where guild is mentioned to ease categorization at a glance.', attrs={"style": "width: 100%"})
    with doc.open_tag("form", attrs={"method": "get"}):
        doc.write("World:")
        world_select(doc, world, onchange=True)
    guildsListed = set()
    with doc.open_tag("form", attrs={"method": "post",}, inline=False): #"action": "/setcookie"}):
        with stattab_table_tag(doc.open_tag):
            with doc.open_tag("tr"):
                for heading in ("Guild Name", "Members") + STANCE_VALUES:
                    doc.add_tag("th", heading)
                if not world:
                    doc.add_tag("th", "World")
            rowClass = stattab_row_class()
            for guild, memberCount in dbiface.list_guilds(world):
                #if not world or world == guildWorld:
                with doc.open_tag("tr", attrs={"class": rowClass.next()}, inline=False):
                    doc.newline()
                    doc.add_tag("td", guild_link(guild, context.get_guild_stance(guild)))
                    doc.add_tag("td", memberCount)
                    for stance in STANCE_VALUES:
                        doc.newline()
                        with doc.open_tag("td", inline=True):
                            attrs = dict(type="radio", name=guild, value=stance)
                            if stance == context.get_guild_stance(guild):
                                attrs["checked"] = None
                            doc.add_tag("input", attrs=attrs, inline=True)
                        #if not world:
                        #    doc.add_tag("td", guildWorld)
                guildsListed.add(guild)
#        doc.add_tag("input", attrs={"type": "hidden", "name": "NEXT_LOCATION", "value": "/whoisonline"})
        for g, s in context.get_all_guild_stances():
            if g not in guildsListed:
                doc.newline()
                doc.add_tag("input", attrs={"type": "hidden", "name": g, "value": s})
        doc.newline()
        doc.add_tag("input", attrs={"type": "submit", "value": "Change Stances!"})
Esempio n. 4
0
def guild_stances(outfile, context):
    doc = outfile
    world = context.get_selected_world()
    doc.add_tag(
        "p",
        'Here are listed the guilds for the world you have selected. You may set your personal "stance" toward that guild, F=Friend, A=Ally, U=Unspecified, E=Enemy. The guild is then appropriately colored on any page where guild is mentioned to ease categorization at a glance.',
        attrs={"style": "width: 100%"})
    with doc.open_tag("form", attrs={"method": "get"}):
        doc.write("World:")
        world_select(doc, world, onchange=True)
    guildsListed = set()
    with doc.open_tag("form", attrs={
            "method": "post",
    }, inline=False):  #"action": "/setcookie"}):
        with stattab_table_tag(doc.open_tag):
            with doc.open_tag("tr"):
                for heading in ("Guild Name", "Members") + STANCE_VALUES:
                    doc.add_tag("th", heading)
                if not world:
                    doc.add_tag("th", "World")
            rowClass = stattab_row_class()
            for guild, memberCount in dbiface.list_guilds(world):
                #if not world or world == guildWorld:
                with doc.open_tag("tr",
                                  attrs={"class": rowClass.next()},
                                  inline=False):
                    doc.newline()
                    doc.add_tag(
                        "td", guild_link(guild,
                                         context.get_guild_stance(guild)))
                    doc.add_tag("td", memberCount)
                    for stance in STANCE_VALUES:
                        doc.newline()
                        with doc.open_tag("td", inline=True):
                            attrs = dict(type="radio",
                                         name=guild,
                                         value=stance)
                            if stance == context.get_guild_stance(guild):
                                attrs["checked"] = None
                            doc.add_tag("input", attrs=attrs, inline=True)
                        #if not world:
                        #    doc.add_tag("td", guildWorld)
                guildsListed.add(guild)


#        doc.add_tag("input", attrs={"type": "hidden", "name": "NEXT_LOCATION", "value": "/whoisonline"})
        for g, s in context.get_all_guild_stances():
            if g not in guildsListed:
                doc.newline()
                doc.add_tag("input",
                            attrs={
                                "type": "hidden",
                                "name": g,
                                "value": s
                            })
        doc.newline()
        doc.add_tag("input",
                    attrs={
                        "type": "submit",
                        "value": "Change Stances!"
                    })