[Cherokee-commits] rev 1079 - cherokee/trunk/admin

cherokee at cherokee-project.com cherokee at cherokee-project.com
Sun Feb 17 12:29:05 CET 2008


Author: alo
Date: 2008-02-17 12:29:04 +0100 (Sun, 17 Feb 2008)
New Revision: 1079
Log:

Get the changeset with:
  svn diff -r 1078:1079 svn://svn.cherokee-project.com/

Modified:
  cherokee/trunk/admin/PageIcon.py
   30 ++++++++++++++++++++++++------
  cherokee/trunk/admin/config.py
    5 +++++

Modified: cherokee/trunk/admin/PageIcon.py
===================================================================
--- cherokee/trunk/admin/PageIcon.py	2008-02-16 22:16:19 UTC (rev 1078)
+++ cherokee/trunk/admin/PageIcon.py	2008-02-17 11:29:04 UTC (rev 1079)
@@ -46,10 +46,19 @@
         # Return the URL
         return "/%s" % (self._id)
 
-    def _get_options_icons (self, cfg_key):
+    def _get_options_icons (self, cfg_key, file_filter=None):
+        file_options = []
+
+        # No icon
+        if file_filter and not file_filter(''):
+            file_options.append (('', 'None'))
+
         # Build icons list
-        file_options = [('', 'None')]
         for file in os.listdir (CHEROKEE_ICONSDIR):
+            if file_filter:
+                ignore = file_filter (file)
+                if ignore: continue
+
             f = file.lower()
             if (f.endswith(".jpg") or
                 f.endswith(".png") or
@@ -147,16 +156,17 @@
                 cfg_key  = 'icons!suffix!%s' % (icon)
                 im = self._get_img_from_icon (icon, cfg_key)
 
-                entry    = self.InstanceEntry (cfg_key, 'text')
-                js       = "post_del_key('/icons/update', '%s');" % (cfg_key)
-                button   = self.InstanceButton ('Del', onClick=js)
+                entry  = self.InstanceEntry (cfg_key, 'text')
+                js     = "post_del_key('/icons/update', '%s');" % (cfg_key)
+                button = self.InstanceButton ('Del', onClick=js)
                 table += (im, icon, entry, button)
 
             tmp += str(table)
 
         # New suffix
         fo1 = Form ("/%s/add_suffix" % (self._id), add_submit=False)
-        op1, im1 = self._get_options_icons ('suffix_new_file')
+        op1, im1 = self._get_options_icons ('suffix_new_file', 
+                                            self._filter_icons_in_suffixes)
         en2 = self.InstanceEntry('suffix_new_exts', 'text')
         ta1 = Table (4,1)
         ta1 += ('', 'Icon', 'Extensions', '')
@@ -172,3 +182,11 @@
     def _op_apply_changes (self, post):
         self.ApplyChanges ([], post)
         return "/%s" % (self._id)
+
+    def _filter_icons_in_suffixes (self, file):
+        cfg = self._cfg['icons!suffix']
+        if not cfg:
+            return False
+        if not file:
+            return True
+        return file in cfg.keys()

Modified: cherokee/trunk/admin/config.py
===================================================================
--- cherokee/trunk/admin/config.py	2008-02-16 22:16:19 UTC (rev 1078)
+++ cherokee/trunk/admin/config.py	2008-02-17 11:29:04 UTC (rev 1079)
@@ -119,6 +119,10 @@
     def has_child (self):
         return len(self._child) > 0
 
+    def keys (self):
+        return self._child.keys()
+
+
 class Config:
     def __init__ (self, file=None):
         self.root = ConfigNode()
@@ -226,3 +230,4 @@
 
     def has_tree (self):
         return len(self.root._child) > 0
+




More information about the Cherokee-commits mailing list