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


Python Bundle.extra["authenticated"]方法代码示例

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


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

示例1: generate

# 需要导入模块: from webassets import Bundle [as 别名]
# 或者: from webassets.Bundle import extra["authenticated"] [as 别名]
    def generate(self, force="true"):
        context = aq_inner(self.context)
        env = zope.component.getUtility(IWebAssetsEnvironment)
        if force == "true":
            env.clear()

        # export portal tool content to filesystem and register as assets
        for info in [CSS, JS]:
            tool = getToolByName(context, info.oid)
            tool.setDebugMode(False)
            theme = tool.getCurrentSkinName()
            resources = tool.getResourcesDict()
            for i, entry in enumerate(tool.getCookedResources(theme)):

                # get groups of resources
                # the groups are defined by the resource attributes
                # see `compareResources`-method in individual tools
                sheets = tool.concatenatedResourcesByTheme.get(theme, {})
                subentries = sheets.get(entry.getId())
                bundle_sheets = []

                # get individual resources of a group and write them
                # to the file system
                for eid in subentries:
                    resource = resources[eid]
                    if resource.getConditionalcomment():
                        LOG.debug("skipping %s", eid)
                        continue
                    LOG.debug("merging %s", eid)
                    file_resource = join(env.directory, info.suffix, eid)
                    if not exists(dirname(file_resource)):
                        makedirs(dirname(file_resource))
                    f = open(file_resource, "w")
                    content = tool.getResourceContent(eid, context, original=True, theme=theme)

                    if info.suffix == "css":
                        m = resource.getMedia()
                        if m:
                            content = "@media %s {\n%s\n}\n" % (m, content)

                    f.write(content.encode("utf-8"))
                    f.close()
                    bundle_sheets.append("%s/%s" % (info.suffix, eid))
                if not bundle_sheets:
                    continue

                # generate asset and register with bundle
                if entry.getCompression() == "none":
                    bundle = Bundle(*bundle_sheets, output="gen/packed%s.%s" % (i, info.suffix))
                else:
                    bundle = Bundle(*bundle_sheets, filters=info.filters, output="gen/packed%s.%s" % (i, info.suffix))
                bundle.extra["authenticated"] = entry.getAuthenticated()
                bundle.extra["expression"] = entry.getCookedExpression()
                if info.suffix == "css":
                    bundle.extra["media"] = entry.getMedia()
                    bundle.extra["rendering"] = entry.getRendering()
                try:
                    env.register("%s-%s" % (info.suffix, i), bundle)
                except RegisterError:
                    return ("Failed!\nBundle %s-%s already registered. " "Try force mode to recreate environment.") % (
                        info.suffix,
                        i,
                    )
开发者ID:collective,项目名称:collective.assets,代码行数:65,代码来源:browser.py


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