Author: jmorliaguet Date: Tue Nov 22 14:02:56 2005 New Revision: 1920 Added: cpsskins/branches/jmo-perspectives/configuration/styles/ cpsskins/branches/jmo-perspectives/configuration/styles/__init__.py (contents, props changed) cpsskins/branches/jmo-perspectives/configuration/styles/configure.zcml (contents, props changed) cpsskins/branches/jmo-perspectives/configuration/styles/meta.zcml (contents, props changed) cpsskins/branches/jmo-perspectives/configuration/styles/metaconfigure.py (contents, props changed) cpsskins/branches/jmo-perspectives/configuration/styles/metadirectives.py (contents, props changed) cpsskins/branches/jmo-perspectives/configuration/styles/style.py (contents, props changed) cpsskins/branches/jmo-perspectives/engines/default/README.txt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/configuration/__init__.py cpsskins/branches/jmo-perspectives/configuration/meta.zcml cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py cpsskins/branches/jmo-perspectives/engines/default/formats/interfaces.py cpsskins/branches/jmo-perspectives/engines/default/formats/style.py Log:
- added a <cpsskins:style> directive for registering styles (as settings) Modified: cpsskins/branches/jmo-perspectives/configuration/__init__.py ============================================================================== --- cpsskins/branches/jmo-perspectives/configuration/__init__.py (original) +++ cpsskins/branches/jmo-perspectives/configuration/__init__.py Tue Nov 22 14:02:56 2005 @@ -34,6 +34,7 @@ IPerspective, Perspective) from cpsskins.configuration.renderers.renderer import IRenderer, Renderer from cpsskins.configuration.widgets.widget import IWidget, Widget +from cpsskins.configuration.styles.style import IStyle, Style # TODO: this will go away (replaced with utilities) Modified: cpsskins/branches/jmo-perspectives/configuration/meta.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/configuration/meta.zcml (original) +++ cpsskins/branches/jmo-perspectives/configuration/meta.zcml Tue Nov 22 14:02:56 2005 @@ -14,6 +14,8 @@ <include package=".perspectives" file="meta.zcml" /> + <include package=".styles" file="meta.zcml" /> + <include package=".displays" file="meta.zcml" /> <include package=".formats" file="meta.zcml" /> Modified: cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py ============================================================================== --- cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py (original) +++ cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py Tue Nov 22 14:02:56 2005 @@ -38,9 +38,3 @@ required=False, ) - title = TextLine( - title=_("Title"), - description=_("The title of the perspective."), - required=False, - ) - Added: cpsskins/branches/jmo-perspectives/configuration/styles/__init__.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/__init__.py Tue Nov 22 14:02:56 2005 @@ -0,0 +1,20 @@ +############################################################################## +# +# Copyright (c) 2005 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +"""Rendering engine traverser /++engine++name + +$Id$ +""" + +__docformat__ = "reStructuredText" + Added: cpsskins/branches/jmo-perspectives/configuration/styles/configure.zcml ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/configure.zcml Tue Nov 22 14:02:56 2005 @@ -0,0 +1,19 @@ +<configure + xmlns="http://namespaces.zope.org/zope" + xmlns:browser="http://namespaces.zope.org/browser"> + + <localUtility class="cpsskins.configuration.style.Style"> + + <require + permission="zope.ManageServices" + interface="cpsskins.configuration.style.IStyle" + /> + + </localUtility> + + <adapter + for="cpsskins.configuration.style.IStyle" + factory="cpsskins.setup.settings.Resource" + /> + +</configure> Added: cpsskins/branches/jmo-perspectives/configuration/styles/meta.zcml ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/meta.zcml Tue Nov 22 14:02:56 2005 @@ -0,0 +1,13 @@ + +<configure xmlns="http://namespaces.zope.org/meta"> + + <directives namespace="http://namespaces.zope.org/cpsskins"> + + <directive + name="style" + schema=".metadirectives.IStyleDirective" + handler=".metaconfigure.style" /> + + </directives> + +</configure> Added: cpsskins/branches/jmo-perspectives/configuration/styles/metaconfigure.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/metaconfigure.py Tue Nov 22 14:02:56 2005 @@ -0,0 +1,45 @@ +############################################################################## +# +# Copyright (c) 2005 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" +__docformat__ = "reStructuredText" + +from zope.component import queryUtility, provideUtility, getUtility +from zope.configuration.exceptions import ConfigurationError +from zope.interface import alsoProvides + +from cpsskins import configuration +from cpsskins.engines.default.formats.style import Style, Resources +from cpsskins.engines.default.formats.interfaces import IStyle +from cpsskins.setup.interfaces import IResourceManager, ISettingType + +alsoProvides(configuration.IStyle, ISettingType) + +def style(_context, name=u'', resource=u''): + + if queryUtility(configuration.IStyle, name) is not None: + raise ConfigurationError( + "The '%s' style has already been registered." % name) + + if not resource: + raise ConfigurationError("Must specify a resource name") + + # register the style as a global setting + resource_object = getUtility(IStyle, resource) + resources = Resources(resource_object) + resources.register(name=name, title=resource_object.title, + resource=resource_object) + Added: cpsskins/branches/jmo-perspectives/configuration/styles/metadirectives.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/metadirectives.py Tue Nov 22 14:02:56 2005 @@ -0,0 +1,40 @@ +############################################################################## +# +# Copyright (c) 2005 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" +__docformat__ = "reStructuredText" + +from zope.interface import Interface +from zope.i18nmessageid import MessageFactory +from zope.schema import DottedName, TextLine + +_ = MessageFactory("cpsskins") + +class IStyleDirective(Interface): + + name = DottedName( + title=_("Name"), + description=_("The name of the style."), + required=False, + min_dots=1, + ) + + resource = TextLine( + title=_("Resource"), + description=_("The name of the resource."), + required=False, + ) + Added: cpsskins/branches/jmo-perspectives/configuration/styles/style.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/configuration/styles/style.py Tue Nov 22 14:02:56 2005 @@ -0,0 +1,39 @@ +############################################################################## +# +# Copyright (c) 2005 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" + +__docformat__ = "reStructuredText" + +from zope.app.container.contained import Contained +from zope.interface import implements, Interface, Attribute +from persistent import Persistent + +from cpsskins.setup.interfaces import ISetting + +class IStyle(ISetting): + """A style configuration item.""" + +class Style(Persistent, Contained): + """A style configuration item. + """ + implements(IStyle) + + def __init__(self, title=u'', readonly=False, resource=None): + self.title = title + self.readonly = readonly + self.resource = resource + Added: cpsskins/branches/jmo-perspectives/engines/default/README.txt ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/engines/default/README.txt Tue Nov 22 14:02:56 2005 @@ -0,0 +1,5 @@ + +$Id:$ + +This directory contains the default resources, filters, formats, engine +definitions. They are considered as mandatory parts of the application. Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/interfaces.py ============================================================================== --- cpsskins/branches/jmo-perspectives/engines/default/formats/interfaces.py (original) +++ cpsskins/branches/jmo-perspectives/engines/default/formats/interfaces.py Tue Nov 22 14:02:56 2005 @@ -19,4 +19,5 @@ from cpsskins.elements.interfaces import IFormat from widget import IWidget +from style import IStyle Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/style.py ============================================================================== --- cpsskins/branches/jmo-perspectives/engines/default/formats/style.py (original) +++ cpsskins/branches/jmo-perspectives/engines/default/formats/style.py Tue Nov 22 14:02:56 2005 @@ -22,9 +22,11 @@ from zope.interface import implements from zope.i18nmessageid import MessageFactory +from cpsskins import configuration from cpsskins.elements.format import Format from cpsskins.elements.interfaces import IFormat from cpsskins.relations import Predicate +from cpsskins.setup.resources import ResourceManager _ = MessageFactory("cpsskins") @@ -153,3 +155,10 @@ return self.id __contains__ = has_key + +class Resources(ResourceManager): + """This adapter makes styles usable as resources + """ + setting_type = configuration.IStyle + setting_factory = configuration.Style + -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins