本文整理汇总了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,
)