Author: jmorliaguet
Date: Mon Dec  5 15:42:06 2005
New Revision: 1960

Modified:
   cpsskins/branches/jmo-perspectives/browser/editing/create_setting.pt
   cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
   cpsskins/branches/jmo-perspectives/browser/editing/manage_settings.pt
   cpsskins/branches/jmo-perspectives/browser/editing/views.py
   cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
   cpsskins/branches/jmo-perspectives/configuration/styles/style.py
   cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
   cpsskins/branches/jmo-perspectives/engines/sitedesigner/site_designer.pt
   cpsskins/branches/jmo-perspectives/setup/resources.py
Log:

- simplification of urls

- using the DRY principle: formats, settings, resources are refered to by their
  tagged name only (getTaggedValue('name')) so we don't have to convert between
  interfaces names, and short name, and dotted names, ...



Modified: cpsskins/branches/jmo-perspectives/browser/editing/create_setting.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/create_setting.pt        
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/create_setting.pt        
Mon Dec  5 15:42:06 2005
@@ -1,7 +1,7 @@
 <html metal:use-macro="context/@@popup_macros/page">
   <body metal:fill-slot="body" i18n:domain="cpsskins">
     <div class="editArea">
-      <h1>Create setting</h1>
+      <h1>Create a setting</h1>
 
       <div class="main">
         <form enctype="multipart/form-data" method="post"

Modified: cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     Mon Dec 
 5 15:42:06 2005
@@ -41,7 +41,8 @@
     <div style="clear:both"></div>
 
     <div class="editActions" tal:define="actions info/actions">
-      <a href="#" tal:repeat="action actions" tal:attributes="href action/url">
+      <a href="#" tal:repeat="action actions" target="main"
+                  tal:attributes="href action/url">
         <img src="" tal:attributes="src 
string:/++skins++cpsskins/@@${action/icon}" />
         <tal:block content="action/title" i18n:translate="" />
       </a>

Modified: cpsskins/branches/jmo-perspectives/browser/editing/manage_settings.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/manage_settings.pt       
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/manage_settings.pt       
Mon Dec  5 15:42:06 2005
@@ -3,10 +3,25 @@
     <div class="editArea">
       <h1>Manage settings</h1>
 
-      <p>This format uses a setting</p>
+      <p>This format uses a setting, in order to modify it you will need to
+         create a local copy.</p>
 
+      <h2>Edit this setting</h2>
       <ul>
-        <li>Create a copy of the setting</li>
+        <li>Create a local copy</li>
+      </ul>
+
+      <h2>Use other settings</h2>
+      <ul tal:define="setting_info context/@@getSettingInfo;
+                      format_type request/form/format|string:''">
+        <li tal:condition="python: format_type in setting_info"
+            tal:repeat="info setting_info/?format_type">
+          <tal:block define="name info/name">
+            <a href=""
+               tal:attributes="href 
string:./@@useSettingAsFormat?setting_name=$name&format_type=$format_type"
+               tal:content="info/name" />
+          </tal:block>
+        </li>
       </ul>
 
     </div>

Modified: cpsskins/branches/jmo-perspectives/browser/editing/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/views.py (original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/views.py Mon Dec  5 
15:42:06 2005
@@ -97,8 +97,6 @@
         form = request.form
         format_name = form.get('format')
         main_url = form.get('main_url')
-        action = form.get('action')
-        base = form.get('base')
 
         negociation = getMultiAdapter((context, request),
                                       INegociation, 'negociation')
@@ -118,8 +116,9 @@
             }
 
         # Formats
+        format = None
         formats_info = []
-        can_create_setting = True
+        format_is_setting = False
         for f in formattable.getFormats(resolve=False):
             is_setting = ISetting.providedBy(f)
             if is_setting:
@@ -127,12 +126,13 @@
             name = f.formatname
             selected = name == format_name
             if selected:
+                format = f
                 if is_setting:
-                    base = 'display'
-                    action = action or 'manage-settings.html'
-                    can_create_setting = False
+                    main_url = '%s/@@manage-settings.html?format=%s' % (
+                               self.getAbsoluteURL(display), name),
+                    format_is_setting = True
                 else:
-                    main = f
+                    main = format
 
             formats_info.append({
                 'title': IType(f).getContentType().__name__,
@@ -142,28 +142,22 @@
 
         # Actions
         actions_info = []
-        if format_name and can_create_setting:
-            actions_info.append({
+        if format_name and not format_is_setting:
+            actions_info.extend([{
                 'title': u'Create setting',
-                'url': '@@%s?action=%s&format=%s' % \
-                       ('edit-menu.html', 'create-setting.html', format_name),
+                'url': '%s/@@create-setting.html?format=%s' % (
+                        self.getAbsoluteURL(format), format_name),
                 'icon': u'create-setting-16.png',
-                })
-
-        if format_name:
-            actions_info.append({
+                },
+                {
                 'title': u'Use setting',
-                'url': '@@%s?base=display&action=%s&format=%s' % \
-                       ('edit-menu.html', 'use-setting.html', format_name),
+                'url': '%s/@@use-setting.html?format=%s' % (
+                        self.getAbsoluteURL(display), format_name),
                 'icon': u'use-setting-16.png',
-                })
+                }])
 
         # Main area
-        if base == 'display':
-            main = display
-
-        action = action or 'edit.html'
-        main_url = main_url or self.getAbsoluteURL(main) + '/@@' + action
+        main_url = main_url or self.getAbsoluteURL(main) + '/@@edit.html'
 
         return {
             'negociation': negociation,

Modified: 
cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py    
    (original)
+++ 
cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py    
    Mon Dec  5 15:42:06 2005
@@ -27,6 +27,8 @@
 class IPerspective(ISetting):
     """A perspective configuration item."""
 
+IPerspective.setTaggedValue('name', 'perspective')
+
 class Perspective(Persistent, Contained):
     """A perspective configuration item.
     """

Modified: cpsskins/branches/jmo-perspectives/configuration/styles/style.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/styles/style.py    
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/styles/style.py    Mon Dec 
 5 15:42:06 2005
@@ -27,6 +27,8 @@
 class IStyle(ISetting):
     """A style configuration item."""
 
+IStyle.setTaggedValue('name', 'style')
+
 class Style(Persistent, Contained):
     """A style configuration item.
     """

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  Mon Dec 
 5 15:42:06 2005
@@ -23,9 +23,9 @@
 from tarfile import TarFile, TarInfo
 from cStringIO import StringIO
 
+from zope.app.interface import queryType
 from zope.app.publisher.browser import BrowserView
 from zope.component import getUtilitiesFor, getUtility
-from zope.app.interface import queryType
 from zope import xmlpickle 
 
 from cpsskins.setup.interfaces import (
@@ -57,9 +57,12 @@
         info = {}
         # get all settings
         for name, setting in getUtilitiesFor(ISetting):
-            setting_type = queryType(setting, ISettingType).__name__
-            info.setdefault(setting_type, []).append({'name': name,
-                'setting': setting, 'customized': False})
+            setting_type = queryType(setting, ISettingType)
+            info.setdefault(setting_type.getTaggedValue('name'), []).append({
+                'name': name,
+                'setting': setting,
+                'customized': False,
+                })
         return info
 
     def customizeSetting(self, name=u''):

Modified: 
cpsskins/branches/jmo-perspectives/engines/sitedesigner/site_designer.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/sitedesigner/site_designer.pt    
(original)
+++ cpsskins/branches/jmo-perspectives/engines/sitedesigner/site_designer.pt    
Mon Dec  5 15:42:06 2005
@@ -30,7 +30,7 @@
               <img class="icon"
                    src="/++skin++cpsskins/@@/++resource++settings-48.png" />
               <ul>
-                <li tal:repeat="subsection python:['IPerspective', 'IStyle', 
'IAccessKey']">
+                <li tal:repeat="subsection python:['perspective', 'style']">
                   <a class="section"
                      tal:attributes="href 
string:@@setSelection?subsection=$subsection"
                      tal:content="subsection" i18n:translate="" />

Modified: cpsskins/branches/jmo-perspectives/setup/resources.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/setup/resources.py       (original)
+++ cpsskins/branches/jmo-perspectives/setup/resources.py       Mon Dec  5 
15:42:06 2005
@@ -17,10 +17,11 @@
 """
 __docformat__ = "reStructuredText"
 
+from copy import deepcopy
+
 from zope.app.component.interfaces.registration import ActiveStatus
 from zope.app.component.site import UtilityRegistration
 from zope.app.container.interfaces import INameChooser
-from zope.app.location.pickling import locationCopy
 from zope.interface import implements
 from zope.component import (getUtilitiesFor, queryUtility, getUtility,
                             provideUtility)
@@ -91,7 +92,7 @@
         resource = None
         resource_getter = IResource(setting)
         if resource_getter is not None:
-            resource = locationCopy(resource_getter.getResource())
+            resource = deepcopy(resource_getter.getResource())
 
         self.register(name=name, title=setting.title, resource=resource,
                       context=context)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to