当前位置: 首页>>代码示例>>Python>>正文


Python Utils.chunkify方法代码示例

本文整理汇总了Python中Mailman.Utils.chunkify方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.chunkify方法的具体用法?Python Utils.chunkify怎么用?Python Utils.chunkify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mailman.Utils的用法示例。


在下文中一共展示了Utils.chunkify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FormatMembershipOptions

# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import chunkify [as 别名]
def FormatMembershipOptions(mlist, cgi_data):
    container = Container()
    header = Table(width="100%")
    header.AddRow([Center(Header(2, "Membership Management"))])
    header.AddCellInfo(max(header.GetCurrentRowIndex(), 0), 0,
                       colspan=2, bgcolor="#99ccff")
    container.AddItem(header)
    user_table = Table(width="90%", border='2')
    user_table.AddRow([Center(Header(4, "Membership List"))])
    user_table.AddCellInfo(user_table.GetCurrentRowIndex(),
                           user_table.GetCurrentCellIndex(),
                           bgcolor="#cccccc", colspan=8)
    user_table.AddRow(
        [Center(Italic("(%s members total, max. %s at a time displayed)" %
                       (len(mlist.members)
                        + len(mlist.digest_members),
                        mlist.admin_member_chunksize)))])
    user_table.AddCellInfo(user_table.GetCurrentRowIndex(),
                           user_table.GetCurrentCellIndex(),
                           bgcolor="#cccccc", colspan=8)

    user_table.AddRow(map(Center, ['member address', 'subscr',
                                   'hide', 'nomail', 'ack', 'not metoo',
                                   'digest', 'plain']))
    rowindex = user_table.GetCurrentRowIndex()
    for i in range(8):
        user_table.AddCellInfo(rowindex, i, bgcolor='#cccccc')
    all = mlist.GetMembers() + mlist.GetDigestMembers()
    if len(all) > mlist.admin_member_chunksize:
        chunks = Utils.chunkify(all, mlist.admin_member_chunksize)
        if not cgi_data.has_key("chunk"):
            chunk = 0
        else:
            chunk = string.atoi(cgi_data["chunk"].value)
        # Sanitize the chunk
        chunk = min(len(chunks)-1, max(chunk, 0))
        all = chunks[chunk]
        footer = ("<p><em>To View other sections, "
                  "click on the appropriate range listed below</em>")
        chunk_indices = range(len(chunks))
        chunk_indices.remove(chunk)
        buttons = []
        for ci in chunk_indices:
            start, end = chunks[ci][0], chunks[ci][-1]
	    url = mlist.GetScriptURL('admin')
            buttons.append("<a href=%s/members?chunk=%d> from %s to %s </a>"
                           % (url, ci, start, end))
        buttons = apply(UnorderedList, tuple(buttons))
        footer = footer + buttons.Format() + "<p>"
    else:
        all.sort()
        footer = "<p>"
    for member in all:
        mtext = '<a href="%s">%s</a>' % (
            mlist.GetOptionsURL(member, obscure=1),
            mlist.GetUserSubscribedAddress(member))
        cells = [mtext + "<input type=hidden name=user value=%s>" % (member),
                 Center(CheckBox(member + "_subscribed", "on", 1).Format())]
        for opt in ("hide", "nomail", "ack", "notmetoo"):
            if mlist.GetUserOption(member,MailCommandHandler.option_info[opt]):
                value = "on"
                checked = 1
            else:
                value = "off"
                checked = 0
            box = CheckBox("%s_%s" % (member, opt), value, checked)
            cells.append(Center(box.Format()))
        if mlist.members.has_key(member):
            cells.append(Center(CheckBox(member + "_digest",
                                         "off", 0).Format()))
        else:
            cells.append(Center(CheckBox(member + "_digest",
                                         "on", 1).Format()))
        if mlist.GetUserOption(member,MailCommandHandler.option_info['plain']):
            value = 'on'
            checked = 1
        else:
            value = 'off'
            checked = 0
        cells.append(Center(CheckBox('%s_plain' % member, value, checked)))
        user_table.AddRow(cells)
    container.AddItem(Center(user_table))
    legend = UnorderedList()
    legend.AddItem('<b>subscr</b> -- Is the member subscribed?')
    legend.AddItem("<b>hide</b> -- Is the member's address "
                   "concealed on the list of subscribers?")
    legend.AddItem('<b>nomail</b> -- Is delivery to the member disabled?')
    legend.AddItem('<b>ack</b> -- '
                   'Does the member get acknowledgements of their posts?')
    legend.AddItem('<b>not metoo</b> -- '
                   'Does the member avoid copies of their own posts?')
    legend.AddItem('<b>digest</b> -- '
                   'Does the member get messages in digests? '
                   '(otherwise, individual messages)')
    legend.AddItem(
        '<b>plain</b> -- '
        'If getting digests, does the member get plain text digests? '
        '(otherwise, MIME)')
    container.AddItem(legend.Format())
    container.AddItem(footer)
#.........这里部分代码省略.........
开发者ID:OS2World,项目名称:APP-SERVER-MailMan,代码行数:103,代码来源:admin.py


注:本文中的Mailman.Utils.chunkify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。