6

I have a blank Plone 4.1 site with only collective.quickupload installed. The upload portlet worked fine until I install plone.app.theming and apply my theme. The files were still uploaded, but the web client got "Failed" status.

Inspecting the ajax response from server I found that they were wrapped by html header. The old response (before install diazo & apply my theme) was simply

{"success":true}

The new response (after install diazo and apply my theme) was being wrapped by a html tag:

<!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>

I've pasted my rule.xml file here (nothing special, there is only one rule conditioned by css:if-content="#visual-portal-wrapper"): http://pastebin.com/SaK13Fni

What should I do to work around this ?

Thanks

quyetnd
  • 589
  • 3
  • 8

2 Answers2

8

To avoid this behavior you have to add an exception in your rules.xml that specify to not apply your theme to your specific view , like this:

<notheme if-path="myjson_view"/>

edit:

I've tried with one of my diazo themes and a json view and I didn't have your issue. So I think the problem is either in your rules.xml or in your json view. You should try one of these two way:

  1. change your rules.xml this way:

       <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. have you already specified the "Content-type" of the output in your json view? Like this:

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

    If not, that's probably the problem.

Giacomo Spettoli
  • 4,476
  • 1
  • 16
  • 24
  • Too bad it not worked. I've tried both add inside root rules with css:if-content="#visual-portal-wrapper" or outside (wrap with another rules tag). I think the problem is the header is added before all the transformation to make sure it follows xhtml syntax. – quyetnd Sep 22 '11 at 09:33
  • I see. I've tried to reproduce your error and i've edited my answer consequently – Giacomo Spettoli Sep 22 '11 at 10:10
  • 1
    Answer 2 here is correct. The next release of plone.app.theming will never theme ZMI pages. – Laurence Rowe Sep 22 '11 at 10:35
  • 1
    Thanks guys, The problem was that the content-type was set to text/html, that make the whole wrap thing expected/good behaviour. A side note (Not related to the problem): Setting content-type back to application/json (or text/plain, text/json, whatever/whatever) make the html version of multiupload portlet collective.quickupload do not work on IE. I fell back to the flash version. – quyetnd Sep 26 '11 at 08:10
0

Watch out for using Chrome inspector... it adds the html head and pre tags around your json when you inspect it...it's not actually there if you look at view:source of the page (old school)...

Aaron Williams
  • 655
  • 4
  • 11