[Checkins] SVN: z3c.zrtresource/tags/1.3.0/ Tag 1.3.0

Dan Korostelev nadako at gmail.com
Thu Aug 27 12:21:04 EDT 2009


Log message for revision 103303:
  Tag 1.3.0

Changed:
  A   z3c.zrtresource/tags/1.3.0/
  D   z3c.zrtresource/tags/1.3.0/CHANGES.txt
  A   z3c.zrtresource/tags/1.3.0/CHANGES.txt
  D   z3c.zrtresource/tags/1.3.0/setup.py
  A   z3c.zrtresource/tags/1.3.0/setup.py
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/SETUP.cfg
  A   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/configure.zcml
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py
  A   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/z3c.zrtresource-meta.zcml
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py
  A   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt
  A   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt
  D   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py
  A   z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py

-=-
Deleted: z3c.zrtresource/tags/1.3.0/CHANGES.txt
===================================================================
--- z3c.zrtresource/trunk/CHANGES.txt	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/CHANGES.txt	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,35 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.1 (unreleased)
-------------------
-
-- Nothing changed yet.
-
-
-1.2.0 (2009-06-25)
-------------------
-
-- Got rid of dependency on ``zope.app.component`` and
-  ``zope.app.pagetemplate``.
-
-- Fixed home page and author email address.
-
-
-1.1.0 (2007-12-01)
-------------------
-
-- Fix bug with spaces in replace expression
-
-- Added custom ZRT commands
-
-1.0.1 (2007-10-30)
-------------------
-
-- Fix long description of package to be valid restructured text.
-
-1.0.0 (2007-10-30)
-------------------
-
-- Initial release.

Copied: z3c.zrtresource/tags/1.3.0/CHANGES.txt (from rev 103302, z3c.zrtresource/trunk/CHANGES.txt)
===================================================================
--- z3c.zrtresource/tags/1.3.0/CHANGES.txt	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/CHANGES.txt	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,45 @@
+=======
+CHANGES
+=======
+
+1.3.0 (2009-08-27)
+------------------
+
+- Use new ``zope.browserresource`` package instead of ``zope.app.publisher``,
+  as the resources mechanism was moved there to reduce dependencies.
+
+- Register ZRTFileResourceFactory as a resource factory with name "zrt" in
+  package's configure.zcml. This makes ZRT resources created automatically
+  when using ``browser:resource`` directive for files with "zrt" extensions.
+  It will also make *.zrt files inside resourse directories a ZRTFileResource.
+
+- Get rid of ``zope.app.testing`` test dependency.
+
+- Remove unused SETUP.CFG and z3c.zrtresource-meta.zcml files.
+
+
+1.2.0 (2009-06-25)
+------------------
+
+- Got rid of dependency on ``zope.app.component`` and
+  ``zope.app.pagetemplate``.
+
+- Fixed home page and author email address.
+
+
+1.1.0 (2007-12-01)
+------------------
+
+- Fix bug with spaces in replace expression
+
+- Added custom ZRT commands
+
+1.0.1 (2007-10-30)
+------------------
+
+- Fix long description of package to be valid restructured text.
+
+1.0.0 (2007-10-30)
+------------------
+
+- Initial release.

Deleted: z3c.zrtresource/tags/1.3.0/setup.py
===================================================================
--- z3c.zrtresource/trunk/setup.py	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/setup.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,74 +0,0 @@
-##############################################################################
-#
-# 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 z3c.zrtresource 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.1dev'
-
-
-setup(name='z3c.zrtresource',
-      version=version,
-      author='Zope Corporation and Contributors',
-      author_email='zope-dev at zope.org',
-      description='Zope Resource Templates',
-      long_description=(
-          read('README.txt')
-          + '\n\n.. contents::\n\n' +
-          read('src', 'z3c', 'zrtresource', 'README.txt')
-          + '\n\n' +
-          read('src', 'z3c', 'zrtresource', 'zcml.txt')
-          + '\n\n' +
-          read('CHANGES.txt')
-          ),
-      keywords = "zope3 css javascript resource zope",
-      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'],
-      url='http://pypi.python.org/pypi/z3c.zrtresource',
-      license='ZPL 2.1',
-      packages=find_packages('src'),
-      package_dir = {'': 'src'},
-      namespace_packages=['z3c'],
-      extras_require = dict(test=['zope.app.testing',
-                                  'zope.testing',
-                                  'zope.traversing',
-                                  ]),
-      install_requires = ['setuptools',
-                          'zope.site',
-                          'zope.pagetemplate >= 3.5.0',
-                          'zope.app.publisher',
-                          'zope.component',
-                          'zope.configuration',
-                          'zope.interface',
-                          'zope.publisher',
-                          'zope.schema',
-                          'zope.security [untrustedpython]',
-                          ],
-      include_package_data = True,
-      zip_safe = False,
-      )

Copied: z3c.zrtresource/tags/1.3.0/setup.py (from rev 103300, z3c.zrtresource/trunk/setup.py)
===================================================================
--- z3c.zrtresource/tags/1.3.0/setup.py	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/setup.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,73 @@
+##############################################################################
+#
+# 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 z3c.zrtresource 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.3.0'
+
+
+setup(name='z3c.zrtresource',
+      version=version,
+      author='Zope Corporation and Contributors',
+      author_email='zope-dev at zope.org',
+      description='Zope Resource Templates',
+      long_description=(
+          read('README.txt')
+          + '\n\n.. contents::\n\n' +
+          read('src', 'z3c', 'zrtresource', 'README.txt')
+          + '\n\n' +
+          read('src', 'z3c', 'zrtresource', 'zcml.txt')
+          + '\n\n' +
+          read('CHANGES.txt')
+          ),
+      keywords = "zope3 css javascript resource zope",
+      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'],
+      url='http://pypi.python.org/pypi/z3c.zrtresource',
+      license='ZPL 2.1',
+      packages=find_packages('src'),
+      package_dir = {'': 'src'},
+      namespace_packages=['z3c'],
+      extras_require = dict(test=['zope.testing',
+                                  'zope.traversing',
+                                  ]),
+      install_requires = ['setuptools',
+                          'zope.site',
+                          'zope.pagetemplate >= 3.5',
+                          'zope.browserresource',
+                          'zope.component',
+                          'zope.configuration',
+                          'zope.interface',
+                          'zope.publisher',
+                          'zope.schema',
+                          'zope.security [untrustedpython]',
+                          ],
+      include_package_data = True,
+      zip_safe = False,
+      )

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/SETUP.cfg
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/SETUP.cfg	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/SETUP.cfg	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,3 +0,0 @@
-<data-files zopeskel/etc/package-includes>
-  z3c.zrtresource-*.zcml
-</data-files>

Copied: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/configure.zcml (from rev 103302, z3c.zrtresource/trunk/src/z3c/zrtresource/configure.zcml)
===================================================================
--- z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/configure.zcml	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/configure.zcml	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,9 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <utility
+      name="zrt"
+      component=".zrtresource.ZRTFileResourceFactory"
+      provides="zope.browserresource.interfaces.IResourceFactoryFactory"
+      />
+
+</configure>

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/tests.py	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 Lovely Systems 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.
-#
-##############################################################################
-"""Tag test setup
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import doctest
-import unittest
-import zope.component
-from zope.app.testing import placelesssetup
-from zope.testing.doctestunit import DocFileSuite
-from zope.traversing import testing
-from zope.traversing.interfaces import ITraversable
-from zope.traversing.namespace import view
-
-
-def setUp(test):
-    placelesssetup.setUp(test)
-    testing.setUp()
-    zope.component.provideAdapter(view, (None, None), ITraversable, name="view")
-
-
-def test_suite():
-
-    return unittest.TestSuite((
-        DocFileSuite('README.txt',
-                     setUp=setUp,
-                     tearDown=placelesssetup.tearDown,
-                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
-                     ),
-        DocFileSuite('zcml.txt',
-                     setUp=placelesssetup.setUp,
-                     tearDown=placelesssetup.tearDown,
-                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
-                     ),
-        ))
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

Copied: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py (from rev 103300, z3c.zrtresource/trunk/src/z3c/zrtresource/tests.py)
===================================================================
--- z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/tests.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2006 Lovely Systems 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.
+#
+##############################################################################
+"""Tag test setup
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import doctest
+import unittest
+import zope.component
+from zope.testing import cleanup, doctest
+from zope.traversing import testing
+from zope.traversing.interfaces import ITraversable
+from zope.traversing.namespace import view
+
+
+def setUp(test):
+    cleanup.setUp()
+    testing.setUp()
+    zope.component.provideAdapter(view, (None, None), ITraversable, name="view")
+
+def tearDown(test):
+    cleanup.tearDown()
+
+
+def test_suite():
+
+    return unittest.TestSuite((
+        doctest.DocFileSuite('README.txt',
+                     setUp=setUp,
+                     tearDown=tearDown,
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        doctest.DocFileSuite('zcml.txt',
+                     setUp=lambda test:cleanup.setUp(),
+                     tearDown=tearDown,
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        ))

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/z3c.zrtresource-meta.zcml
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/z3c.zrtresource-meta.zcml	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/z3c.zrtresource-meta.zcml	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1 +0,0 @@
-<include package="z3c.zrtresource" file="meta.zcml" />

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/zcml.py	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,66 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation 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.
-#
-##############################################################################
-"""Meta Configure
-
-$Id$
-"""
-import zope.schema
-import zope.configuration.fields
-from zope.component.zcml import handler
-from zope.interface import Interface
-from zope.publisher.interfaces import browser
-from zope.security.checker import CheckerPublic, NamesChecker
-from zope.app.publisher.browser import metadirectives, resourcemeta
-
-import z3c.zrtresource
-
-
-class IZRTResourceDirective(metadirectives.IBasicResourceInformation):
-    """Defines a browser ZRT resource"""
-
-    name = zope.schema.TextLine(
-        title=u"The name of the resource",
-        description=u"""
-        This is the name used in resource urls. Resource urls are of
-        the form site/@@/resourcename, where site is the url of
-        "site", a folder with a site manager.
-
-        We make resource urls site-relative (as opposed to
-        content-relative) so as not to defeat caches.""",
-        required=True
-        )
-
-    file = zope.configuration.fields.Path(
-        title=u"File",
-        description=u"The file containing the resource data.",
-        required=True
-        )
-
-
-def zrtresource(_context, name, file, layer=browser.IDefaultBrowserLayer,
-                permission='zope.Public'):
-
-    if permission == 'zope.Public':
-        permission = CheckerPublic
-
-    checker = NamesChecker(resourcemeta.allowed_names, permission)
-
-    factory = z3c.zrtresource.ZRTFileResourceFactory(file, checker, name)
-
-    _context.action(
-        discriminator = ('resource', name, browser.IBrowserRequest, layer),
-        callable = handler,
-        args = ('registerAdapter',
-                factory, (layer,), Interface, name, _context.info),
-        )

Copied: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py (from rev 103300, z3c.zrtresource/trunk/src/z3c/zrtresource/zcml.py)
===================================================================
--- z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Foundation 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.
+#
+##############################################################################
+"""Meta Configure
+
+$Id$
+"""
+import zope.schema
+import zope.configuration.fields
+from zope.component.zcml import handler
+from zope.interface import Interface
+from zope.publisher.interfaces import browser
+from zope.security.checker import CheckerPublic, NamesChecker
+from zope.browserresource import metadirectives
+from zope.browserresource import metaconfigure as resourcemeta
+
+import z3c.zrtresource
+
+
+class IZRTResourceDirective(metadirectives.IBasicResourceInformation):
+    """Defines a browser ZRT resource"""
+
+    name = zope.schema.TextLine(
+        title=u"The name of the resource",
+        description=u"""
+        This is the name used in resource urls. Resource urls are of
+        the form site/@@/resourcename, where site is the url of
+        "site", a folder with a site manager.
+
+        We make resource urls site-relative (as opposed to
+        content-relative) so as not to defeat caches.""",
+        required=True
+        )
+
+    file = zope.configuration.fields.Path(
+        title=u"File",
+        description=u"The file containing the resource data.",
+        required=True
+        )
+
+
+def zrtresource(_context, name, file, layer=browser.IDefaultBrowserLayer,
+                permission='zope.Public'):
+
+    if permission == 'zope.Public':
+        permission = CheckerPublic
+
+    checker = NamesChecker(resourcemeta.allowed_names, permission)
+
+    factory = z3c.zrtresource.ZRTFileResourceFactory(file, checker, name)
+
+    _context.action(
+        discriminator = ('resource', name, browser.IBrowserRequest, layer),
+        callable = handler,
+        args = ('registerAdapter',
+                factory, (layer,), Interface, name, _context.info),
+        )

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/zcml.txt	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,49 +0,0 @@
-==========================
-``zrt-resource`` Directive
-==========================
-
-This package provides a new directive to use the special resource
-directive. Let's register it first:
-
-  >>> from zope.configuration import xmlconfig
-  >>> context = xmlconfig.string('''
-  ... <configure i18n_domain="zope">
-  ...   <include package="z3c.zrtresource" file="meta.zcml" />
-  ... </configure>
-  ... ''')
-
-Now we can register a resource:
-
-  >>> import tempfile
-  >>> fn = tempfile.mktemp('.css')
-  >>> open(fn, 'w').write('''\
-  ... /* zrt-replace: "../img1" "++resource++/img" */
-  ... h1 {
-  ...   color: red;
-  ...   background: url('../img1/mybackground.gif');
-  ... }
-  ... ''')
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns="http://namespaces.zope.org/browser" i18n_domain="zope">
-  ...   <zrt-resource
-  ...       name="test.css"
-  ...       file="%s" />
-  ... </configure>
-  ... ''' %fn, context=context)
-
-Now let's see whether the adapter has been registered:
-
-  >>> import zope.component
-  >>> import zope.interface
-  >>> from zope.publisher.browser import TestRequest
-  >>> resource = zope.component.getAdapter(
-  ...     TestRequest(), zope.interface.Interface, name='test.css')
-
-Now run it:
-
-  >>> print resource.GET()
-  h1 {
-    color: red;
-    background: url('++resource++/img/mybackground.gif');
-  }

Copied: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt (from rev 103302, z3c.zrtresource/trunk/src/z3c/zrtresource/zcml.txt)
===================================================================
--- z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zcml.txt	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,100 @@
+==========================
+``zrt-resource`` Directive
+==========================
+
+This package provides a new directive to use the special resource
+directive. Let's register it first:
+
+  >>> from zope.configuration import xmlconfig
+  >>> context = xmlconfig.string('''
+  ... <configure i18n_domain="zope">
+  ...   <include package="z3c.zrtresource" file="meta.zcml" />
+  ... </configure>
+  ... ''')
+
+Now we can register a resource:
+
+  >>> import tempfile
+  >>> fn = tempfile.mktemp('.css')
+  >>> open(fn, 'w').write('''\
+  ... /* zrt-replace: "../img1" "++resource++/img" */
+  ... h1 {
+  ...   color: red;
+  ...   background: url('../img1/mybackground.gif');
+  ... }
+  ... ''')
+
+  >>> context = xmlconfig.string('''
+  ... <configure xmlns="http://namespaces.zope.org/browser" i18n_domain="zope">
+  ...   <zrt-resource
+  ...       name="test.css"
+  ...       file="%s" />
+  ... </configure>
+  ... ''' %fn, context=context)
+
+Now let's see whether the adapter has been registered:
+
+  >>> import zope.component
+  >>> import zope.interface
+  >>> from zope.publisher.browser import TestRequest
+  >>> resource = zope.component.getAdapter(
+  ...     TestRequest(), zope.interface.Interface, name='test.css')
+
+Now run it:
+
+  >>> print resource.GET()
+  h1 {
+    color: red;
+    background: url('++resource++/img/mybackground.gif');
+  }
+
+We can also register a ZRT resource using standard ``browser:resource`` directive.
+The ``configure.zcml`` file in this package registers a ZRT resource factory for
+files with "zrt" extension, so any file with "zrt" extension will be a ZRT
+resource.
+
+First, let's include the ``browser:resource`` directive and the resource factory
+registration:
+
+  >>> context = xmlconfig.string('''
+  ... <configure i18n_domain="zope">
+  ...   <include package="zope.browserresource" file="meta.zcml" />
+  ...   <include package="zope.component" file="meta.zcml" />
+  ...   <include package="z3c.zrtresource" />
+  ... </configure>
+  ... ''')
+
+Now we need to create a file with "zrt" extension:
+
+  >>> fn = tempfile.mktemp('.zrt')
+  >>> open(fn, 'w').write('''\
+  ... /* zrt-replace: "../img1" "++resource++/img" */
+  ... h1 {
+  ...   color: red;
+  ...   background: url('../img1/mybackground.gif');
+  ... }
+  ... ''')
+
+And register it as a resource using browser:resource directive.
+
+  >>> context = xmlconfig.string('''
+  ... <configure xmlns="http://namespaces.zope.org/browser" i18n_domain="zope">
+  ...   <resource
+  ...       name="test2.css"
+  ...       file="%s" />
+  ... </configure>
+  ... ''' %fn, context=context)
+
+Let's see whether the adapter has been registered:
+
+  >>> resource2 = zope.component.getAdapter(
+  ...     TestRequest(), zope.interface.Interface, name='test2.css')
+
+Now, let's render it and check if ZRT mechanism works for it.
+
+  >>> print resource2.GET()
+  h1 {
+    color: red;
+    background: url('++resource++/img/mybackground.gif');
+  }
+  
\ No newline at end of file

Deleted: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py
===================================================================
--- z3c.zrtresource/trunk/src/z3c/zrtresource/zrtresource.py	2009-08-27 15:52:10 UTC (rev 103299)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -1,46 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation 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.
-#
-##############################################################################
-"""CSS Resource
-
-$Id$
-"""
-__docformat__='restructuredtext'
-from zope.site.hooks import getSite
-from zope.app.publisher.fileresource import File
-from zope.app.publisher.browser.fileresource import FileResource
-
-from z3c.zrtresource import processor, replace
-
-
-class ZRTFileResource(FileResource):
-
-    def GET(self):
-        data = super(ZRTFileResource, self).GET()
-        # Process the file
-        p = processor.ZRTProcessor(data, commands={'replace': replace.Replace})
-        return p.process(getSite(), self.request)
-
-
-class ZRTFileResourceFactory(object):
-
-    def __init__(self, path, checker, name):
-        self.__file = File(path, name)
-        self.__checker = checker
-        self.__name = name
-
-    def __call__(self, request):
-        resource = ZRTFileResource(self.__file, request)
-        resource.__Security_checker__ = self.__checker
-        resource.__name__ = self.__name
-        return resource

Copied: z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py (from rev 103300, z3c.zrtresource/trunk/src/z3c/zrtresource/zrtresource.py)
===================================================================
--- z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py	                        (rev 0)
+++ z3c.zrtresource/tags/1.3.0/src/z3c/zrtresource/zrtresource.py	2009-08-27 16:21:04 UTC (rev 103303)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Foundation 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.
+#
+##############################################################################
+"""CSS Resource
+
+$Id$
+"""
+__docformat__='restructuredtext'
+from zope.browserresource.file import File, FileResource
+from zope.browserresource.interfaces import IResourceFactory
+from zope.browserresource.interfaces import IResourceFactoryFactory
+from zope.interface import implements, classProvides
+from zope.site.hooks import getSite
+
+from z3c.zrtresource import processor, replace
+
+
+class ZRTFileResource(FileResource):
+
+    def GET(self):
+        data = super(ZRTFileResource, self).GET()
+        # Process the file
+        p = processor.ZRTProcessor(data, commands={'replace': replace.Replace})
+        return p.process(getSite(), self.request)
+
+
+class ZRTFileResourceFactory(object):
+    
+    implements(IResourceFactory)
+    classProvides(IResourceFactoryFactory)
+
+    def __init__(self, path, checker, name):
+        self.__file = File(path, name)
+        self.__checker = checker
+        self.__name = name
+
+    def __call__(self, request):
+        resource = ZRTFileResource(self.__file, request)
+        resource.__Security_checker__ = self.__checker
+        resource.__name__ = self.__name
+        return resource



More information about the Checkins mailing list