Author: jmorliaguet
Date: Thu Dec  8 17:22:34 2005
New Revision: 1996

Modified:
   cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
   cpsskins/branches/jmo-perspectives/setup/registration.py
Log:

- filesystem settings can be reloaded (refreshed)



Modified: cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  
(original)
+++ cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  Thu Dec 
 8 17:22:34 2005
@@ -26,9 +26,9 @@
 from zope.component import getUtilitiesFor, getUtility, getMultiAdapter
 from zope.component import queryUtility, getAllUtilitiesRegisteredFor
 
-from cpsskins.setup.interfaces import (
-    ISetting, IResourceType, IResource, IResourceManager,
-    )
+from cpsskins.setup.interfaces import ISetting, IResource
+from cpsskins.setup.interfaces import IResourceType, IResourceManager
+from cpsskins.setup.registration import refresh
 
 setting_xml = """<?xml version="1.0"?>
 <setting name="%(name)s" title="%(title)s">
@@ -110,7 +110,7 @@
         """Reload the setting from the file-system
         """
 
-        #TODO
+        refresh(name)
 
         target = self.request.get('HTTP_REFERER', '.')
         self.request.response.redirect(target)

Modified: cpsskins/branches/jmo-perspectives/setup/registration.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/setup/registration.py    (original)
+++ cpsskins/branches/jmo-perspectives/setup/registration.py    Thu Dec  8 
17:22:34 2005
@@ -27,6 +27,7 @@
 from zope.component.interfaces import IFactory
 
 from cpsskins.setup.interfaces import IResourceImporter, IResourceManager
+from cpsskins.setup.interfaces import ISetting, IResource
 
 DEBUG = logging.DEBUG
 logger = logging.getLogger()
@@ -51,7 +52,7 @@
             resource = setting.getElementsByTagName('*')
             if not resource:
                 logger.log(DEBUG,
-                    "cpsskins no resource found for: %s" % name)
+                    "no resource found for: %s" % name)
                 continue
             resource = resource[0]
             factory = queryUtility(IFactory, resource.tagName)
@@ -68,5 +69,29 @@
             resources.register(name=name, title=title, 
resource=resource_object,
                                filename=filename)
 
-        logger.log(DEBUG, "cpsskins loaded setting: %s" % filename)
+        logger.log(DEBUG, "loaded settings in: %s" % filename)
+
+
+def refresh(name=u''):
+
+    setting = getUtility(ISetting, name)
+    filename = setting.filename
+
+    if not filename:
+        raise TypeError("The setting is not a file-system setting.")
+
+    dom = parse(filename)
+    for setting_node in dom.getElementsByTagName('setting'):
+        if setting_node.getAttribute('name') != name:
+            continue
+
+        resource = setting_node.getElementsByTagName('*')
+        if not resource:
+            break
+        resource = resource[0]
+
+        resource_object = IResource(setting).getResource()
+        IResourceImporter(resource_object).load(resource.toxml())
+
+        logger.log(DEBUG, "reloaded setting: %s (in %s)" % (name, filename))
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to