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


Python AssetResolver.abspath方法代码示例

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


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

示例1: create_app

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def create_app(settings):
    from pyramid.config import Configurator
    from pyramid.authorization import ACLAuthorizationPolicy
    from pyramid.path import AssetResolver
    from pyramid.response import FileResponse

    from h.auth import HybridAuthenticationPolicy
    from h.models import groupfinder

    authn_policy = HybridAuthenticationPolicy(callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )

    favicon = AssetResolver().resolve('h:favicon.ico')
    config.add_route('favicon', '/favicon.ico')
    config.add_view(
        lambda request: FileResponse(favicon.abspath(), request=request),
        route_name='favicon'
    )

    config.add_route('ok', '/ruok')
    config.add_view(lambda request: 'imok', renderer='string', route_name='ok')

    # Include all the pyramid subcomponents
    config.include(includeme)

    return config.make_wsgi_app()
开发者ID:jnishiyama,项目名称:h,代码行数:34,代码来源:__init__.py

示例2: get_template

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
    def get_template(self, uri):
        """Fetch a template from the cache, or check the filesystem
        for it

        In addition to the basic filesystem lookup, this subclass will
        use pkg_resource to load a file using the asset
        specification syntax.

        """
        isabs = os.path.isabs(uri)
        if (not isabs) and (':' in uri):
            # Windows can't cope with colons in filenames, so we replace the
            # colon with a dollar sign in the filename mako uses to actually
            # store the generated python code in the mako module_directory or
            # in the temporary location of mako's modules
            adjusted = uri.replace(':', '$')
            try:
                if self.filesystem_checks:
                    return self._check(adjusted, self._collection[adjusted])
                else:
                    return self._collection[adjusted]
            except KeyError:
                asset = AssetResolver().resolve(uri)
                if asset.exists():
                    srcfile = asset.abspath()
                    return self._load(srcfile, adjusted)
                raise TopLevelLookupException(
                    "Can not locate template for uri %r" % uri)
        try:
            return TemplateLookup.get_template(self, uri)
        except TemplateLookupException:
            if isabs:
                return self._load(uri, uri)
            else:
                raise
开发者ID:kr41,项目名称:pyramid_mako,代码行数:37,代码来源:__init__.py

示例3: create_app

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def create_app(settings):
    from horus import groupfinder
    from pyramid.config import Configurator
    from pyramid.authentication import AuthTktAuthenticationPolicy
    from pyramid.authorization import ACLAuthorizationPolicy
    from pyramid.path import AssetResolver
    from pyramid.response import FileResponse

    authn_policy = AuthTktAuthenticationPolicy(
        settings['auth.secret'],
        callback=groupfinder
    )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        root_factory='h.resources.RootFactory'
    )

    favicon = AssetResolver().resolve('h:favicon.ico')
    config.add_route('favicon', '/favicon.ico')
    config.add_view(
        lambda request: FileResponse(favicon.abspath(), request=request),
        route_name='favicon'
    )

    config.include(includeme)
    return config.make_wsgi_app()
开发者ID:3divs,项目名称:h,代码行数:32,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def main(global_config, **settings):
    """ This function is a 'paste.app_factory' and returns a WSGI
    application.
    """
    static = AssetResolver().resolve(settings['kotti_dkbase.maintenance_page'])
    with open(static.abspath(), 'r') as f:
        body = '\n'.join(f.readlines())

    def maintenance(environ, start_response):
        start_response('503 Service Unavailable',
                       [('content-type', 'text/html')])
        return [body]

    return maintenance
开发者ID:chrneumann,项目名称:kotti_dkbase,代码行数:16,代码来源:maintenance.py

示例5: load_schema

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def load_schema(filename):
    if isinstance(filename, dict):
        schema = filename
        resolver = NoRemoteResolver.from_schema(schema)
    else:
        utf8 = codecs.getreader("utf-8")
        asset = AssetResolver(caller_package()).resolve(filename)
        schema = json.load(utf8(asset.stream()),
                           object_pairs_hook=collections.OrderedDict)
        resolver = RefResolver('file://' + asset.abspath(), schema)
    schema = mixinProperties(schema, resolver)

    # SchemaValidator is not thread safe for now
    SchemaValidator(schema, resolver=resolver, serialize=True)
    return schema
开发者ID:Kapeel,项目名称:encoded,代码行数:17,代码来源:schema_utils.py

示例6: create_app

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def create_app(settings):
    config = Configurator(settings=settings)
    config.include('h')

    favicon = AssetResolver().resolve('h:favicon.ico')
    config.add_route('favicon', '/favicon.ico')
    config.add_view(
        lambda request: FileResponse(favicon.abspath(), request=request),
        route_name='favicon'
    )

    config.add_route('ok', '/ruok')
    config.add_view(lambda request: 'imok', renderer='string', route_name='ok')

    config.set_root_factory('h.resources.RootFactory')

    return config.make_wsgi_app()
开发者ID:Treora,项目名称:h,代码行数:19,代码来源:app.py

示例7: includeme

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def includeme(config):
    config.include('pyramid_multiauth')
    config.include('h.api')
    config.include('h.models')
    config.include('h.streamer')
    config.include('h.subscribers')
    config.include('h.views')
    config.set_root_factory('h.resources.RootFactory')

    favicon = AssetResolver().resolve('h:favicon.ico')
    config.add_route('favicon', '/favicon.ico')
    config.add_view(
        lambda request: FileResponse(favicon.abspath(), request=request),
        route_name='favicon'
    )

    config.add_route('ok', '/ruok')
    config.add_view(lambda request: 'imok', renderer='string', route_name='ok')
开发者ID:RichardLitt,项目名称:h,代码行数:20,代码来源:__init__.py

示例8: create_app

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def create_app(settings):
    config = Configurator(settings=settings)

    favicon = AssetResolver().resolve("h:favicon.ico")
    config.add_route("favicon", "/favicon.ico")
    config.add_view(lambda request: FileResponse(favicon.abspath(), request=request), route_name="favicon")

    config.add_route("ok", "/ruok")
    config.add_view(lambda request: "imok", renderer="string", route_name="ok")

    config.include(includeme)
    config.commit()

    # Register a default session factory if there is still none registered
    if config.registry.queryUtility(ISessionFactory) is None:
        random_secret = uuid.uuid4().hex + uuid.uuid4().hex
        session_factory = SignedCookieSessionFactory(random_secret)
        config.set_session_factory(session_factory)

    return config.make_wsgi_app()
开发者ID:helemaalbigt,项目名称:h,代码行数:22,代码来源:__init__.py

示例9: create_app

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def create_app(settings):
    from horus import groupfinder
    from pyramid.config import Configurator
    from pyramid.authentication import SessionAuthenticationPolicy
    from pyramid.authorization import ACLAuthorizationPolicy
    from pyramid.path import AssetResolver
    from pyramid.response import FileResponse

    authn_policy = SessionAuthenticationPolicy(callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )

    favicon = AssetResolver().resolve('h:favicon.ico')
    config.add_route('favicon', '/favicon.ico')
    config.add_view(
        lambda request: FileResponse(favicon.abspath(), request=request),
        route_name='favicon'
    )

    config.add_route('ok', '/ruok')
    config.add_view(lambda request: 'imok', renderer='string', route_name='ok')

    # Include the base configuration for horus integration
    config.include('h.forms')
    config.include('h.models')
    config.include('h.schemas')
    config.commit()

    # Include horus
    config.include('horus')
    config.commit()

    # Include the rest of the application
    config.include(includeme)

    return config.make_wsgi_app()
开发者ID:davidmcclure,项目名称:h,代码行数:43,代码来源:__init__.py

示例10: load_schema

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import abspath [as 别名]
def load_schema(filename):
    if isinstance(filename, dict):
        schema = filename
        resolver = NoRemoteResolver.from_schema(schema)
    else:
        utf8 = codecs.getreader("utf-8")
        asset = AssetResolver(caller_package()).resolve(filename)
        schema = json.load(utf8(asset.stream()),
                           object_pairs_hook=collections.OrderedDict)
        resolver = RefResolverOrdered('file://' + asset.abspath(), schema)
    # use mixinProperties, mixinFacets, mixinAggregations, and mixinColumns (if provided)
    schema = mixinSchemas(
        mixinSchemas(
            mixinSchemas( mixinSchemas(schema, resolver, 'properties'), resolver, 'facets' ),
            resolver,
            'aggregations'
        ),
        resolver, 'columns'
    )

    # SchemaValidator is not thread safe for now
    SchemaValidator(schema, resolver=resolver, serialize=True)
    return schema
开发者ID:j1z0,项目名称:snovault,代码行数:25,代码来源:schema_utils.py


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