[Checkins] SVN: z3ext.resource/trunk/ deprecated

Nikolay Kim fafhrd91 at gmail.com
Tue Dec 22 18:57:34 EST 2009


Log message for revision 106983:
  deprecated

Changed:
  U   z3ext.resource/trunk/CHANGES.txt
  D   z3ext.resource/trunk/bootstrap.py
  D   z3ext.resource/trunk/buildout.cfg
  U   z3ext.resource/trunk/setup.py
  D   z3ext.resource/trunk/src/z3ext/resource/README.txt
  U   z3ext.resource/trunk/src/z3ext/resource/configure.zcml
  D   z3ext.resource/trunk/src/z3ext/resource/fileresource.py
  D   z3ext.resource/trunk/src/z3ext/resource/interfaces.py
  U   z3ext.resource/trunk/src/z3ext/resource/meta.zcml
  D   z3ext.resource/trunk/src/z3ext/resource/resource.py
  D   z3ext.resource/trunk/src/z3ext/resource/tests.py
  D   z3ext.resource/trunk/src/z3ext/resource/zcml.py
  D   z3ext.resource/trunk/src/z3ext/resource/zrtresource/

-=-
Modified: z3ext.resource/trunk/CHANGES.txt
===================================================================
--- z3ext.resource/trunk/CHANGES.txt	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/CHANGES.txt	2009-12-22 23:57:34 UTC (rev 106983)
@@ -2,10 +2,12 @@
 CHANGES
 =======
 
-1.3.1 (Unreleased)
+1.4.0 (Unreleased)
 ------------------
 
+- Deprecated
 
+
 1.3.0 (2009-08-28)
 ------------------
 

Deleted: z3ext.resource/trunk/bootstrap.py
===================================================================
--- z3ext.resource/trunk/bootstrap.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/bootstrap.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""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)

Deleted: z3ext.resource/trunk/buildout.cfg
===================================================================
--- z3ext.resource/trunk/buildout.cfg	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/buildout.cfg	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,18 +0,0 @@
-[buildout]
-develop = .
-parts = test coverage-test coverage-report
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.resource [test]
-
-[coverage-test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.resource [test]
-defaults = ['--coverage', '../../coverage']
-
-[coverage-report]
-recipe = zc.recipe.egg
-eggs = z3c.coverage
-scripts = coverage=coverage-report
-arguments = ('coverage', 'coverage/report')

Modified: z3ext.resource/trunk/setup.py
===================================================================
--- z3ext.resource/trunk/setup.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/setup.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -21,7 +21,7 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-version = '1.3.1dev'
+version = '0'
 
 
 setup(name='z3ext.resource',
@@ -47,28 +47,14 @@
         'Framework :: Zope3'],
       author='Nikolay Kim',
       author_email='fafhrd91 at gmail.com',
-      url='http://z3ext.net/',
+      url='http://pypi.python.org/pypi/z3ext.resource/',
       license='ZPL 2.1',
       packages=find_packages('src'),
       package_dir = {'':'src'},
       namespace_packages=['z3ext'],
       install_requires = ['setuptools',
-                          'zope.schema',
-                          'zope.component',
-                          'zope.interface',
-                          'zope.configuration',
-                          'zope.publisher',
-                          'zope.security',
-                          'zope.app.publisher',
-                          'z3c.zrtresource',
-                          'z3ext.cacheheaders',
-                          'z3ext.cssregistry',
+                          'z3ext.resourcepackage',
                           ],
-      extras_require = dict(test=['zope.traversing',
-                                  'zope.app.testing',
-                                  'zope.testing',
-                                  'zope.testbrowser',
-                                  ]),
       include_package_data = True,
       zip_safe = False
       )

Deleted: z3ext.resource/trunk/src/z3ext/resource/README.txt
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/README.txt	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/README.txt	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,246 +0,0 @@
-============================
-``z3ext:resource`` Directive
-============================
-
-This package provides a new directive similar to browser:resource directive.
-
-  >>> from zope import component, interface
-  >>> from z3ext.resource import interfaces, fileresource
-
-  >>> import z3ext.resource
-  >>> from zope.configuration import xmlconfig
-  >>> context = xmlconfig.file('meta.zcml', z3ext.resource)
-
-Now we can register a resource:
-
-  >>> import tempfile, os, os.path
-  >>> fn = tempfile.mktemp('.js')
-  >>> open(fn, 'w').write('''some resource data''')
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resource
-  ...       name="resource.js"
-  ...       file="%s" />
-  ... </configure>
-  ... '''%fn, context=context)
-
-Now let's see whether the adapter has been registered:
-
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> response = request.response
-
-  >>> resource = component.getAdapter(
-  ...    request, interface.Interface, name='resource.js')
-
-  >>> modified = resource.modified()
-
-  >>> resource.render(request)
-  'some resource data'
-
-By default resource is FileResource
-
-  >>> isinstance(resource.context, fileresource.File)
-  True
-
-We can set resource type explicitly
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resource
-  ...       name="resource-image"
-  ...       type="imageresource"
-  ...       file="%s" />
-  ... </configure>
-  ... ''' %fn, context=context)
-
-  >>> resource = component.getAdapter(
-  ...    request, interface.Interface, name='resource-image')
-
-  >>> isinstance(resource.context, fileresource.Image)
-  True
-
-
-Custom resource type
---------------------
-
-We have to register IResourceFactoryType utility
-
-  >>> from z3ext.resource.tests import CustomFileResourceFactory
-  >>> custom = component.factory.Factory(
-  ...   CustomFileResourceFactory, interfaces=(interfaces.IResourceFactory,))
-  >>> component.provideUtility(
-  ...     custom, interfaces.IResourceFactoryType, name='custom')
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resource
-  ...       name="resource-custom"
-  ...       type="custom"
-  ...       file="%s" />
-  ... </configure>
-  ... ''' %fn, context=context)
-
-  >>> resource = component.getAdapter(
-  ...    request, interface.Interface, name='resource-custom')
-
-  >>> resource
-  <z3ext.resource.tests.CustomResource object at ...>
-
-  >>> os.unlink(fn)
-
-
-=====================================
-``z3ext:resourceDirectory`` Directive
-=====================================
-
-We need some temporary directories and files
-
-  >>> import tempfile
-  >>> dn = tempfile.mkdtemp()
-  >>> os.mkdir(os.path.join(dn, 'subfolder'))
-  >>> open(os.path.join(dn, 'resource1.css'), 'w').write('''\
-  ... /* zrt-cssregistry: */ 
-  ... h1 {
-  ...   color: fontColor;
-  ...   font: fontFamily;
-  ...   background: url('../img1/mybackground.gif');
-  ... }''')
-  >>> open(os.path.join(dn, 'resource2.js'), 'w').write('test')
-  >>> open(os.path.join(dn, 'resource3.css'), 'w').write('test')
-  >>> open(os.path.join(dn, 'resource4.jpg'), 'w').write('test')
-  >>> open(os.path.join(dn, 'resource5.png'), 'w').write('test')
-
-Directive require directory path
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resourcedirectory
-  ...       name="myresources"
-  ...       directory="%s" />
-  ... </configure>
-  ... ''' %(dn+'123123234534234'), context=context)
-  Traceback (most recent call last):
-  ...
-  ZopeXMLConfigurationError: ...
-
-Now we can register a directory of resources, also we can set
-resource types:
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resourcedirectory
-  ...       name="myresources"
-  ...       directory="%s"
-  ...	    mapping=".css:zrt .js:fileresource
-  ...                resource3.css:cutom .png:null" />
-  ... </configure>
-  ... ''' %dn, context=context)
-
-  >>> dirresource = component.getAdapter(
-  ...    request, interface.Interface, name='myresources')
-
-Now we can get resource
-
-  >>> dirresource.browserDefault(request)
-  (<function empty at ...>, ())
-
-  >>> resource = dirresource.publishTraverse(request, 'resource1.css')
-  >>> print resource.GET()
-  h1 {
-      color: #11111111;
-      font: Verdana;
-      background: url('../img1/mybackground.gif');
-  }
-
-  >>> print dirresource['resource1.css'].GET()
-  h1 {
-      color: #11111111;
-      font: Verdana;
-      background: url('../img1/mybackground.gif');
-  }
-
-  >>> dirresource.publishTraverse(request, 'unknown.css')
-  Traceback (most recent call last):
-  ...
-  NotFound: ...
-
-  >>> dirresource['unknown.css']
-  Traceback (most recent call last):
-  ...
-  KeyError: 'unknown.css'
-
-
-Types mapping
--------------
-
-  In 'mapping' we defined that all files with '.css' extension should be 
-custom type, '.js' should be file resource and filename 'test.css' 
-should be file resource, '.png' should be not available
-
-  >>> dirresource.publishTraverse(request, 'resource1.css')
-  <z3ext.resource.zrtresource.zrtresource.ZRTFileResource ...>
-
-  >>> dirresource.publishTraverse(request, 'resource2.js')
-  <z3ext.resource.fileresource.FileResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource3.css')
-  <z3ext.resource.fileresource.FileResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource4.jpg')
-  <z3ext.resource.fileresource.FileResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource5.png')
-  Traceback (most recent call last):
-  ...
-  NotFound: Object: ...
-
-Or we can use 'resourceType' subdirective:
-
-  >>> context = xmlconfig.string('''
-  ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
-  ...   <z3ext:resourcedirectory
-  ...       name="myresources2"
-  ...       directory="%s">
-  ...     <resourceType file=".css" type="zrt" />
-  ...     <resourceType file=".js" type="fileresource" />
-  ...     <resourceType file="resource3.css" type="custom" />
-  ...     <resourceType file=".png" type="null" />
-  ...   </z3ext:resourcedirectory>
-  ... </configure>
-  ... ''' %dn, context=context)
-
-  >>> dirresource = component.getAdapter(
-  ...    request, interface.Interface, name='myresources2')
-
-  >>> dirresource.publishTraverse(request, 'resource1.css')
-  <z3ext.resource.zrtresource.zrtresource.ZRTFileResource ...>
-
-  >>> dirresource.publishTraverse(request, 'resource2.js')
-  <z3ext.resource.fileresource.FileResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource3.css')
-  <z3ext.resource.tests.CustomResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource4.jpg')
-  <z3ext.resource.fileresource.FileResource object at ...>
-
-  >>> dirresource.publishTraverse(request, 'resource5.png')
-  Traceback (most recent call last):
-  ...
-  NotFound: Object: ...
-
-
-We can get sub directories
-
-  >>> subdir = dirresource.publishTraverse(request, 'subfolder')
-
-
-  >>> os.unlink(os.path.join(dn, 'resource1.css'))
-  >>> os.unlink(os.path.join(dn, 'resource2.js'))
-  >>> os.unlink(os.path.join(dn, 'resource3.css'))
-  >>> os.unlink(os.path.join(dn, 'resource4.jpg'))
-  >>> os.unlink(os.path.join(dn, 'resource5.png'))
-  >>> os.rmdir(os.path.join(dn, 'subfolder'))
-  >>> os.rmdir(dn)

Modified: z3ext.resource/trunk/src/z3ext/resource/configure.zcml
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/configure.zcml	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/configure.zcml	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,56 +1,3 @@
-<configure 
-   xmlns="http://namespaces.zope.org/zope"
-   xmlns:zcml="http://namespaces.zope.org/zcml">
+<configure xmlns="http://namespaces.zope.org/zope">
 
-  <utility
-     component=".fileresource.filefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="fileresource"
-     component=".fileresource.filefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="imageresource"
-     component=".fileresource.imagefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="gif"
-     component=".fileresource.imagefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="png"
-     component=".fileresource.imagefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="jpg"
-     component=".fileresource.imagefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="pt"
-     component=".resource.pagetemplatefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="zpt"
-     component=".resource.pagetemplatefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <utility
-     name="html"
-     component=".resource.pagetemplatefactory"
-     provides=".resource.IResourceFactoryType" />
-
-  <adapter
-     for="zope.app.publisher.browser.fileresource.FileResource"
-     factory=".fileresource.FileResourceAdapter"
-     permission="zope.Public" />
-
-  <include package=".zrtresource" />
-
 </configure>

Deleted: z3ext.resource/trunk/src/z3ext/resource/fileresource.py
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/fileresource.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/fileresource.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,101 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from zope.component.factory import Factory
-from zope.app.publisher.fileresource import Image
-from zope.app.publisher.fileresource import File as BaseFile
-from zope.app.publisher.browser.fileresource import FileResource as BaseFileResource
-
-from interfaces import IResource, IResourceFactoryType
-
-
-class File(BaseFile):
-
-    def __init__(self, path, name):
-        super(File, self).__init__(path, name)
-
-        if self.content_type == 'application/x-javascript':
-            self.content_type = 'text/javascript'
-
-
-class FileResource(BaseFileResource):
-    interface.implements(IResource)
-
-    def modified(self, default=long(0)):
-        file = self.chooseContext()
-        if getattr(file, 'lmt', None):
-            return long(file.lmt)
-        else:
-            return default
-
-    def render(self, request):
-        file = self.chooseContext()
-        f = open(file.path,'rb')
-        data = f.read()
-        f.close()
-        return data
-
-
-class FileResourceAdapter(object):
-    interface.implements(IResource)
-
-    def __init__(self, context):
-        self.context = context
-
-    def modified(self, default=long(0)):
-        file = self.context.chooseContext()
-        if getattr(file, 'lmt', None):
-            return long(file.lmt)
-        else:
-            return default
-
-    def render(self, request):
-        file = self.context.chooseContext()
-        f = open(file.path,'rb')
-        data = f.read()
-        f.close()
-        return data
-
-
-class FileResourceFactory(object):
-
-    def __init__(self, path, checker, name):
-        self._file = File(path, name)
-        self._checker = checker
-        self._name = name
-
-    def __call__(self, request):
-        resource = FileResource(self._file, request)
-        resource.__Security_checker__ = self._checker
-        resource.__name__ = self._name
-        return resource
-
-
-filefactory = Factory(FileResourceFactory)
-interface.directlyProvides(filefactory, IResourceFactoryType)
-
-
-class ImageResourceFactory(FileResourceFactory):
-
-    def __init__(self, path, checker, name):
-        self._file = Image(path, name)
-        self._checker = checker
-        self._name = name
-
-imagefactory = Factory(ImageResourceFactory)
-interface.directlyProvides(imagefactory, IResourceFactoryType)

Deleted: z3ext.resource/trunk/src/z3ext/resource/interfaces.py
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/interfaces.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/interfaces.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,37 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from z3ext.cacheheaders.interfaces import IModificationInfo
-
-
-class IResource(IModificationInfo):
-
-    def render(request):
-        """ render resource """
-
-
-class IResourceFactory(interface.Interface):
-
-    def __call__(self, request, **kwargs):
-        """ create resource """
-
-
-class IResourceFactoryType(interface.Interface):
-
-    def __call__(self, path, checker, name):
-        """ create resource factory """

Modified: z3ext.resource/trunk/src/z3ext/resource/meta.zcml
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/meta.zcml	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/meta.zcml	2009-12-22 23:57:34 UTC (rev 106983)
@@ -2,22 +2,4 @@
    xmlns="http://namespaces.zope.org/zope"
    xmlns:meta="http://namespaces.zope.org/meta">
 
-  <meta:directives namespace="http://namespaces.zope.org/z3ext">
-    <meta:directive
-        name="resource"
-        schema=".zcml.IResourceDirective"
-        handler=".zcml.resourceDirective" />
-
-    <meta:complexDirective
-       name="resourcedirectory"
-       schema=".zcml.IResourceDirectoryDirective"
-       handler=".zcml.ResourceDirectoryDirective">
-
-      <meta:subdirective
-         name="resourceType"
-         schema=".zcml.IResourceDirectoryResourceType" />
-    </meta:complexDirective>
-
-  </meta:directives>
-
 </configure>

Deleted: z3ext.resource/trunk/src/z3ext/resource/resource.py
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/resource.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/resource.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,26 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from zope.component.factory import Factory
-from zope.app.publisher.browser import pagetemplateresource
-
-from interfaces import IResourceFactoryType
-
-
-pagetemplatefactory = Factory(pagetemplateresource.PageTemplateResourceFactory)
-interface.directlyProvides(IResourceFactoryType)

Deleted: z3ext.resource/trunk/src/z3ext/resource/tests.py
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/tests.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/tests.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,87 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-"""test setup
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import doctest, unittest
-from zope import component, interface
-from zope.app.testing import placelesssetup
-from zope.traversing import testing
-from zope.traversing.interfaces import ITraversable
-from zope.traversing.namespace import view
-from zope.app.publisher.browser.fileresource import FileResource
-
-from z3c.zrtresource.interfaces import IZRTCommandFactory
-
-from zrtresource import zrtresource
-
-from z3ext.resource import fileresource
-from z3ext.resource.interfaces import IResourceFactoryType
-from z3ext.cssregistry.registry import CSSRegistry
-from z3ext.cssregistry import zcml, command, property, interfaces
-
-
-class CustomResource(fileresource.FileResource):
-    pass
-
-
-class CustomFileResourceFactory(fileresource.FileResourceFactory):
-
-    def __call__(self, request):
-        resource = CustomResource(self._file, request)
-        resource.__Security_checker__ = self._checker
-        resource.__name__ = self._name
-        return resource
-
-
-def setUp(test):
-    placelesssetup.setUp(test)
-    testing.setUp()
-    component.provideAdapter(view, (None, None), ITraversable, name="view")
-
-    component.provideUtility(
-        fileresource.filefactory, IResourceFactoryType)
-    component.provideUtility(
-        fileresource.filefactory, IResourceFactoryType, name='fileresource')
-    component.provideUtility(
-        fileresource.imagefactory, IResourceFactoryType, name='imageresource')
-    component.provideUtility(
-        zrtresource.zrtfactory, IResourceFactoryType, name='zrt')
-
-    component.provideAdapter(
-        fileresource.FileResourceAdapter, (FileResource,))
-
-    component.provideUtility(
-        command.cssregistry_factory, IZRTCommandFactory, 'cssregistry')
-
-    registry = CSSRegistry()
-    registry['fontColor']= property.Property('fontColor', '#11111111')
-    registry['fontFamily']= property.Property('fontFamily', 'Verdana')
-
-    component.provideAdapter(
-        zcml.Factory(registry),
-        (interfaces.ICSSRegistryLayer, interfaces.ICSSRegistryLayer,
-         interface.Interface), interfaces.ICSSRegistry, '')
-
-
-def test_suite():
-    return unittest.TestSuite((
-            doctest.DocFileSuite(
-                'README.txt',
-                setUp=setUp, tearDown=placelesssetup.tearDown,
-                optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
-         ))

Deleted: z3ext.resource/trunk/src/z3ext/resource/zcml.py
===================================================================
--- z3ext.resource/trunk/src/z3ext/resource/zcml.py	2009-12-22 23:57:20 UTC (rev 106982)
+++ z3ext.resource/trunk/src/z3ext/resource/zcml.py	2009-12-22 23:57:34 UTC (rev 106983)
@@ -1,264 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-""" z3ext:resource and z3ext:directoryResource directives implementation
-
-$Id$
-"""
-import os, posixpath
-
-from zope import schema, interface
-from zope.component.zcml import handler
-from zope.component import getUtility, queryUtility
-
-from zope.configuration import fields
-from zope.configuration.exceptions import ConfigurationError
-
-from zope.publisher.browser import BrowserView
-from zope.publisher.interfaces import NotFound
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-
-from zope.security.checker import CheckerPublic, NamesChecker
-
-from zope.app.publisher.browser import metadirectives
-from zope.app.publisher.browser.resource import Resource
-from zope.app.publisher.browser.resources import empty
-from zope.app.publisher.browser.resourcemeta import allowed_names
-from zope.app.publisher.browser.directoryresource import Directory
-
-from z3ext.resource import fileresource
-from z3ext.resource.interfaces import IResourceFactory, IResourceFactoryType
-
-_marker = object()
-
-
-class IResourceDirective(metadirectives.IBasicResourceInformation):
-    """ z3ext:resource directive """
-
-    name = 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)
-
-    type = schema.TextLine(
-        title = u'Resource type',
-        required = False)
-
-    file = fields.Path(
-        title = u'Resource file',
-        description = u'The file containing the resource data.',
-        required = True)
-
-# Arbitrary keys and values are allowed to be passed to the CustomWidget.
-IResourceDirective.setTaggedValue('keyword_arguments', True)
-
-
-class IResourceDirectoryDirective(metadirectives.IResourceDirectoryDirective):
-
-    mapping = fields.Tokens(
-        title = u'Resource mapping',
-        description = u'By default resourceDirective tries determine resource '\
-            u"type by it's extension, but we can define mapping explicitly."\
-            u'Format ".{extention}:{resource type}" or "{filename}:{resource type}',
-        required=False,
-        value_type=schema.TextLine())
-
-
-class IResourceDirectoryResourceType(interface.Interface):
-
-    file = schema.TextLine(
-        title = u'Filename',
-        required = True)
-
-    type = schema.TextLine(
-        title = u'Resource type',
-        required = True)
-
-
-# Arbitrary keys and values are allowed to be passed to the CustomWidget.
-IResourceDirectoryResourceType.setTaggedValue('keyword_arguments', True)
-
-
-def resourceDirective(_context, name, file, layer=IDefaultBrowserLayer,
-                      permission='zope.Public', type='', **kwargs):
-    if permission == 'zope.Public':
-        permission = CheckerPublic
-
-    checker = NamesChecker(allowed_names, permission)
-
-    _context.action(
-        discriminator = ('z3ext.resource', name, IBrowserRequest, layer),
-        callable = resourceHandler,
-        args = (name, layer, checker, file, type, _context.info),
-        )
-
-
-def resourceHandler(name, layer, checker, file, type, info):
-    if type:
-        factory = getUtility(IResourceFactoryType, name=type)
-    else:
-        type = os.path.splitext(os.path.normcase(name))[1][1:]
-
-        factory = queryUtility(IResourceFactoryType, name=type)
-        if factory is None:
-            factory = getUtility(IResourceFactoryType)
-
-    factory = factory(file, checker, name)
-
-    handler('registerAdapter',
-            factory, (layer,), interface.Interface, name, info)
-
-
-class ResourceDirectoryDirective(object):
-
-
-    def __init__(self, _context, name, directory, layer=IDefaultBrowserLayer,
-                 permission='zope.Public', mapping=()):
-        if permission == 'zope.Public':
-            permission = CheckerPublic
-
-        checker = NamesChecker(
-            allowed_names + ('__getitem__', 'get'), permission)
-
-        if not os.path.isdir(directory):
-            raise ConfigurationError(
-                "Directory %s does not exist" % directory)
-
-        # process resource types
-        types = {}
-        for l in mapping:
-            fname, type = l.split(':')
-            info = {'file': None,
-                    'ext': None,
-                    'type': type}
-            if fname[0] == '.':
-                info['ext'] = fname[1:]
-            else:
-                info['file'] = fname
-            types[fname] = info
-
-        factory = DirectoryResourceFactory(directory, checker, name, types)
-        _context.action(
-            discriminator = ('z3ext.resource', name, IBrowserRequest, layer),
-            callable = handler,
-            args = ('registerAdapter',
-                    factory, (layer,), interface.Interface, name, _context.info))
-
-        self.factory = factory
-
-    def resourceType(self, _context, file, type, **kwargs):
-        info = {'file': None,
-                'ext': None,
-                'type': type}
-        info.update(kwargs)
-
-        if file[0] == '.':
-            info['ext'] = file[1:]
-        else:
-            info['file'] = file
-
-        self.factory.types[file] = info
-
-
-class DirectoryResource(BrowserView, Resource):
-
-    interface.implements(IBrowserPublisher)
-
-    default_factory = fileresource.filefactory
-
-    types = {}
-
-    def publishTraverse(self, request, name):
-        '''See interface IBrowserPublisher'''
-        return self.get(name)
-
-    def browserDefault(self, request):
-        '''See interface IBrowserPublisher'''
-        return empty, ()
-
-    def __getitem__(self, name):
-        res = self.get(name, None)
-        if res is None:
-            raise KeyError(name)
-        return res
-
-    def get(self, name, default=_marker):
-        request = self.request
-        path = self.context.path
-        filename = os.path.join(path, name)
-        isfile = os.path.isfile(filename)
-        isdir = os.path.isdir(filename)
-
-        rname = posixpath.join(self.__name__, name)
-
-        if not (isfile or isdir):
-            if default is _marker:
-                raise NotFound(self, name)
-            return default
-
-        if isfile:
-            types = self.types
-
-            info = types.get(name)
-            if info is None:
-                ext = os.path.splitext(os.path.normcase(name))[1]
-                info = types.get(ext)
-
-            if info is not None:
-                if info['type'] == 'null':
-                    raise NotFound(self, name)
-
-                factoryType = queryUtility(IResourceFactoryType, name=info['type'])
-                if factoryType is not None:
-                    factory = factoryType(filename, self.context.checker, rname)
-
-                    if IResourceFactory.providedBy(factory):
-                        resource = factory(request, **info)
-                    else:
-                        resource = factory(request)
-
-                    resource.__parent__ = self
-                    return resource
-
-            resource = self.default_factory(
-                filename, self.context.checker, rname)(request)
-        else:
-            resource = DirectoryResourceFactory(
-                filename, self.context.checker, rname, self.types)(request)
-
-        resource.__parent__ = self
-        return resource
-
-
-class DirectoryResourceFactory(object):
-
-    def __init__(self, path, checker, name, types={}):
-        self._dir = Directory(path, checker, name)
-        self._checker = checker
-        self._name = name
-        self.types = types
-
-    def __call__(self, request):
-        resource = DirectoryResource(self._dir, request)
-        resource.__Security_checker__ = self._checker
-        resource.__name__ = self._name
-        resource.types = self.types
-        return resource



More information about the checkins mailing list