示例#1
0
def main():
    parser = OptionParser(description=__doc__)
    parser.add_option(
        '-C',
        '--config',
        dest='config',
        default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-d',
                      '--dry-run',
                      dest='dry_run',
                      action="store_true",
                      default=False,
                      help="Don't commit the transactions")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    peopledir = find_peopledirectory(root)
    reindex_peopledirectory(peopledir)

    if options.dry_run:
        transaction.abort()
    else:
        transaction.commit()
示例#2
0
def peopleconf(peopledir, tree, force_reindex=False):
    # tree is an lxml.etree element.
    if tree.find("categories") is not None:
        try:
            del peopledir.categories
        except AttributeError:  # already scrubbed
            pass
        categories = peopledir.get("categories")
        if not isinstance(categories, PeopleCategories):
            if "categories" in peopledir:
                del peopledir["categories"]
            categories = peopledir["categories"] = PeopleCategories()
        doomed = list(categories.keys())
        for x in doomed:
            del categories[x]
        for cat_elem in tree.findall("categories/category"):
            c_name, title = name_and_title(cat_elem)
            pc = categories[c_name] = PeopleCategory(title)
            for value_elem in cat_elem.findall("value"):
                v_name, title = name_and_title(value_elem)
                desc_elem = value_elem.find("description")
                if desc_elem is not None:
                    # get the content of the description as XML
                    # Note that lxml.etree.Element.text is documented as the
                    # "text before the first subelement".
                    text = desc_elem.text or ""
                    description = text + u"".join(etree.tostring(e, encoding=unicode) for e in desc_elem)
                else:
                    description = u""
                item = PeopleCategoryItem(title, description)
                pc[v_name] = item

    for name in list(peopledir.keys()):
        if name != "categories":
            del peopledir[name]

    clear_mailinglist_aliases(peopledir)

    section_order = []
    for section_elem in tree.findall("sections/section"):
        name, title = name_and_title(section_elem)
        section_order.append(name)
        tab_title = section_elem.get("tab-title", title)
        section = peopledir[name] = PeopleSection(title, tab_title)
        set_acl(section, section_elem)

        sub_order = []
        for sub_name, sub in parse_section(peopledir, section_elem):
            section[sub_name] = sub
            sub_order.append(sub_name)
        section.order = tuple(sub_order)

    find_mailinglist_aliases(peopledir)

    # 'categories' never in the order.
    peopledir.order = section_order

    need_reindex = peopledir.update_indexes()
    if need_reindex or force_reindex:
        reindex_peopledirectory(peopledir)
示例#3
0
文件: subscribers.py 项目: hj91/karl
def update_peopledirectory_indexes(event):
    """Updates the peopledir catalog schema.

    This is an IPeopleDirectorySchemaChanged subscriber.
    """
    peopledir = event.peopledir
    if peopledir.update_indexes():
        reindex_peopledirectory(peopledir)
示例#4
0
def update_peopledirectory_indexes(event):
    """Updates the peopledir catalog schema.

    This is an IPeopleDirectorySchemaChanged subscriber.
    """
    peopledir = event.peopledir
    if peopledir.update_indexes():
        reindex_peopledirectory(peopledir)
示例#5
0
文件: peopleconf.py 项目: zagy/karl
def peopleconf(peopledir, tree, force_reindex=False):
    # tree is an lxml.etree element.
    if tree.find('categories') is not None:
        try:
            del peopledir.categories
        except AttributeError:  # already scrubbed
            pass
        categories = peopledir.get('categories')
        if not isinstance(categories, PeopleCategories):
            if 'categories' in peopledir:
                del peopledir['categories']
            categories = peopledir['categories'] = PeopleCategories()
        doomed = list(categories.keys())
        for x in doomed:
            del categories[x]
        for cat_elem in tree.findall('categories/category'):
            c_name, title = name_and_title(cat_elem)
            pc = categories[c_name] = PeopleCategory(title)
            for value_elem in cat_elem.findall('value'):
                v_name, title = name_and_title(value_elem)
                # get the content of the description as XML
                # Note that lxml.etree.Element.text is documented as the
                # "text before the first subelement".
                text = value_elem.text or ''
                description = text + u''.join(
                    etree.tostring(e, encoding=unicode) for e in value_elem)
                item = PeopleCategoryItem(title, description.strip())
                pc[v_name] = item

    for name in list(peopledir.keys()):
        if name != 'categories':
            del peopledir[name]

    clear_mailinglist_aliases(peopledir)

    section_order = []
    for section_elem in tree.findall('sections/section'):
        name, title = name_and_title(section_elem)
        section_order.append(name)
        tab_title = section_elem.get('tab-title', title)
        section = peopledir[name] = PeopleSection(title, tab_title)
        set_acl(section, section_elem)

        sub_order = []
        for sub_name, sub in parse_section(peopledir, section_elem):
            section[sub_name] = sub
            sub_order.append(sub_name)
        section.order = tuple(sub_order)

    find_mailinglist_aliases(peopledir)

    # 'categories' never in the order.
    peopledir.order = section_order

    need_reindex = peopledir.update_indexes()
    if need_reindex or force_reindex:
        reindex_peopledirectory(peopledir)
示例#6
0
def peopleconf(peopledir, tree, force_reindex=False):
    # tree is an lxml.etree element.
    if tree.find('categories') is not None:
        peopledir.categories.clear()
        for cat_elem in tree.findall('categories/category'):
            catid, title = id_and_title(cat_elem)
            pc = PeopleCategory(title)
            peopledir.categories[catid] = pc
            for value_elem in cat_elem.findall('value'):
                valueid, title = id_and_title(value_elem)
                desc_elem = value_elem.find('description')
                if desc_elem is not None:
                    # get the content of the description as XML
                    # Note that lxml.etree.Element.text is documented as the
                    # "text before the first subelement".
                    text = desc_elem.text or ''
                    description = text + u''.join(
                        etree.tostring(e, encoding=unicode) for e in desc_elem)
                else:
                    description = u''
                item = PeopleCategoryItem(title, description)
                pc[valueid] = item

    for secid in list(peopledir.keys()):
        del peopledir[secid]

    section_order = []
    for section_elem in tree.findall('sections/section'):
        secid, title = id_and_title(section_elem)
        section_order.append(secid)
        tab_title = section_elem.get('tab-title', title)
        section = PeopleSection(title, tab_title)
        peopledir[secid] = section
        set_acl(section, section_elem)

        columns, reportmap = parse_section(peopledir, section_elem)
        section.set_columns(columns)
        for k, v in reportmap.items():
            section[k] = v

    peopledir.set_order(section_order)

    need_reindex = peopledir.update_indexes()
    if need_reindex or force_reindex:
        reindex_peopledirectory(peopledir)
示例#7
0
def main():
    parser = OptionParser(description=__doc__)
    parser.add_option('-C', '--config', dest='config', default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-d', '--dry-run', dest='dry_run',
        action="store_true", default=False,
        help="Don't commit the transactions")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    peopledir = find_peopledirectory(root)
    reindex_peopledirectory(peopledir)

    if options.dry_run:
        transaction.abort()
    else:
        transaction.commit()
示例#8
0
 def _callFUT(self, peopledir):
     from karl.models.peopledirectory import reindex_peopledirectory
     reindex_peopledirectory(peopledir)
示例#9
0
 def _callFUT(self, peopledir):
     from karl.models.peopledirectory import reindex_peopledirectory
     reindex_peopledirectory(peopledir)
示例#10
0
文件: evolve12.py 项目: Falmarri/karl
def evolve(context):
    remove_broken_objects(context['profiles'], sys.stdout)

    print "Reindexing people directory"
    peopledir = find_peopledirectory(context)
    reindex_peopledirectory(peopledir)
示例#11
0
文件: evolve12.py 项目: iotest3/new
def evolve(root):
    peopledir = root['people']
    if peopledir.update_indexes():
        reindex_peopledirectory(peopledir)
示例#12
0
def evolve(context):
    remove_broken_objects(context['profiles'], sys.stdout)

    print "Reindexing people directory"
    peopledir = find_peopledirectory(context)
    reindex_peopledirectory(peopledir)