示例#1
0
def destroy(context, request):
    session = get_shib_session(request)
    data = get_base_data(context, request)
    root = find_root(context)
    certificate = root.slcs.get(session)

    credname = request.params['credname']

    context.myproxy_destroy(certificate, credname)

    return HTTPFound(location=model_url(context, request))
示例#2
0
def default(context, request):
    data = get_base_data(context, request)
    session = get_shib_session(request)
    if session:
        root = find_root(context)
        certificate = root.slcs.get(session)
        data['myproxyinfo'] = None
        if certificate:
            data['myproxyinfo'] = context.myproxy_info(certificate)

        proxies = context.get(session)
        data['proxies'] = proxies

    hostname = socket.getfqdn()
    return data
示例#3
0
def put(context, request):
    session = get_shib_session(request)
    data = get_base_data(context, request)
    if request.params:
        info = parse(request.environ, request.environ['wsgi.input'])
        proxy = info['proxy']

        root = find_root(context)
        certificate = root.slcs.get(session)

        cred_name = proxy.name or None
        password = proxy.password or None

        context.myproxy_put(session, certificate, cred_name, password)

        return HTTPFound(location=model_url(context, request))
    return data
示例#4
0
文件: evolve6.py 项目: boothead/karl
def evolve(context):
    root = find_root(context)
    searcher = ICatalogSearch(root)
    total, docids, resolver = searcher(interfaces=[IForumTopic])
    count = 0
    workflow = get_workflow(IForumTopic, 'security')
    for docid in docids:
        topic = resolver(docid)
        if has_custom_acl(topic):
            continue # don't mess with objects customized via edit_acl
        try:
            state, msg = workflow.reset(topic)
        except:
            print "ERROR while resetting topic workflow: %s" % model_path(topic)
        else:
            print "Reset topic workflow: %s" % model_path(topic)
            count += 1
    print "Updated %d forum topic workflows" % count
示例#5
0
文件: utils.py 项目: russell/lanyard
def get_base_data(context, request):
    main = get_template("../templates/master.pt")
    data = {"main": main, "project": "lanyard"}
    home_node = find_root(context)
    data["navitems"] = [
        {"href": model_url(home_node, request), "title": "Home", "state": ""},
        {
            "href": model_url(home_node.slcs, request),
            "title": home_node.slcs.__name__.upper(),
            "state": ("", "current_page_item")[home_node.slcs == context],
        },
        {
            "href": model_url(home_node.proxies, request),
            "title": "MyProxy",
            "state": ("", "current_page_item")[home_node.proxies == context],
        },
    ]
    return data
示例#6
0
文件: evolve4.py 项目: boothead/karl
def evolve(context):
    root = find_root(context)
    searcher = ICatalogSearch(root)
    categories_and_layers_query = dict(
        interfaces={'query':[ICalendarCategory, ICalendarLayer],
                    'operator':'or'},
        )
    total, docids, resolver = searcher(**categories_and_layers_query)
    changed_categories = {}
    for docid in docids:
        ob = resolver(docid)
        if ob is None:
            # slash in path, likely
            path = root.catalog.document_map.docid_to_address.get(docid)
            if path is not None:
                container_path, ob_name = path.rsplit('/', 1)
                container = find_model(root, container_path)
                name = urllib.unquote(ob_name)
                ob = container.get(name)
            
        if ob is not None:
            ob_name = ob.__name__
            if not (ob_name.startswith('_default_') or is_opaque_id(ob_name)):
                old_path = model_path(ob)
                container = ob.__parent__
                new_name = generate_name(container)
                del container[ob_name]
                ob.__name__ = new_name # XXX required?
                container.add(new_name, ob, send_events=False)
                new_path = model_path(ob)
                index_content(ob, None)
                print 'path fixed: %s -> %s' % (old_path, new_path)
                if ICalendarCategory.providedBy(ob):
                    changed_categories[old_path] = new_path

    if changed_categories:
        # fix layer.paths
        layers_query = dict(interfaces=[ICalendarLayer])
        total, docids, resolver = searcher(**layers_query)
        for docid in docids:
            layer = resolver(docid)
            if layer is not None:
                new_paths = []
                changed = []
                for path in layer.paths:
                    if path in changed_categories:
                        new_paths.append(changed_categories[path])
                        changed.append((path, changed_categories[path]))
                    else:
                        new_paths.append(path)

                if changed:
                    layer.paths = new_paths
                    reindex_content(layer, None)
                    print 'layer fixed: %s, %s' % (
                        model_path(layer), [ '%s -> %s' % x for x in changed ])

        # fix the category of events
        events_query = dict(
            interfaces=[ICalendarEvent],
            )
        total, docids, resolver = searcher(**events_query)
        for docid in docids:
            event = resolver(docid)
            if event is not None:
                category = event.calendar_category
                if category in changed_categories:
                    old_category = event.calendar_category
                    new_category = changed_categories[category]
                    event.calendar_category = new_category
                    reindex_content(event, None)
                    print 'event fixed: %s, %s -> %s' % (
                        model_path(event),
                        old_category,
                        new_category)
示例#7
0
文件: tests.py 项目: russell/lanyard
    def test_slcs_request(self):
        from repoze.bfg.traversal import find_root

        context = dummy_model_factory()
        root = find_root(context.slcs)
        self.assertEqual(root, context)
示例#8
0
def find_site(context):
    site = find_interface(context, ISite)
    if site is None:
        # for unittesting convenience
        site = find_root(context)
    return site
示例#9
0
def find_tempfolder(context):
    root = find_root(context)
    if not 'TEMP' in root:
        root['TEMP'] = TempFolder()
    return root['TEMP']
示例#10
0
 def __call__(self, context, utility_name):
     if utility_name not in self._utilities:
         raise KeyError('`%s` is not a registered utility' % utility_name)
     return find_model(find_root(context), self._utilities[utility_name])