[uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 21 Jul 2010 11:28:30 +0200
branchstable
changeset 6000 98ca82aae3a1
parent 5999 eaf8219f8b7d
child 6001 1a21d7d2c959
[uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
web/propertysheet.py
--- a/web/propertysheet.py	Tue Jul 20 16:45:11 2010 +0200
+++ b/web/propertysheet.py	Wed Jul 21 11:28:30 2010 +0200
@@ -23,6 +23,10 @@
 import os
 import os.path as osp
 
+TYPE_CHECKS = [('STYLESHEETS', list), ('JAVASCRIPTS', list),
+               ('STYLESHEETS_IE', list), ('STYLESHEETS_PRINT', list),
+               ]
+
 class lazystr(object):
     def __init__(self, string, context):
         self.string = string
@@ -54,6 +58,11 @@
         scriptglobals = self.context.copy()
         scriptglobals['__file__'] = fpath
         execfile(fpath, scriptglobals, self)
+        for name, type in TYPE_CHECKS:
+            if name in self:
+                if not isinstance(self[name], type):
+                    msg = "Configuration error: %s.%s should be a %s" % (fpath, name, type)
+                    raise Exception(msg)
         self._propfile_mtime[fpath] = os.stat(fpath)[-2]
         self._ordered_propfiles.append(fpath)