[Checkins] SVN: z3ext.cssregistry/ initial import
Nikolay Kim
fafhrd at datacom.kz
Fri Mar 21 02:44:45 EDT 2008
Log message for revision 84821:
initial import
Changed:
A z3ext.cssregistry/
A z3ext.cssregistry/branches/
A z3ext.cssregistry/tags/
A z3ext.cssregistry/trunk/
A z3ext.cssregistry/trunk/AUTHOR.txt
A z3ext.cssregistry/trunk/CHANGES.txt
A z3ext.cssregistry/trunk/LICENSE.txt
A z3ext.cssregistry/trunk/bootstrap.py
A z3ext.cssregistry/trunk/buildout.cfg
A z3ext.cssregistry/trunk/setup.py
A z3ext.cssregistry/trunk/src/
A z3ext.cssregistry/trunk/src/z3ext/
A z3ext.cssregistry/trunk/src/z3ext/__init__.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/README.txt
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/__init__.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/command.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/configlet.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.pt
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/configure.zcml
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/i18n.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/interfaces.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/meta.zcml
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/property.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/registry.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/tests.py
A z3ext.cssregistry/trunk/src/z3ext/cssregistry/zcml.py
-=-
Property changes on: z3ext.cssregistry/trunk
___________________________________________________________________
Name: svn:ignore
+ bin
develop-eggs
eggs
parts
coverage
.installed.cfg
Added: z3ext.cssregistry/trunk/AUTHOR.txt
===================================================================
--- z3ext.cssregistry/trunk/AUTHOR.txt (rev 0)
+++ z3ext.cssregistry/trunk/AUTHOR.txt 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1 @@
+Nikolay Kim (fafhrd91 <at> gmail <dot> com)
Added: z3ext.cssregistry/trunk/CHANGES.txt
===================================================================
--- z3ext.cssregistry/trunk/CHANGES.txt (rev 0)
+++ z3ext.cssregistry/trunk/CHANGES.txt 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,42 @@
+=======
+CHANGES
+=======
+
+1.2.0 (2008-03-21)
+------------------
+
+- tests updated
+
+- move to svn.zope.org
+
+
+1.1.3 (2008-02-11)
+------------------
+
+- Fixed control panel configlet
+
+
+1.1.2 (2008-02-08)
+------------------
+
+- Security declarations fixed
+
+
+1.1.1 (2008-02-08)
+------------------
+
+- Remove support cssregistry as utility
+
+
+1.1.0 (2008-02-08)
+------------------
+
+- Added controlpanel configlet
+
+- Code cleanup
+
+
+1.0.0 (2007-12-01)
+------------------
+
+- Initial release.
Added: z3ext.cssregistry/trunk/LICENSE.txt
===================================================================
--- z3ext.cssregistry/trunk/LICENSE.txt (rev 0)
+++ z3ext.cssregistry/trunk/LICENSE.txt 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,54 @@
+Zope Public License (ZPL) Version 2.1
+-------------------------------------
+
+A copyright notice accompanies this license document that
+identifies the copyright holders.
+
+This license has been certified as open source. It has also
+been designated as GPL compatible by the Free Software
+Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions in source code must retain the
+ accompanying copyright notice, this list of conditions,
+ and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying
+ copyright notice, this list of conditions, and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to
+ endorse or promote products derived from this software
+ without prior written permission from the copyright
+ holders.
+
+4. The right to distribute this software or to use it for
+ any purpose does not give you the right to use
+ Servicemarks (sm) or Trademarks (tm) of the copyright
+ holders. Use of them is covered by separate agreement
+ with the copyright holders.
+
+5. If any files are modified, you must cause the modified
+ files to carry prominent notices stating that you changed
+ the files and the date of any change.
+
+Disclaimer
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+ AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
Added: z3ext.cssregistry/trunk/bootstrap.py
===================================================================
--- z3ext.cssregistry/trunk/bootstrap.py (rev 0)
+++ z3ext.cssregistry/trunk/bootstrap.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: z3ext.cssregistry/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/buildout.cfg
===================================================================
--- z3ext.cssregistry/trunk/buildout.cfg (rev 0)
+++ z3ext.cssregistry/trunk/buildout.cfg 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,18 @@
+[buildout]
+develop = .
+parts = test coverage-test coverage-report
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.cssregistry [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.cssregistry [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Added: z3ext.cssregistry/trunk/setup.py
===================================================================
--- z3ext.cssregistry/trunk/setup.py (rev 0)
+++ z3ext.cssregistry/trunk/setup.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,71 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+"""Setup for z3ext.cssregistry package
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version = '1.2.0'
+
+
+setup(name='z3ext.cssregistry',
+ version=version,
+ description="CSS Registry - zrt-cssregistry command for z3c.zrtresource",
+ long_description=(
+ 'Detailed Dcoumentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'cssregistry', 'README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ classifiers=[
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ author='Nikolay Kim',
+ author_email='fafhrd91 at gmail.com',
+ url='http://z3ext.net/',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir = {'':'src'},
+ namespace_packages=['z3ext'],
+ install_requires = ['setuptools',
+ 'zope.schema',
+ 'zope.proxy',
+ 'zope.interface',
+ 'zope.component',
+ 'zope.i18nmessageid',
+ 'zope.configuration',
+ 'z3c.zrtresource>=1.1.0',
+ ],
+ extras_require = dict(test=['zope.app.testing',
+ 'zope.testing',
+ 'zope.publisher',
+ 'zope.traversing',
+ ]),
+ include_package_data = True,
+ zip_safe = False,
+ )
Property changes on: z3ext.cssregistry/trunk/setup.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/__init__.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/__init__.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/__init__.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Property changes on: z3ext.cssregistry/trunk/src/z3ext/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/README.txt
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/README.txt (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/README.txt 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,207 @@
+============
+CSS Registry
+============
+
+A registry for linked Stylesheet files and Javascripts.
+
+This registry is mainly aimed at solving the following usecases:
+
+ - Enable skin developer to change css properties without having to
+ resort to override css files itself
+
+ - Enable more componentialization of the stylesheets.
+
+Some usefull imports
+
+ >>> from zope import interface, component
+ >>> from zope.interface.verify import verifyObject
+ >>> from z3ext.cssregistry.interfaces import \
+ ... Layer, ICSSRegistry, ICSSRegistryLayer
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+
+Load directive declaration
+
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.string("""
+ ... <configure>
+ ... <include package="z3ext.cssregistry" file="meta.zcml" />
+ ... </configure>""")
+
+Now we can create css registry
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:browser="http://namespaces.zope.org/browser">
+ ... <browser:cssregistry>
+ ... <property name="color1" value="#f5f5f5" />
+ ... <property name="color2" value="white" />
+ ... <property name="fontFamilyH1" value="Verdana" />
+ ... <property name="fontFamilyH2" value="Arial" />
+ ... </browser:cssregistry>
+ ... </configure>""", context)
+
+`browser:cssregistry` diretive creates ICSSRegistry. It accepts name,title,layer
+parameters. All parameters not required, by default registry will have blank name
+and registered against IDefaultBrowserLayer layer. We can't register cssregistry
+for layer, because in that case it whould be available as resource (++resource++)
+So directive register multi adapter for ICSSRegistryLayer and supplied layer
+
+ >>> registry = component.getMultiAdapter((Layer, Layer, request), ICSSRegistry)
+ >>> verifyObject(ICSSRegistry, registry)
+ True
+
+ >>> registry['color1'].value
+ u'#f5f5f5'
+
+ >>> registry['fontFamilyH1'].value
+ u'Verdana'
+
+We also can add more properties later:
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:browser="http://namespaces.zope.org/browser">
+ ... <browser:cssproperty name="color3" value="#225593" />
+ ... </configure>""", context)
+
+ >>> registry['color3'].value
+ u'#225593'
+
+
+zrt command
+-----------
+
+z3ext.cssregistry package aslo register new command for z3c.zrtresource.
+
+ >>> from z3ext.cssregistry.command import cssregistry_factory
+ >>> from z3c.zrtresource.interfaces import IZRTCommandFactory
+
+ >>> component.provideUtility(cssregistry_factory, IZRTCommandFactory, 'cssregistry')
+
+Now we can use cssregistry for zrtresource resources
+
+ >>> import tempfile
+ >>> fn = tempfile.mktemp('.css')
+ >>> open(fn, 'w').write('''\
+ ... /* zrt-cssregistry: */
+ ... h1 {
+ ... color: color1;
+ ... font: fontFamilyH1;
+ ... }
+ ...
+ ... h2 {
+ ... color: color2;
+ ... font: fontFamilyH2;
+ ... }''')
+
+ >>> from z3c.zrtresource.zrtresource import ZRTFileResourceFactory
+ >>> cssFactory = ZRTFileResourceFactory(fn, None, 'site.css')
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> css = cssFactory(TestRequest())
+
+ >>> print css.GET()
+ h1 {
+ color: #f5f5f5;
+ font: Verdana;
+ }
+ <BLANKLINE>
+ h2 {
+ color: white;
+ font: Arial;
+ }
+
+Now if we need change css file we only need change cssregistry properties
+
+ >>> registry['color1'].value = 'black'
+
+ >>> print css.GET()
+ h1 {
+ color: black;
+ font: Verdana;
+ }
+ <BLANKLINE>
+ h2 {
+ color: white;
+ font: Arial;
+ }
+
+We also can use named cssregistries
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:browser="http://namespaces.zope.org/browser">
+ ... <browser:cssregistry name="mycss">
+ ... <property name="color1" value="#d5d5d5" />
+ ... <property name="color2" value="black" />
+ ... <property name="fontFamilyH1" value="Tahoma" />
+ ... <property name="fontFamilyH2" value="Courier" />
+ ... </browser:cssregistry>
+ ... </configure>""", context)
+
+ >>> open(fn, 'w').write('''\
+ ... /* zrt-cssregistry: mycss */
+ ... h1 {
+ ... color: color1;
+ ... font: fontFamilyH1;
+ ... }
+ ...
+ ... h2 {
+ ... color: color2;
+ ... font: fontFamilyH2;
+ ... }''')
+
+ >>> print css.GET()
+ h1 {
+ color: #d5d5d5;
+ font: Tahoma;
+ }
+ <BLANKLINE>
+ h2 {
+ color: black;
+ font: Courier;
+ }
+
+If cssregistry is unknown nothing will happen
+
+ >>> open(fn, 'w').write('''\
+ ... /* zrt-cssregistry: unknown */
+ ... h1 {
+ ... color: color1;
+ ... font: fontFamilyH1;
+ ... }''')
+ >>> print css.GET()
+ h1 {
+ color: color1;
+ font: fontFamilyH1;
+ }
+
+
+Registry methods
+----------------
+
+ >>> registry.keys()
+ [u'color1', u'color3', u'color2', u'fontFamilyH2', u'fontFamilyH1']
+
+ >>> list(iter(registry))
+ [u'color1', u'color3', u'color2', u'fontFamilyH2', u'fontFamilyH1']
+
+ >>> for key, prop in registry.items():
+ ... print key, prop
+ color1 <z3ext.cssregistry.property.CSSProperty ...>
+ color3 <z3ext.cssregistry.property.CSSProperty ...>
+ color2 <z3ext.cssregistry.property.CSSProperty ...>
+ fontFamilyH2 <z3ext.cssregistry.property.CSSProperty ...>
+ fontFamilyH1 <z3ext.cssregistry.property.CSSProperty ...>
+
+ >>> len(registry)
+ 5
+
+ >>> u'color1' in registry
+ True
+
+ >>> registry.get(u'color1')
+ <z3ext.cssregistry.property.CSSProperty ...>
+
+ >>> del registry[u'color1']
+ >>> registry.keys()
+ [u'color3', u'color2', u'fontFamilyH2', u'fontFamilyH1']
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/__init__.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/__init__.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/__init__.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1 @@
+# This file is necessary to make this directory a package.
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/command.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/command.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/command.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" z3c.zrtresource zrt-cssregistry command implementation
+
+$Id$
+"""
+import re
+from zope import interface
+from zope.proxy import removeAllProxies
+from zope.component import factory, queryUtility, queryMultiAdapter
+
+from z3c.zrtresource.interfaces import IZRTCommand, IZRTCommandFactory
+
+from interfaces import Layer, ICSSRegistry
+
+
+class CSSRegistryCommand(object):
+ interface.implements(IZRTCommand)
+
+ isAvailable = True
+
+ def __init__(self, args, start, end):
+ self.start = start
+ self.end = end
+ self.name = args.strip()
+
+ def process(self, text, context, request):
+ registry = queryMultiAdapter(
+ (Layer, request), ICSSRegistry, name=self.name)
+
+ if registry is None:
+ registry = queryMultiAdapter(
+ (Layer, Layer, request), ICSSRegistry, name=self.name)
+
+ if registry is None:
+ return text
+
+ for property in removeAllProxies(registry).values():
+ text = property.process(text)
+
+ return text
+
+
+cssregistry_factory = factory.Factory(CSSRegistryCommand, 'cssregistry')
+interface.directlyProvides(cssregistry_factory, IZRTCommandFactory)
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/command.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configlet.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/configlet.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/configlet.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation 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$
+"""
+from BTrees.OOBTree import OOBTree
+from zope import interface, component
+from zope.component import getUtility
+
+from registry import CSSRegistry, registries
+from interfaces import ICSSRegistryConfiglet
+from interfaces import ICSSRegistry, ICSSRegistryLayer
+
+
+class CSSRegistryConfiglet(CSSRegistry):
+ """ css registry configlet """
+ interface.implements(ICSSRegistryConfiglet)
+
+ @property
+ def properties(self):
+ properties = self.data.get('properties')
+ if properties is None:
+ properties = OOBTree()
+ self.data['properties'] = properties
+
+ return properties
+
+
+ at interface.implementer(ICSSRegistry)
+ at component.adapter(ICSSRegistryLayer, interface.Interface)
+def portalCssRegistry(layer, request):
+ css = getUtility(ICSSRegistryConfiglet)
+ if css.enabled:
+ return css
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configlet.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.pt
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.pt (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.pt 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,114 @@
+<form method="post" action="@@index.html" class="z-form" i18n:domain="z3ext">
+ <div class="topframe" tal:define="props context/keys">
+ <h1 tal:content="context/__title__">Portal CSS properties</h1>
+ <div class="pageDescription" tal:content="context/__description__"></div>
+
+ <div class="z-field">
+ <label i18n:translate="">Status</label>
+ <div>
+ <select name="form.enabled">
+ <option value="yes"
+ tal:attributes="selected context/enabled" i18n:translate="">
+ Enabled
+ </option>
+ <option value="no"
+ tal:attributes="selected not:context/enabled" i18n:translate="">
+ Disabled
+ </option>
+ </select>
+ </div>
+ </div>
+ <br />
+
+ <tal:block tal:condition="props">
+ <h2 i18n:translate="">Properties</h2>
+
+ <table class="listing">
+ <tr>
+ <th> </th>
+ <th i18n:translate="">Property</th>
+ <th i18n:translate="">Value</th>
+ </tr>
+ <tr tal:repeat="prop props"
+ tal:attributes="class python:repeat['prop'].even() and 'even' or 'odd'">
+ <td><input type="checkbox" name="property:list"
+ tal:attributes="value prop" /></td>
+ <td tal:content="prop"></td>
+ <td><input type="text"
+ tal:attributes="name string:prop-$prop;
+ value python:context[prop].value" /></td>
+ </tr>
+ </table>
+ <div class="z-form-controls">
+ <input type="submit" class="z-form-button"
+ name="form.save" value="Save" i18n:attributes="value" />
+ <input type="submit" class="z-form-removebutton"
+ name="form.remove" value="Remove" i18n:attributes="value" />
+ </div>
+ </tal:block>
+
+ <tal:block tal:condition="not:props" i18n:translate="">
+ There are no any defined properties.
+ </tal:block>
+
+ <tal:block condition="nothing">
+ <br /><br />
+ <hr />
+ <h3 i18n:translate="">Add property</h3>
+ <div class="z-field">
+ </div>
+ <div>
+ </div>
+ <div class="z-form-controls">
+ <input type="submit" class="z-form-addbutton"
+ name="form.add" value="Add" i18n:attributes="value" />
+ </div>
+ </tal:block>
+ </div>
+
+ <div class="frame">
+ <h2 i18n:translate="">Add property</h2>
+
+ <div class="z-field">
+ <label i18n:translate="">Property name</label>
+
+ <div>
+ <input type="text" name="form.add.name" />
+ </div>
+ </div>
+
+ <div class="z-field">
+ <label i18n:translate="">Value</label>
+
+ <div>
+ <input type="text" name="form.add.value" />
+ </div>
+ </div>
+
+ <div class="z-form-controls">
+ <input type="submit" class="z-form-addbutton"
+ name="form.add" value="Add" i18n:attributes="value" />
+ </div>
+ </div>
+
+ <div class="frame" tal:define="regs view/listRegistries" tal:condition="regs">
+ <h2 i18n:translate="">Copy/Update properties from existent registries</h2>
+ <div> </div>
+
+ <div class="z-field">
+ <label i18n:translate="">Registry</label>
+ <div></div>
+ <select name="registry:int">
+ <option tal:repeat="reg regs"
+ tal:attributes="value python:repeat['reg'].index()"
+ tal:content="string:${reg/name} (${reg/layer})"></option>
+ </select>
+ </div>
+ <div class="z-form-controls">
+ <input type="submit" class="z-form-button" name="form.copy"
+ value="Copy" i18n:attributes="value" />
+ <input type="submit" class="z-form-standalonebtn" name="form.update"
+ value="Update" i18n:attributes="value" />
+ </div>
+ </div>
+</form>
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,86 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" `browser:cssregistry` directive
+
+$Id$
+"""
+from zope import interface
+from z3ext.layout.pagelet import BrowserPagelet
+from z3ext.portalmessage.interfaces import IMessageService
+
+from z3ext.cssregistry.i18n import _
+from z3ext.cssregistry.registry import registries
+from z3ext.cssregistry.property import CSSProperty
+from z3ext.cssregistry.interfaces import ICSSRegistry
+
+
+class ViewRegistry(BrowserPagelet):
+
+ def listRegistries(self):
+ regs = []
+ for key, registry in registries.items():
+ name, layer = key
+
+ regs.append({'name': name or 'Without name',
+ 'layer': '%s.%s'%(layer.__module__, layer.__name__),
+ 'registry': registry})
+
+ return regs
+
+ def update(self):
+ request = self.request
+
+ if 'form.copy' in request:
+ reg = request.get('registry', None)
+
+ try:
+ registry = self.listRegistries()[int(reg)]['registry']
+
+ for prop, value in registry.items():
+ self.context[prop] = value
+
+ IMessageService(request).add(
+ _(u"CSS Registry has been copied."))
+ except:
+ pass
+
+ if 'form.add' in request:
+ name = request.get('form.add.name', '').strip()
+ if not name:
+ IMessageService(request).add(
+ _(u"Can't add property with emtpy name."), 'error')
+ else:
+ self.context[name] = CSSProperty(
+ name, request.get('form.add.value', ''))
+
+ if 'form.remove' in request:
+ for prop in request.get('property', ()):
+ del self.context[prop]
+ IMessageService(request).add(_(u"Properties have been removed."))
+
+ if 'form.save' in request:
+
+ for key, value in request.form.items():
+ if key.startswith('prop-'):
+ key = key[5:]
+ self.context[key].value = value
+
+ if request.get('form.enabled') == 'yes':
+ self.context.enabled = True
+ else:
+ self.context.enabled = False
+
+ IMessageService(request).add(_(u"Properties have been changed."))
+
+ return self.index()
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configletview.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/configure.zcml
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/configure.zcml (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/configure.zcml 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,62 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="z3ext">
+
+ <utility
+ name="cssregistry"
+ provides="z3c.zrtresource.interfaces.IZRTCommandFactory"
+ component=".command.cssregistry_factory" />
+
+ <class class=".registry.CSSRegistry">
+ <require
+ permission="zope.Public"
+ attributes="name title"
+ interface="zope.interface.common.mapping.IEnumerableMapping" />
+ </class>
+
+ <class class=".property.CSSProperty">
+ <require
+ permission="zope.Public"
+ interface=".interfaces.ICSSProperty" />
+
+ <require
+ permission="zope.Public"
+ set_schema=".interfaces.ICSSProperty" />
+ </class>
+
+ <zcml:configure
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ zcml:condition="installed z3ext.controlpanel">
+
+ <z3ext:configlet
+ name="ui.cssregistry"
+ title="CSS Properties"
+ description="CSS properties registry configuration."
+ schema=".interfaces.ICSSRegistryConfiglet"
+ class=".configlet.CSSRegistryConfiglet" />
+
+ <adapter factory=".configlet.portalCssRegistry" />
+
+ <class class=".configlet.CSSRegistryConfiglet">
+ <require
+ permission="zope.Public"
+ attributes="name title"
+ interface="zope.interface.common.mapping.IEnumerableMapping" />
+ <require
+ permission="z3ext.Configure"
+ interface="zope.interface.common.mapping.IWriteMapping" />
+ </class>
+
+ <browser:page
+ name="index.html"
+ for=".interfaces.ICSSRegistryConfiglet"
+ template="configletview.pt"
+ class=".configletview.ViewRegistry"
+ permission="z3ext.Configure" />
+
+ </zcml:configure>
+
+</configure>
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/i18n.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/i18n.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/i18n.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" i18n
+
+$Id$
+"""
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('z3ext')
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/i18n.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/interfaces.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/interfaces.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/interfaces.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,83 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" z3ext.cssregistry interfaces
+
+$Id$
+"""
+from zope import schema, interface
+from zope.interface.common.mapping import IMapping
+
+from z3ext.cssregistry.i18n import _
+
+
+class ICSSRegistry(IMapping):
+
+ properties = interface.Attribute('css properties')
+
+ name = schema.TextLine(
+ title = _(u'Name'),
+ description = _(u'CSS Registry name'),
+ default = u'',
+ required = False)
+
+ title = schema.TextLine(
+ title = _(u'Title'),
+ description = _(u'CSS Registry title'),
+ default = u'',
+ required = False)
+
+
+class ICSSProperty(interface.Interface):
+
+ name = schema.TextLine(
+ title = _(u'Name'),
+ description = _(u'Property name'),
+ required = True)
+
+ description = schema.TextLine(
+ title = _(u'Description'),
+ description = _(u'Property description'),
+ required = False)
+
+ value = schema.TextLine(
+ title = _(u'Value'),
+ description = _(u'Property value'),
+ required = True)
+
+ type = schema.TextLine(
+ title = _(u'Type'),
+ description = _(u'Property type. (color, font, size)'),
+ required = False)
+
+ def process(text):
+ """ replace property in text """
+
+
+class ICSSRegistryLayer(interface.Interface):
+ """ marker interface """
+
+
+class Layer(object):
+ interface.implements(ICSSRegistryLayer)
+
+Layer = Layer()
+
+
+class ICSSRegistryConfiglet(ICSSRegistry):
+ """ css registry configlet """
+
+ enabled = schema.Bool(
+ title = _(u'Enabled'),
+ default = False,
+ required = True)
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/meta.zcml
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/meta.zcml (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/meta.zcml 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,23 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta">
+
+ <meta:directives namespace="http://namespaces.zope.org/browser">
+ <meta:complexDirective
+ name="cssregistry"
+ schema=".zcml.ICSSRegistryDirective"
+ handler=".zcml.cssregistryHandler">
+
+ <meta:subdirective
+ name="property"
+ schema=".zcml.ICSSPropertySubDirective" />
+
+ </meta:complexDirective>
+
+ <meta:directive
+ name="cssproperty"
+ schema=".zcml.ICSSPropertyDirective"
+ handler=".zcml.csspropertyHandler" />
+ </meta:directives>
+
+</configure>
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/property.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/property.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/property.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" ICSSProperty implementation
+
+$Id$
+"""
+import re
+from zope import interface
+from persistent import Persistent
+
+from interfaces import ICSSProperty
+
+
+class CSSProperty(Persistent):
+ interface.implements(ICSSProperty)
+
+ def __init__(self, name, value, description='', type=''):
+ self.name = name
+ self.value = value
+ self.description = description
+ self.type = type
+
+ def process(self, text):
+ regex = re.compile(re.escape(self.name))
+ return regex.subn(self.value, text)[0]
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/property.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/registry.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/registry.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/registry.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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$
+"""
+from zope import interface
+from persistent import Persistent
+from interfaces import ICSSRegistry
+
+registries = {}
+
+
+class CSSRegistry(Persistent):
+ interface.implements(ICSSRegistry)
+
+ @property
+ def properties(self):
+ try:
+ return self._properties
+ except AttributeError:
+ self._properties = {}
+ return self._properties
+
+ def keys(self):
+ return self.properties.keys()
+
+ def __iter__(self):
+ return iter(self.properties)
+
+ def values(self):
+ return self.properties.values()
+
+ def items(self):
+ return self.properties.items()
+
+ def __len__(self):
+ return len(self.properties)
+
+ def __setitem__(self, key, value):
+ self.properties[key] = value
+
+ def __getitem__(self, key):
+ return self.properties[key]
+
+ def __delitem__(self, key):
+ del self.properties[key]
+
+ def get(self, key, default=None):
+ return self.properties.get(key, default)
+
+ def __contains__(self, key):
+ return key in self.properties
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/registry.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/tests.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/tests.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/tests.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" z3ext.cssregistry tests
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest, doctest
+from zope import interface, schema
+from zope.component import provideAdapter
+from zope.app.testing import setup
+from zope.traversing.namespace import view
+from zope.traversing.interfaces import ITraversable
+
+
+def setUp(test):
+ setup.placelessSetUp()
+ setup.setUpTraversal()
+ provideAdapter(view, (None, None), ITraversable, name="view")
+
+
+def tearDown(test):
+ setup.placelessTearDown()
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ ))
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3ext.cssregistry/trunk/src/z3ext/cssregistry/zcml.py
===================================================================
--- z3ext.cssregistry/trunk/src/z3ext/cssregistry/zcml.py (rev 0)
+++ z3ext.cssregistry/trunk/src/z3ext/cssregistry/zcml.py 2008-03-21 06:44:44 UTC (rev 84821)
@@ -0,0 +1,136 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" `browser:cssregistry` directive
+
+$Id$
+"""
+
+from zope import schema, interface
+from zope.component.zcml import handler
+from zope.configuration.fields import GlobalObject
+
+from i18n import _
+from property import CSSProperty
+from registry import CSSRegistry, registries
+
+from interfaces import ICSSRegistry, ICSSRegistryLayer
+
+
+class ICSSRegistryDirective(interface.Interface):
+
+ name = schema.TextLine(
+ title = _(u'Name'),
+ description = _(u'Registry name'),
+ required = False)
+
+ title = schema.TextLine(
+ title = _(u'Title'),
+ required = False)
+
+ layer = GlobalObject(
+ title=_(u"The layer the css registry should be found in"),
+ required=False)
+
+
+class ICSSPropertySubDirective(interface.Interface):
+
+ name = schema.TextLine(
+ title = _(u'Name'),
+ description = _(u'Property name'),
+ required = True)
+
+ value = schema.TextLine(
+ title = _(u'Value'),
+ description = _(u'Property value'),
+ required = True)
+
+ description = schema.TextLine(
+ title = _(u'Description'),
+ description = _(u'Property description'),
+ required = False)
+
+ type = schema.TextLine(
+ title = _(u'Type'),
+ description = _(u'Property type. (color, font, size)'),
+ required = False)
+
+
+class ICSSPropertyDirective(interface.Interface):
+
+ registry = schema.TextLine(
+ title = _(u'Registry'),
+ required = False)
+
+ layer = GlobalObject(
+ title = _(u"The layer the css registry should be found in"),
+ required=False)
+
+ name = schema.TextLine(
+ title = _(u'Name'),
+ required = True)
+
+ value = schema.TextLine(
+ title = _(u'Value'),
+ required = True)
+
+ description = schema.TextLine(
+ title = _(u'Description'),
+ description = _(u'Property description'),
+ required = False)
+
+ type = schema.TextLine(
+ title = _(u'Type'),
+ description = _(u'Property type. (color, font, size)'),
+ required = False)
+
+
+class Factory(object):
+
+ def __init__(self, registry):
+ self.registry = registry
+
+ def __call__(self, layer1, layer2, request):
+ return self.registry
+
+
+class cssregistryHandler(object):
+
+ def __init__(self, _context, name='', title='', layer=interface.Interface):
+ self.name = name
+ self.layer = layer
+
+ self.registry = CSSRegistry()
+ self.registry.name = name
+ self.registry.title = title
+
+ registries[(name, layer)] = self.registry
+
+ # we can't use just 'layer', because registry will be registered as resource
+ _context.action(
+ discriminator = ('CSSRegistry', name, layer),
+ callable = handler,
+ args = ('registerAdapter',
+ Factory(self.registry),
+ (ICSSRegistryLayer, ICSSRegistryLayer, layer),
+ ICSSRegistry, name, _context.info),
+ )
+
+ def property(self, _context, name, value, description='', type=''):
+ self.registry[name] = CSSProperty(name, value, description, type)
+
+
+def csspropertyHandler(_context, name, value, registry='',
+ layer=interface.Interface, description='', type=''):
+ registry = registries[(registry, layer)]
+ registry[name] = CSSProperty(name, value, description, type)
Property changes on: z3ext.cssregistry/trunk/src/z3ext/cssregistry/zcml.py
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the Checkins
mailing list