我使用Diazo在特定的url上部署静态html文件'ticker.html‘。该页面完全不使用内容。
这是rules.xml:
<rules xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<rules if-path="/Plone/ticker/ /ticker/">
<theme href="ticker.html" />
</rules>
<rules css:if-content="#visual-portal-wrapper" if-not-path="/Plone/ticker/ /ticker/">
<theme href="index.html" />
The rest of the theme...
</rules>
</rules>它工作得很好,html是正确的,但是http://localhost:8080/Plone/ticker的返回代码是404。只有当我在这个位置用Plone创建一些虚拟内容时,我才能得到200。返回的内容也略有改变:当存在虚拟内容时,Diazo向标头添加一个基标记:
<base href="http://localhost:8080/Plone/ticker/" />我如何告诉重氮完全忽略内容,并返回一个200,即使没有虚拟内容?
如果你想知道:我使用的是重氮,因为plone.app.themeing允许通过网络修改静态页面。
发布于 2014-09-05 15:32:10
plone.app.theming转换是传递管道中的最后一步。内容已经从Plone中召唤出来,这样就可以与主题结合起来。所以,这不是个合适的地方。
相反,使用反向代理的重写规则执行此操作。当代理收到对目标URL的请求时,请让它获取您的代码。在这个过程中,您还将节省大量的CPU周期,因为您将避免通过Zope/Plone的机器完成整个旅程。
发布于 2014-10-27 21:22:16
我有一个类似的用法,我想通过Zope向AngularJS服务器一些AngularJS。他们是text/html,所以他们通过plone.app.theming被改造了。在深入了解plone.app.theming之后,我在新文件transforms.py中重载了一个子类适配器,如下所示:
# -*- coding: utf-8 -*-
from plone.app.theming import transform
from your.theme.interfaces import IYourThemeLayer
from zope.component import adapter
from zope.interface import Interface
@adapter(Interface, IYourThemeLayer
class ThemeTransform(transform.ThemeTransform):
def parseTree(self, result):
# Prevent diazo from adding doctype and html head to every
# html file. Exclude all partial resources from theme transforms
if '/++resource++your.theme.js-partials/' in self.request.getURL():
return None
return super(ThemeTransform, self).parseTree(result)..。并在zcml中注册为与默认ThemeTransform适配器相同的名称,使用:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="your.theme">
<!-- Override plone.app.theming adapter -->
<adapter
name="plone.app.theming.transform"
factory=".transform.ThemeTransform"
zcml:condition="installed plone.app.theming"
/>
</configure>可能与此问题有关:https://dev.plone.org/ticket/13139
https://stackoverflow.com/questions/25687377
复制相似问题