6

我有一个只安装了collective.quickupload 的空白Plone 4.1 站点。在我安装 plone.app.theming 并应用我的主题之前,上传 portlet 运行良好。文件仍在上传,但 Web 客户端的状态为“失败”。

检查来自服务器的 ajax 响应,我发现它们被 html 标头包装。旧的回应(在安装重氮和应用我的主题之前)很简单

{"success":true}

新的响应(在安装 diazo 并应用我的主题之后)被一个 html 标签包裹:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><body><p>{"success":true}</p></body></html>

我在这里粘贴了我的 rule.xml 文件(没什么特别的,只有一条规则受 css:if-content="#visual-portal-wrapper" 限制): http: //pastebin.com/SaK13Fni

我应该怎么做才能解决这个问题?

谢谢

4

2 回答 2

8

为了避免这种行为,您必须在您的指定中添加一个异常,rules.xml以指定不将您的主题应用于您的特定视图,如下所示:

<notheme if-path="myjson_view"/>

编辑

我已经尝试过使用我的重氮主题和 json 视图之一,但没有遇到您的问题。所以我认为问题出在您的 rules.xml 或您的 json 视图中。您应该尝试以下两种方式之一:

  1. 改变你的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">
    
        <!-- Prevent theme usage in zmi-->
        <rules css:if-content="#visual-portal-wrapper">
            <theme href="index.html" />
        </rules>
    
  2. 您是否已经在 json 视图中指定了输出的“内容类型”?像这样:

    self.request.response.setHeader("Content-type","application/json")
    return json_data
    

    如果不是,那可能就是问题所在。

于 2011-09-22T09:07:27.833 回答
0

注意使用 Chrome 检查器...当您检查它时,它会在您的 json 周围添加 html 头和 pre 标记...如果您查看 view:source of the page (old school),它实际上并不存在...

于 2015-02-06T05:27:12.643 回答