You are here: Home / Documentation / How To's / How to check for debug modes

How to check for debug modes

by nguyen — published Apr 16, 2009 03:55 PM, last modified Aug 16, 2016 10:50 AM
Script to check that CSS and Javascript debug modes are not set (".checkDebugMode")
# Script to place in Zope root that checks CSS and Javascript debug mode in all the contained Plone sites.

from Products.CMFCore.utils import getToolByName

uniqueDict = {}

for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   css = getToolByName(site, 'portal_css')
   cssdebugmode = css.getDebugMode()
   if cssdebugmode:
       print "Plone site <a href=\"%s\">%s</a> CSS debug mode: " % (site.portal_url()+'/portal_css/manage_cssForm', site.id)
       print "    ", cssdebugmode, "<br>"
   js = getToolByName(site, 'portal_javascripts')
   jsdebugmode = js.getDebugMode()
   if jsdebugmode:
       print "Plone site <a href=\"%s\">%s</a> JS debug mode: " % (site.portal_url()+'/portal_javascripts/manage_jsForm', site.id)
       print "    ", jsdebugmode, "<br>"
 elif str(itemType).startswith('<Folder at '):
   folder = getattr(context, item)
   for folderItemTuple in folder.items():
     (folderItem, folderItemType) = folderItemTuple
     if str(folderItemType).startswith('<PloneSite at '):
       site = getattr(folder, folderItem)
       css = getToolByName(site, 'portal_css')
       cssdebugmode = css.getDebugMode()
       if cssdebugmode:
           print "Plone site <a href=\"%s\">%s</a> CSS debug mode: " % (site.portal_url()+'/portal_css/manage_cssForm', site.id)
           print "    ", cssdebugmode, "<br>"
       js = getToolByName(site, 'portal_javascripts')
       jsdebugmode = js.getDebugMode()
       if jsdebugmode:
           print "Plone site <a href=\"%s\">%s</a> JS debug mode: " % (site.portal_url()+'/portal_javascripts/manage_jsForm', site.id)
           print "    ", jsdebugmode, "<br>"

print "End of run"    
return printed


Navigation