Author: jmorliaguet
Date: Tue May 30 12:58:47 2006
New Revision: 3275

Modified:
   
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- useFormatAsSetting() is now functional



Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    Tue May 30 12:58:47 2006
@@ -59,7 +59,7 @@
       <tal:block content="structure info/preview" />
     </fieldset>
 
-    <div tal:condition="python: mode == 'manage-presets'">
+    <div tal:condition="python: mode == 'manage-presets' or preset">
       <fieldset class="panel" tal:condition="not:preset">
         <legend class="panelTitle">Create a preset</legend>
         <form enctype="multipart/form-data" method="post"
@@ -74,7 +74,7 @@
         </form>
       </fieldset>
 
-      <fieldset class="panel" condition="python: edited_type in preset_info">
+      <fieldset class="panel" tal:condition="python: edited_type in 
preset_info">
         <legend class="panelTitle">Use an existing preset</legend>
         <ul class="inlineTabs">
           <li tal:repeat="preset preset_info/?edited_type">

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Tue May 
30 12:58:47 2006
@@ -23,13 +23,15 @@
 from zope.security.proxy import removeSecurityProxy
 
 from cpsskins import minjson as json
-from cpsskins.elements.interfaces import IDisplay
-from cpsskins.storage.interfaces import IStorage
+from cpsskins.elements.interfaces import IDisplay, IFormat
+from cpsskins.relations import DyadicRelation
+from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.setup.interfaces import IType, IIdentifiable
 from cpsskins.setup.interfaces import IResourceManager, IResource
 from cpsskins.setup.io import importSite, exportSite
 from cpsskins.setup.registration import refreshPresets
 from cpsskins.setup.snapshot import Snapshot
+from cpsskins.storage.interfaces import IStorage
 from cpsskins.utils import getThemeManager
 
 class SiteDesignerView:
@@ -129,6 +131,21 @@
         if preset is None:
             raise KeyError("No such preset: '%s'." % uri)
 
+        resource = IResource(preset).getResource()
+        if not IFormat.providedBy(resource):
+            raise TypeError("The resource must be a format.")
+
+        # remove the existing display <--> format relation
+        reltool = IRelationTool(context)
+        predicate = resource.predicate
+        old_rel = reltool.search(first=context, predicate=predicate)
+        reltool.remove(old_rel)
+
+        # create a new display <--> setting relation
+        relation = DyadicRelation(first=context, second=preset,
+                                  predicate=predicate)
+        reltool.add(relation)
+
     ### Sites  #########################################################
 
     def importSite(self, file=None):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to