Author: jmorliaguet Date: Wed Nov 30 11:08:34 2005 New Revision: 1949 Added: cpsskins/branches/jmo-perspectives/browser/editing/views.py - copied, changed from r1946, cpsskins/branches/jmo-perspectives/browser/editing/editing.py Removed: cpsskins/branches/jmo-perspectives/browser/editing/editing.py cpsskins/branches/jmo-perspectives/browser/editing/settings.py Modified: cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml cpsskins/branches/jmo-perspectives/browser/editing/edit_settings.pt cpsskins/branches/jmo-perspectives/engines/authoring/authoring.css cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt Log:
- saving work Modified: cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml Wed Nov 30 11:08:34 2005 @@ -46,14 +46,14 @@ layer="cpsskins" for="cpsskins.elements.interfaces.IElement" permission="zope.ManageContent" - class=".editing.EditPanel" + class=".views.EditPanel" /> <pages for="cpsskins.elements.interfaces.IElement" layer="cpsskins" permission="zope.ManageContent" - class=".editing.Editing"> + class=".views.Editing"> <page name="getId" @@ -81,7 +81,7 @@ for="cpsskins.elements.interfaces.IElement" layer="cpsskins" permission="zope.ManageContent" - class=".settings.SettingsView"> + class=".views.SettingsView"> <page name="createSetting" Modified: cpsskins/branches/jmo-perspectives/browser/editing/edit_settings.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/browser/editing/edit_settings.pt (original) +++ cpsskins/branches/jmo-perspectives/browser/editing/edit_settings.pt Wed Nov 30 11:08:34 2005 @@ -1,7 +1,6 @@ <html metal:use-macro="context/@@popup_macros/page"> <body metal:fill-slot="body" i18n:domain="cpsskins"> - <div class="editArea" - tal:define="id request/form/id|nothing"> + <div class="editArea"> <h1>Settings</h1> <h2>Create setting</h2> @@ -25,9 +24,11 @@ <h2>Use setting</h2> + <span tal:content="context/@@absolute_url" /> <!-- For testing --> <ul tal:define="setting_info context/@@getSettingInfo"> - <li tal:repeat="info setting_info/IStyle"> + <li tal:condition="python: 'IStyle' in setting_info" + tal:repeat="info setting_info/IStyle"> <tal:block define="name info/name"> <a href="" tal:attributes="href string:./@@useSettingAsFormat?name=$name" Copied: cpsskins/branches/jmo-perspectives/browser/editing/views.py (from r1946, cpsskins/branches/jmo-perspectives/browser/editing/editing.py) ============================================================================== --- cpsskins/branches/jmo-perspectives/browser/editing/editing.py (original) +++ cpsskins/branches/jmo-perspectives/browser/editing/views.py Wed Nov 30 11:08:34 2005 @@ -17,15 +17,26 @@ """ __docformat__ = "reStructuredText" +from zope.app.location.pickling import locationCopy from zope.app.location.traversing import LocationPhysicallyLocatable from zope.app.publisher.browser import BrowserView from zope.app.traversing.api import getParent from zope.app.zapi import queryMultiAdapter, getMultiAdapter -from zope.component import adapts +from zope.component import adapts, queryUtility, getUtility from zope.interface import implements, Interface +from zope.security.proxy import removeSecurityProxy +from cpsskins import configuration from cpsskins.elements.interfaces import IElement, IDisplayable, IFormattable from cpsskins.browser.negociation.interfaces import INegociation +from cpsskins.ontology import hasFormat +from cpsskins.relations.interfaces import IRelationTool +from cpsskins.relations.relations import DyadicRelation +from cpsskins.setup.interfaces import IResourceManager, ISetting + +####################################################################### +# Generic views +####################################################################### class IEditing(Interface): @@ -70,6 +81,10 @@ icon_url = icon.url() return icon_url +####################################################################### +# Edit panel +####################################################################### + class EditPanel(BrowserView): def getMainUrl(self): @@ -98,3 +113,58 @@ main_url = base_url + form.get('action', '@@edit.html') return main_url + + +####################################################################### +# Settings +####################################################################### + +class ISettingsView(Interface): + + def createSetting(title): + """Create a setting from an object considered as a resource.""" + + def useSettingAsFormat(name): + """Replace an existing format with a setting.""" + +class SettingsView(BrowserView): + + implements(ISettingsView) + + def createSetting(self, title=u''): + resource = locationCopy(removeSecurityProxy(self.context)) + resources = IResourceManager(resource) + resources.register(title=title, resource=resource, context=self.context) + target = self.request.get('HTTP_REFERER', '.') + self.request.response.redirect(target) + + def useSettingAsFormat(self, name=u''): + if not name: + raise KeyError("Must specify a setting's name.") + + context = self.context + setting = queryUtility(ISetting, name) + if setting is None: + raise KeyError("No such setting.") + + reltool = IRelationTool(context) + displays = reltool.getFirsts(second=context, predicate=hasFormat) + if len(displays) > 1: + raise KeyError("The format is used by several displays.") + display = displays[0] + + # create a display -- setting relation + predicate = getUtility(configuration.IFormat, + context.formatname).predicate + relation = DyadicRelation(first=display, second=setting, + predicate=predicate) + reltool.add(relation) + + # remove existing display -- format relation + old_rel = reltool.search(first=display, second=context, + predicate=hasFormat) + reltool.remove(old_rel) + + target = self.request.get('HTTP_REFERER', '.') + self.request.response.redirect(target) + Modified: cpsskins/branches/jmo-perspectives/engines/authoring/authoring.css ============================================================================== --- cpsskins/branches/jmo-perspectives/engines/authoring/authoring.css (original) +++ cpsskins/branches/jmo-perspectives/engines/authoring/authoring.css Wed Nov 30 11:08:34 2005 @@ -236,7 +236,7 @@ border-width: 1px 2px 2px 1px; border-style: solid; border-color: #666; - background: #f6f3f3; + background: #eeeeec; color: #000; cursor: default; z-index: 2000; Modified: cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt (original) +++ cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt Wed Nov 30 11:08:34 2005 @@ -27,13 +27,6 @@ <div class="editArea"> <h1>Style editor</h1> - - <p i18n:translate="" - tal:condition="python: len(displays) > 1"> - This style is being used by several elements. Create a local copy. - </p> - - </div> <!-- the style editor --> -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins