• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.get_route_value函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tiddlyweb.web.util.get_route_value函数的典型用法代码示例。如果您正苦于以下问题:Python get_route_value函数的具体用法?Python get_route_value怎么用?Python get_route_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _get_links

def _get_links(environ, start_response, linktype):
    """
    Form the links as tiddlers and then send them
    to send_tiddlers. This allows us to use the
    serialization and filtering subsystems on the
    lists of links.
    """
    bag_name = get_route_value(environ, 'bag_name')
    tiddler_title = get_route_value(environ, 'tiddler_name')
    store = environ['tiddlyweb.store']
    filters = environ['tiddlyweb.filters']
    collection_title = '%s for %s' % (linktype, tiddler_title)

    link = environ['SCRIPT_NAME']
    try:
        extension = environ['tiddlyweb.extension']
        link = link.rsplit('.%s' % extension)[0]
    except KeyError:
        pass

    host_tiddler = Tiddler(tiddler_title, bag_name)
    try:
        host_tiddler = store.get(host_tiddler)
    except StoreError, exc:
        raise HTTP404('No such tiddler: %s:%s, %s' % (host_tiddler.bag,
            host_tiddler.title, exc))
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.links,代码行数:26,代码来源:__init__.py


示例2: _determine_tiddler

def _determine_tiddler(environ, bag_finder, revisions=False):
    """
    Determine, using URL info, the target tiddler.
    This can be complicated because of the mechanics
    of recipes and bags.

    Set revisions to True when the current request ends in
    `/revisions` or `/revisions.*`. Doing so ensures that
    processing of extensions does not impact the name of
    the tiddler.
    """
    tiddler_name = get_route_value(environ, 'tiddler_name')
    tiddler = _base_tiddler_object(environ, tiddler_name, revisions)

    # We have to deserialize the tiddler here so that
    # PUTs to recipes are aware of values like tags when
    # doing filter checks.
    if environ['REQUEST_METHOD'] == 'PUT':
        _process_request_body(environ, tiddler)

    try:
        recipe_name = get_route_value(environ, 'recipe_name')
        recipe = Recipe(recipe_name)
        try:
            store = environ['tiddlyweb.store']
            recipe = store.get(recipe)
            tiddler.recipe = recipe_name
        except NoRecipeError, exc:
            raise HTTP404('%s not found via recipe, %s' % (tiddler.title, exc))

        try:
            bag = bag_finder(recipe, tiddler, environ)
        except NoBagError, exc:
            raise HTTP404('%s not found via bag, %s' % (tiddler.title, exc))
开发者ID:tup,项目名称:tiddlyweb,代码行数:34,代码来源:tiddler.py


示例3: bag_tiddler_uri_keys

def bag_tiddler_uri_keys(environ):
    """
    We have a tiddler in a bag URI provide the tiddler key and the bag
    tiddler key.
    """
    bag_name = get_route_value(environ, 'bag_name')
    tiddler_title = get_route_value(environ, 'tiddler_name')
    tiddler = Tiddler(tiddler_title, bag_name)
    return [tiddler_key(tiddler), bag_key(tiddler.bag)]
开发者ID:cdent,项目名称:tiddlywebplugins.fastly,代码行数:9,代码来源:surrogates.py


示例4: post_revisions

def post_revisions(environ, start_response):
    """
    Take a collection of JSON tiddlers, each with a
    text key and value, and process them into the store.
    That collection is known as a TiddlerChronicle.
    """
    tiddler_name = get_route_value(environ, 'tiddler_name')
    bag_name = get_route_value(environ, 'bag_name')
    tiddler = Tiddler(tiddler_name, bag_name)
    return _post_tiddler_revisions(environ, start_response, tiddler)
开发者ID:FND,项目名称:tiddlyweb,代码行数:10,代码来源:chronicle.py


示例5: definition

def definition(environ, start_response):
    store = environ['tiddlyweb.store']
    manifesto = get_route_value(environ, 'manifesto_name')
    definition = get_route_value(environ, 'definition')

    try:
        recipe = Recipe(manifesto)
        recipe = store.get(recipe)
    except NoRecipeError, exc:
        raise HTTP404('no such manifesto: %s' % exc)
开发者ID:cdent,项目名称:manifestopheles,代码行数:10,代码来源:__init__.py


示例6: post_revisions

def post_revisions(environ, start_response):
    """
    Handle a ``POST`` of a chronicle of :py:class:`tiddlers
    <tiddlyweb.model.tiddler.Tiddler>` at a tiddler revisions
    URI.

    Take a collection of ``JSON`` tiddlers, each with a
    text key and value, and process them into the store.
    """
    tiddler_name = get_route_value(environ, 'tiddler_name')
    bag_name = get_route_value(environ, 'bag_name')
    tiddler = Tiddler(tiddler_name, bag_name)
    return _post_tiddler_revisions(environ, start_response, tiddler)
开发者ID:interstar,项目名称:tiddlyweb,代码行数:13,代码来源:chronicle.py


示例7: recipe_tiddler_uri_keys

def recipe_tiddler_uri_keys(environ):
    """
    We have a tiddler in a recipe URI, provide the tiddler and the bag
    tiddler key for all the bags in the recipe.
    """
    store = environ['tiddlyweb.store']
    recipe_name = get_route_value(environ, 'recipe_name')
    tiddler_title = get_route_value(environ, 'tiddler_name')
    recipe = store.get(Recipe(recipe_name))
    tiddler = Tiddler(tiddler_title)
    bag = determine_bag_from_recipe(recipe, tiddler, environ)
    tiddler.bag = bag.name
    return [recipe_key(recipe_name), tiddler_key(tiddler)] + [
            bag_key(bag) for bag, _ in recipe.get_recipe()]
开发者ID:cdent,项目名称:tiddlywebplugins.fastly,代码行数:14,代码来源:surrogates.py


示例8: _get_container

 def _get_container(self):
     routing_args = self.environ.get('wsgiorg.routing_args', ([], {}))[1]
     container_name = False
     container_type = 'bags'
     if routing_args:
         if 'recipe_name' in routing_args:
             container_name = get_route_value(self.environ, 'recipe_name')
             container_type = 'recipes'
         elif 'bag_name' in routing_args:
             container_name = get_route_value(self.environ, 'bag_name')
     if container_name:
         return "%s/%s" % (container_type, container_name)
     else:
         return ""
开发者ID:cdent,项目名称:otw,代码行数:14,代码来源:serialization.py


示例9: current_uri_keys

def current_uri_keys(environ):
    """
    Return relevant keys for the current uri based on routing_args and
    and other factors.
    """
    config = environ.get('tiddlyweb.config', {})
    routing_keys = environ['wsgiorg.routing_args'][1]
    request_uri = (environ.get('SCRIPT_NAME', '') +
            environ.get('PATH_INFO', ''))
    fastly_selector = config.get('fastly.selector')

    if _uri_is_global(request_uri):
        return [DISPATCH[request_uri]()]

    route_keys = [route_name for route_name in routing_keys
            if route_name in ROUTE_NAMES]

    surrogate_keys = []

    try:
        if fastly_selector:
            # Find the selector method for this path (if any)
            method = fastly_selector.select(request_uri, 'GET')[0]
            surrogate_keys = method(environ, None)
            if surrogate_keys:
                return surrogate_keys
    except KeyError:
        pass
            
    if len(route_keys) == 1:
        name = route_keys[0]
        if '/tiddlers' not in request_uri:  # recipe or bag
            surrogate_keys = [DISPATCH[name](get_route_value(environ, name))]
        else:  # recipe or bags tiddlers
            if name == 'recipe_name':
                surrogate_keys = recipe_tiddlers_uri_keys(environ)
            elif name == 'bag_name':
                surrogate_keys = [bag_key(get_route_value(
                    environ, name))]
    else:  # a tiddler, revisions collection or single revision
        is_revision = 'revision' in route_keys
        if 'recipe_name' in route_keys:
            surrogate_keys = recipe_tiddler_uri_keys(environ)
        elif 'bag_name' in route_keys:
            if not is_revision:
                surrogate_keys = bag_tiddler_uri_keys(environ)

    return surrogate_keys
开发者ID:cdent,项目名称:tiddlywebplugins.fastly,代码行数:48,代码来源:surrogates.py


示例10: get_tiddlers

def get_tiddlers(environ, start_response):
    """
    Get a list representation of the tiddlers in a
    bag. The information sent is dependent on the
    serialization chosen.
    """
    store = environ["tiddlyweb.store"]
    filters = environ["tiddlyweb.filters"]
    bag_name = web.get_route_value(environ, "bag_name")
    bag = _get_bag(environ, bag_name)
    title = "Tiddlers From Bag %s" % bag.name
    title = environ["tiddlyweb.query"].get("title", [title])[0]

    usersign = environ["tiddlyweb.usersign"]
    # will raise exception if there are problems
    bag.policy.allows(usersign, "read")

    tiddlers = Tiddlers(title=title)
    if not filters:
        tiddlers.store = store
    tiddlers.bag = bag_name

    # A special bag can raise NoBagError here.
    try:
        for tiddler in store.list_bag_tiddlers(bag):
            tiddlers.add(tiddler)
    except NoBagError, exc:
        raise HTTP404("%s not found, %s" % (bag.name, exc))
开发者ID:FND,项目名称:tiddlyweb,代码行数:28,代码来源:bag.py


示例11: make_ticklist

def make_ticklist(environ, start_response):
    """
    Record routes the user would like to climb.
    """
    store = environ['tiddlyweb.store']
    current_user = environ['tiddlyweb.usersign']['name']
    gym = get_route_value(environ, 'gym')
    tick_wishes = environ['tiddlyweb.query'].get('addroute', [])
    routes = _get_gym_routes(environ, gym)

    for route in routes:
        route.bag = current_user
        if route.title in tick_wishes:
            route.tags = ['tickwish']
            route.fields['gym'] = gym
            store.put(route)
        else:
            try:
                tiddler = store.get(route)
                tiddler.tags.remove('tickwish')
                store.put(tiddler)
            except (StoreError, ValueError):
                pass

    raise HTTP303(server_base_url(environ)
            + '/gyms/%s/ticklist' % encode_name(gym))
开发者ID:cdent,项目名称:nitor,代码行数:26,代码来源:__init__.py


示例12: record_climbs

def record_climbs(environ, start_response):
    """
    Record a climb that has been accomplished.
    """
    query = environ['tiddlyweb.query']
    store = environ['tiddlyweb.store']
    current_user = environ['tiddlyweb.usersign']['name']
    gym = get_route_value(environ, 'gym')

    routes = query['route']
    dones = query['doneroute']
    
    for index, value in enumerate(dones):
        if value != '':
            route_title = routes[index]
            tiddler = Tiddler(route_title, current_user)
            try:
                tiddler = store.get(tiddler)
            except StoreError:
                pass
            if value in CLEAN_CLIMB:
                try:
                    tiddler.tags.remove('tickwish')
                except ValueError:
                    pass
            tiddler.fields['climbtype'] = value
            tiddler.fields['gym'] = gym
            tiddler.tags.append('climb')
            store.put(tiddler)

    raise HTTP303(server_base_url(environ) + environ['REQUEST_URI'])
开发者ID:cdent,项目名称:nitor,代码行数:31,代码来源:__init__.py


示例13: gym_routes

def gym_routes(environ, start_response):
    """
    Display the routes from a single gym.
    """
    store = environ['tiddlyweb.store']
    current_user = environ['tiddlyweb.usersign']['name']
    gym = get_route_value(environ, 'gym')
    routes = _get_gym_routes(environ, gym)
    climbtypes = [tiddler.title for tiddler in
            store.list_bag_tiddlers(Bag(CLIMBTYPES))]
    if current_user:# != 'GUEST':
        search_query = 'bag:%s tag:climb gym:%s _limit:%s' % (current_user,
                gym, len(routes))
        recent_climbs = dict([(tiddler.title, store.get(tiddler))
            for tiddler in store.search(search_query)])
        search_query = 'bag:%s tag:tickwish gym:%s _limit:%s' % (current_user,
                gym, len(routes))
        wished_climbs = [tiddler.title for tiddler in store.search(search_query)]
        for route in routes:
            if route.title in recent_climbs:
                route.fields['climbtype'] = recent_climbs[
                        route.title].fields['climbtype']
            if route.title in wished_climbs:
                route.fields['do'] = True

    return send_template(environ, 'gym_routes.html', {
        'gym': gym,
        'climbtypes': [''] + climbtypes,
        'title': 'Routes @%s' % gym,
        'routes': routes})
开发者ID:cdent,项目名称:nitor,代码行数:30,代码来源:__init__.py


示例14: get_identities

def get_identities(environ, start_response):
    """
    Get a list of the identities associated with the named user.
    That named user must match the current user or the current
    user must be an admin.
    """
    store = environ['tiddlyweb.store']
    username = get_route_value(environ, 'username')
    usersign = environ['tiddlyweb.usersign']['name']
    roles = environ['tiddlyweb.usersign']['roles']

    if username != usersign and 'ADMIN' not in roles:
        raise HTTP403('Bad user for action')

    identities = []
    try:
        mapped_bag = store.get(Bag('MAPUSER'))
        tiddlers = store.list_bag_tiddlers(mapped_bag)
        matched_tiddlers = control.filter_tiddlers(tiddlers,
            'select=mapped_user:%s' % username, environ)
        identities = [tiddler.title for tiddler in matched_tiddlers]
    except NoBagError:
        pass

    start_response('200 OK', [
        ('Content-Type', 'application/json; charset=UTF-8')])
    return [simplejson.dumps(identities)]
开发者ID:colmjude,项目名称:tiddlyspace,代码行数:27,代码来源:handler.py


示例15: get_tiddlers

def get_tiddlers(environ, start_response): # TODO: rename
    config = environ['tiddlyweb.config']

    tags = get_route_value(environ, 'tags')
    tags = csv.reader([tags]).next()

    start_response('200 OK', [('Content-Type', 'text/html; charset=UTF-8')])

    tiddlers = []
    tiddler_ids = []
    for _id, tiddler in commands.get_readable_tagged_tiddlers(environ, tags): # XXX: smell
        tiddlers.append(tiddler)
        tiddler_ids.append(_id)

    yield '<h2 id="tags">Related Tags</h2>\n'
    for tag in commands.get_readable_related_tags(environ, tags, tiddler_ids):
        params = sorted(tags + [tag]) # sorting ensures consistency

        csv_out = StringIO()
        writer = csv.writer(csv_out)
        writer.writerow(params)
        csv_out.seek(0)
        params = csv_out.read().rstrip()

        uri = '/tags/%s' % params # XXX: server prefix & encoding
        yield '<a href="%s">%s</a>\n' % (uri, tag)

    yield '<h2 id="tiddlers">Tiddlers</h2>\n'
    for tiddler in tiddlers:
        uri = '/bags/%s/tiddlers/%s' % (tiddler.bag, tiddler.title) # XXX: server prefix & encoding
        yield '<a href="%s">%s</a>\n' % (uri, tiddler.title)
开发者ID:FND,项目名称:tiddlywebplugins.tagdex,代码行数:31,代码来源:web.py


示例16: get_tiddlers

def get_tiddlers(environ, start_response):
    """
    Get a list representation of the tiddlers in a
    bag. The information sent is dependent on the
    serialization chosen.
    """
    store = environ['tiddlyweb.store']
    filters = environ['tiddlyweb.filters']
    bag_name = web.get_route_value(environ, 'bag_name')
    bag = _get_bag(environ, bag_name)
    title = 'Tiddlers From Bag %s' % bag.name
    title = environ['tiddlyweb.query'].get('title', [title])[0]

    usersign = environ['tiddlyweb.usersign']
    # will raise exception if there are problems
    bag.policy.allows(usersign, 'read')

    tiddlers = Tiddlers(title=title)
    if not filters:
        tiddlers.store = store
    tiddlers.bag = bag_name

    for tiddler in store.list_bag_tiddlers(bag):
        tiddlers.add(tiddler)

    tiddlers.link = '%s/tiddlers' % web.bag_url(environ, bag, full=False)

    return send_tiddlers(environ, start_response, tiddlers=tiddlers)
开发者ID:tup,项目名称:tiddlyweb,代码行数:28,代码来源:bag.py


示例17: recent_changes

def recent_changes(environ, start_response):
    """
    List recent changes for the named tank.
    """
    tank_name = get_route_value(environ, 'bag_name')
    store = environ['tiddlyweb.store']
    usersign = environ['tiddlyweb.usersign']
    config = environ['tiddlyweb.config']
    days = environ['tiddlyweb.query'].get('d', [7])[0]

    try:
        bag = store.get(Bag(tank_name))
        bag.policy.allows(usersign, 'read')
    except NoBagError:
        raise HTTP404('no tank found for %s' % tank_name)

    tiddlers = filter_tiddlers(store.list_bag_tiddlers(bag),
        'select=modified:>%sd;sort=-modified' % days, environ)

    changes_template = get_template(environ, CHANGES_TEMPLATE)
    start_response('200 OK', [
        ('Content-Type', 'text/html; charset=UTF-8'),
        ('Cache-Control', 'no-cache')])
    return changes_template.generate({
        'socket_link': config.get('socket.link'),
        'csrf_token': get_nonce(environ),
        'days': days,
        'tiddlers': tiddlers,
        'bag': bag,
        'gravatar': gravatar(environ),
        'user': usersign['name'],
    })
开发者ID:pads,项目名称:tank,代码行数:32,代码来源:wiki.py


示例18: manage_gym

def manage_gym(environ, start_response):
    store = environ['tiddlyweb.store']
    gym = get_route_value(environ, 'gym')
    routes_bag = store.get(Bag('%s_climbs' % gym))
    news_bag = Bag('%s_news' % gym)
    # Bail out if we are not allowed to manage. 
    routes_bag.policy.allows(environ['tiddlyweb.usersign'], 'manage')
    gym_tiddler = store.get(Tiddler(gym, GYMS_BAG))

    try:
        latest_news = [tiddler for tiddler in filter_tiddlers(
            store.list_bag_tiddlers(news_bag),
            'sort=-modified;limit=1', environ)][0]
        latest_news = store.get(latest_news)
        news_html = render_wikitext(latest_news, environ)
        latest_news.fields['html'] = news_html
    except IndexError:
        latest_news = Tiddler('tmp')
        latest_news.fields['html'] = '<p>No News</p>'

    routes = _get_gym_routes(environ, gym)

    return send_template(environ, 'manage_gym.html', {
        'title': 'Manage %s' % gym,
        'gym_tiddler': gym_tiddler,
        'latest_news': latest_news,
        'routes': routes})
开发者ID:FND,项目名称:nitor,代码行数:27,代码来源:__init__.py


示例19: delete

def delete(environ, start_response):
    """
    Remove a bag and its tiddlers from the store.
    How the store chooses to handle remove and what
    it means is up to the store.
    """
    bag_name = web.get_route_value(environ, 'bag_name')
    bag_name = web.handle_extension(environ, bag_name)

    usersign = environ['tiddlyweb.usersign']

    bag = _get_bag(environ, bag_name)
    bag.policy.allows(usersign, 'manage')
    # reuse the store attribute that was set on the
    # bag when we "got" it.
    # we don't need to check for existence here because
    # the above get already did
    try:
        store = environ['tiddlyweb.store']
        store.delete(bag)
    except StoreMethodNotImplemented:
        raise HTTP400('Bag DELETE not supported')

    start_response("204 No Content", [])
    return []
开发者ID:tup,项目名称:tiddlyweb,代码行数:25,代码来源:bag.py


示例20: put

def put(environ, start_response):
    """
    Put a bag to the server, meaning the description and
    policy of the bag, if policy allows.
    """
    bag_name = web.get_route_value(environ, 'bag_name')
    bag_name = web.handle_extension(environ, bag_name)

    bag = Bag(bag_name)
    store = environ['tiddlyweb.store']
    length, _ = web.content_length_and_type(environ)

    usersign = environ['tiddlyweb.usersign']

    try:
        bag = store.get(bag)
        bag.policy.allows(usersign, 'manage')
    except NoBagError:
        create_policy_check(environ, 'bag', usersign)

    try:
        serialize_type = web.get_serialize_type(environ)[0]
        serializer = Serializer(serialize_type, environ)
        serializer.object = bag
        content = web.read_request_body(environ, length)
        serializer.from_string(content.decode('utf-8'))

        bag.policy.owner = usersign['name']

        _validate_bag(environ, bag)
        store.put(bag)
    except BagFormatError, exc:
        raise HTTP400('unable to put bag: %s' % exc)
开发者ID:tup,项目名称:tiddlyweb,代码行数:33,代码来源:bag.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_serialize_type函数代码示例发布时间:2022-05-27
下一篇:
Python util.encode_name函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap