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


Python IRequest.resource_url方法代码示例

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


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

示例1: _get_api_auth_data

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import resource_url [as 别名]
def _get_api_auth_data(headers: [tuple], request: IRequest, user: IResource)\
        -> dict:
    token_headers = dict([(x, y) for x, y in headers if x == UserTokenHeader])
    token = token_headers[UserTokenHeader]
    user_url = request.resource_url(user)
    # TODO: use colander schema to create cstruct
    return {'status': 'success',
            'user_path': user_url,
            'user_token': token,
            }
开发者ID:Janaba,项目名称:adhocracy3,代码行数:12,代码来源:views.py

示例2: get_choices_by_interface

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import resource_url [as 别名]
def get_choices_by_interface(interface: IInterface,
                             context: IResource,
                             request: IRequest,
                             ) -> []:
    """Get choices for resource paths by interface."""
    catalogs = find_service(context, 'catalogs')
    query = search_query._replace(interfaces=interface)
    resources = catalogs.search(query).elements
    choices = [(request.resource_url(r,
                                     route_name=API_ROUTE_NAME),
                resource_path(r)) for r in resources]
    return choices
开发者ID:liqd,项目名称:adhocracy3,代码行数:14,代码来源:__init__.py

示例3: embed_code_config_adapter

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import resource_url [as 别名]
def embed_code_config_adapter(context: IResource,
                              request: IRequest) -> {}:
    """Return mapping to render `adhocracy_core:templates/embed_code.html`."""
    settings = request.registry.settings
    frontend_url = settings.get('adhocracy.frontend_url',
                                'http://localhost:6551')
    sdk_url = os.path.join(frontend_url, 'AdhocracySDK.js')
    path = request.resource_url(context)
    locale = settings.get('pyramid.default_locale_name', 'en')
    return {'sdk_url': sdk_url,
            'frontend_url': frontend_url,
            'path': path,
            'widget': '',
            'autoresize': 'false',
            'locale': locale,
            'autourl': 'false',
            'nocenter': 'true',
            'style': 'height: 650px',
            }
开发者ID:Janaba,项目名称:adhocracy3,代码行数:21,代码来源:embed.py

示例4: embed_code_config_adapter

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import resource_url [as 别名]
def embed_code_config_adapter(context: IResource,
                              request: IRequest) -> {}:
    """Return mapping to render `adhocracy_core:templates/embed_code.html`."""
    settings = request.registry['config']
    frontend_url = settings.adhocracy.frontend_url
    sdk_url = os.path.join(frontend_url, 'AdhocracySDK.js')
    path = request.resource_url(context, route_name=API_ROUTE_NAME)
    # TODO use frontend.locale instead
    locale = settings.configurator.pyramid.default_locale_name
    return {'sdk_url': sdk_url,
            'frontend_url': frontend_url,
            'path': path,
            'widget': '',
            'autoresize': 'false',
            'locale': locale,
            'autourl': 'false',
            'initial_url': '',
            'nocenter': 'true',
            'noheader': 'false',
            'style': 'height: 650px',
            }
开发者ID:liqd,项目名称:adhocracy3,代码行数:23,代码来源:embed.py


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