[Checkins] SVN: megrok.strictrequire/ Initial import.

Jan-Wijbrand Kolman janwijbrand at gmail.com
Mon Jun 22 09:43:54 EDT 2009


Log message for revision 101218:
  Initial import.
  
  

Changed:
  A   megrok.strictrequire/
  A   megrok.strictrequire/branches/
  A   megrok.strictrequire/tags/
  A   megrok.strictrequire/trunk/
  A   megrok.strictrequire/trunk/CHANGES.txt
  A   megrok.strictrequire/trunk/COPYRIGHT.txt
  A   megrok.strictrequire/trunk/LICENSE.txt
  A   megrok.strictrequire/trunk/README.txt
  A   megrok.strictrequire/trunk/bootstrap.py
  A   megrok.strictrequire/trunk/buildout.cfg
  A   megrok.strictrequire/trunk/setup.py
  A   megrok.strictrequire/trunk/src/
  A   megrok.strictrequire/trunk/src/megrok/
  A   megrok.strictrequire/trunk/src/megrok/__init__.py
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/README.txt
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/__init__.py
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/configure.zcml
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/meta.py
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/__init__.py
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/checkrequire.txt
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/fixtures.py
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/ftesting.zcml
  A   megrok.strictrequire/trunk/src/megrok/strictrequire/tests/test.py

-=-
Added: megrok.strictrequire/trunk/CHANGES.txt
===================================================================
--- megrok.strictrequire/trunk/CHANGES.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/CHANGES.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,12 @@
+Changelog of megrok.strictrequire
+=================================
+
+0.2 (unreleased)
+----------------
+
+- Check ViewletManager and Viewlet components too.
+
+0.1 (2009-06-18)
+----------------
+
+- Initial release.

Added: megrok.strictrequire/trunk/COPYRIGHT.txt
===================================================================
--- megrok.strictrequire/trunk/COPYRIGHT.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/COPYRIGHT.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,9 @@
+Copyright (c) 2006-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. 

Added: megrok.strictrequire/trunk/LICENSE.txt
===================================================================
--- megrok.strictrequire/trunk/LICENSE.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/LICENSE.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -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: megrok.strictrequire/trunk/README.txt
===================================================================
--- megrok.strictrequire/trunk/README.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/README.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,12 @@
+megrok.strictrequire
+====================
+
+What is megrok.strictrequire?
+-----------------------------
+
+Strictrequire implements additional grokkers for the various view components
+in Grok. These grokkers determine whether the ``grok.require`` directive has
+been explicitly set on the view component (or on its baseclass).
+
+See README.txt in src/megrok/strictrequire/README.txt for additional
+information.

Added: megrok.strictrequire/trunk/bootstrap.py
===================================================================
--- megrok.strictrequire/trunk/bootstrap.py	                        (rev 0)
+++ megrok.strictrequire/trunk/bootstrap.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# 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()
+
+try:
+    import pkg_resources
+except ImportError:
+    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)

Added: megrok.strictrequire/trunk/buildout.cfg
===================================================================
--- megrok.strictrequire/trunk/buildout.cfg	                        (rev 0)
+++ megrok.strictrequire/trunk/buildout.cfg	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,61 @@
+[buildout]
+develop = .
+extensions = buildout.dumppickedversions
+extends = http://grok.zope.org/releaseinfo/grok-1.0a4.cfg
+unzip = true
+prefer-final = true
+versions = versions
+parts =
+    development_tools
+    omelette
+    pyflakes
+    test
+
+
+[versions]
+# Override Grok KGS for development:
+z3c.testsetup = 0.4
+zope.testing = 3.7.5
+# Result of buildout.dumppickedversions:
+collective.recipe.omelette = 0.9
+ipython = 0.9.1
+pyflakes = 0.3.0
+zc.recipe.egg = 1.2.2
+zest.releaser = 2.6
+setuptools = 0.6c9
+zc.buildout = 1.2.1
+tha.coverage = 0.1.1
+z3c.coverage = 1.1.2
+
+[test]
+recipe = zc.recipe.testrunner
+defaults = ['--tests-pattern', '^f?tests$', '-v', '-c']
+eggs =
+    megrok.strictrequire
+    megrok.strictrequire[test]
+
+
+[development_tools]
+recipe = zc.recipe.egg
+interpreter = python
+eggs =
+    megrok.strictrequire
+    ipython
+    zest.releaser
+    tha.coverage
+
+
+[pyflakes]
+recipe = zc.recipe.egg
+scripts =
+   pyflakes
+eggs =
+   pyflakes
+   setuptools
+entry-points = pyflakes=pkg_resources:run_script
+arguments = 'pyflakes', 'pyflakes'
+
+
+[omelette]
+recipe = collective.recipe.omelette
+eggs = megrok.strictrequire

Added: megrok.strictrequire/trunk/setup.py
===================================================================
--- megrok.strictrequire/trunk/setup.py	                        (rev 0)
+++ megrok.strictrequire/trunk/setup.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,33 @@
+from setuptools import setup, find_packages
+import os.path
+
+version = '0.2dev'
+detailed = open(
+    os.path.join('src', 'megrok', 'strictrequire', 'README.txt')).read()
+changes = open('CHANGES.txt').read()
+long_description = '\n\n'.join([detailed, changes, ''])
+
+setup(name='megrok.strictrequire',
+      version=version,
+      description="Checks that all Grokked components require a permission.",
+      long_description=long_description,
+      classifiers=[],
+      keywords=[],
+      author='The Health Agency',
+      author_email='techniek at thehealthagency.com',
+      url='http://www.thehealthagency.com',
+      license='',
+      package_dir={'': 'src'},
+      namespace_packages=['megrok'],
+      packages=find_packages('src'),
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          'grok',
+          ],
+      extras_require = {
+          'test': ['z3c.testsetup >= 0.4',],
+          },
+      entry_points={},
+      )

Added: megrok.strictrequire/trunk/src/megrok/__init__.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/__init__.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/__init__.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -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__)

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/README.txt
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/README.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/README.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,47 @@
+megrok.strictrequire
+====================
+
+What is megrok.strictrequire?
+-----------------------------
+
+Strictrequire implements additional grokkers for the various view components
+in Grok. These grokkers determine whether the ``grok.require`` directive has
+been explicitly set on the view component (or on its baseclass).
+
+It will raise an error (and thus prevent the startup of the application) if
+there's a view component without an explicit use of the ``grok.require``
+directive, providing a minimal safety net for finding unprotected views in
+your application.
+
+Making use of megrok.strictrequire
+----------------------------------
+
+To enable megrok.strictrequire simply list it as a requirement in your
+projects's ``setup.py``. Grok based applications that were bootstrapped with
+a recent version of the ``grokproject`` command will automatically include
+the megrok.strictrequire's ``configure.zcml`` making the additional grokkers
+effective.
+
+Caveat
+------
+
+If your applications triggers the registration of "third-party" views that do
+not themselves specifically use the ``grok.require`` directive, your
+application will not start.
+
+If you decide you still want to make use of the third-aprty views you should
+make sure the inclusion of the ``configure.zcml`` of megrok.strictrequire
+comes *after* the inclusion of the third-party package by tweaking your
+applications's ``configure.zcml``. For example::
+
+    <configure xmlns="http://namespaces.zope.org/zope"
+               xmlns:grok="http://namespaces.zope.org/grok">
+      <include package="grok" />
+
+      <!-- include this package before mgrok.strictrequire is included -->
+      <include package="package_with_unprotected_views" />
+
+      <!-- includeDependencies will include megrok.strictrequire -->
+      <includeDependencies package="." />
+      <grok:grok package="." />
+    </configure>

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/__init__.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/__init__.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/__init__.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1 @@
+# this directory is a package

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/configure.zcml
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/configure.zcml	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/configure.zcml	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,6 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:grok="http://namespaces.zope.org/grok">
+  <include package="grok" />
+  <grok:grok package="." />
+</configure>

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/meta.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/meta.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/meta.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,52 @@
+import martian
+import grok
+
+class SecurityError(grok.GrokError):
+    pass
+
+
+_require_marker = object()
+
+
+class CheckRequireGrokker(martian.ClassGrokker):
+    """Ensure every grok.View has a grok.require directive"""
+    martian.component(grok.View)
+    martian.directive(grok.require, default=_require_marker)
+
+    def execute(self, factory, config, require, **kw):
+        if require is _require_marker:
+            raise SecurityError(
+                'megrok.strictrequire requires %r to use the grok.require '
+                'directive!' % factory, factory)
+        return True
+
+
+class CheckRequireGrokkerViewlet(CheckRequireGrokker):
+    """Ensure every grok.Viewlet has a grok.require directive"""
+    martian.component(grok.Viewlet)
+
+
+class CheckRequireGrokkerViewletmanager(CheckRequireGrokker):
+    """Ensure every grok.ViewletManager has a grok.require directive"""
+    martian.component(grok.ViewletManager)
+
+
+class CheckRequireRESTGrokker(martian.MethodGrokker):
+    """Ensure every grok.REST has a grok.require directive"""
+    martian.component(grok.REST)
+    martian.directive(grok.require, default=_require_marker)
+
+    def execute(self, factory, method, config, require, **kw):
+        if require is _require_marker:
+            raise SecurityError(
+                'megrok.strictrequire requires %r to use the grok.require '
+                'directive on the method: %s!' % (factory, method), factory)
+        return True
+
+
+class CheckRequireXMLPRCGrokker(CheckRequireRESTGrokker):
+    martian.component(grok.XMLRPC)
+
+
+class CheckRequireJSONGrokker(CheckRequireRESTGrokker):
+    martian.component(grok.JSON)

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/tests/__init__.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/tests/__init__.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/tests/__init__.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1 @@
+# this directory is a package

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/tests/checkrequire.txt
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/tests/checkrequire.txt	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/tests/checkrequire.txt	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,112 @@
+"""
+.. :doctest:
+.. :functional-zcml-layer: ftesting.zcml
+
+It is important to have all views closed by default, unless explicitely opened
+up. Here we check to see that all view related component at have an explicitly
+set `grok.require` directive.
+
+This "assurance" is implemented by a custom grokker that checks whether a view
+component does have a required permission defined::
+
+    >>> from grok.testing import grok_component
+    >>> from megrok.strictrequire.tests.fixtures import (
+    ...     NoRequireView, NoRequireViewletManager, NoRequireViewlet)
+    >>> grok_component('NoRequireView', NoRequireView)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireView'>
+    to use the grok.require directive!
+
+    >>> grok_component('NoRequireViewletManager', NoRequireViewletManager)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireViewletManager'>
+    to use the grok.require directive!
+
+    >>> grok_component('NoRequireViewlet', NoRequireViewlet)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireViewlet'>
+    to use the grok.require directive!
+
+Ditto for grok.Fornm, grok.AddForm. grok.EditForm, grok.XMLRPC, grok.JSON,
+grok.REST components::
+
+    >>> from megrok.strictrequire.tests.fixtures import (
+    ...     NoRequireForm, NoRequireAddForm, NoRequireEditForm,
+    ...     NoRequireXMLRPC, NoRequireREST, NoRequireJSON)
+    >>> grok_component('NoRequireForm', NoRequireForm)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireForm'>
+    to use the grok.require directive!
+
+    >>> grok_component('NoRequireAddForm', NoRequireAddForm)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireAddForm'>
+    to use the grok.require directive!
+
+    >>> grok_component('NoRequireEditForm', NoRequireEditForm)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires
+    <class 'megrok.strictrequire.tests.fixtures.NoRequireEditForm'>
+    to use the grok.require directive!
+
+    >>> grok_component('NoRequireXMLRPC', NoRequireXMLRPC)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires <class
+    'megrok.strictrequire.tests.fixtures.NoRequireXMLRPC'> to use the grok.require
+    directive on the method: <unbound method NoRequireXMLRPC.foobar>!
+
+    >>> grok_component('NoRequireREST', NoRequireREST)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires <class
+    'megrok.strictrequire.tests.fixtures.NoRequireREST'> to use the grok.require
+    directive on the method: <unbound method NoRequireREST.foobar>!
+
+    >>> grok_component('NoRequireJSON', NoRequireJSON)
+    Traceback (most recent call last):
+    ...
+    SecurityError: megrok.strictrequire requires <class
+    'megrok.strictrequire.tests.fixtures.NoRequireJSON'> to use the grok.require
+    directive on the method: <unbound method NoRequireJSON.foobar>!
+
+Of course, when the grok.require directive *is* used, there should not be any
+exception raised::
+
+    >>> from megrok.strictrequire.tests.fixtures import (
+    ...     RequireView, RequireForm, RequireAddForm, RequireEditForm,
+    ...     RequireXMLRPC, RequireREST, RequireJSON,
+    ...     RequireOnMethodXMLRPC, RequireOnMethodREST, RequireOnMethodJSON)
+    >>> grok_component('RequireView', RequireView)
+    True
+    >>> grok_component('RequireForm', RequireForm)
+    True
+    >>> grok_component('RequireAddForm', RequireAddForm)
+    True
+    >>> grok_component('RequireEditForm', RequireEditForm)
+    True
+    >>> grok_component('RequireXMLRPC', RequireXMLRPC)
+    True
+    >>> grok_component('RequireREST', RequireREST)
+    True
+    >>> grok_component('RequireJSON', RequireJSON)
+    True
+    >>> grok_component('RequireOnMethodXMLRPC', RequireOnMethodXMLRPC)
+    True
+    >>> grok_component('RequireOnMethodREST', RequireOnMethodREST)
+    True
+    >>> grok_component('RequireOnMethodJSON', RequireOnMethodJSON)
+    True
+
+"""

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/tests/fixtures.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/tests/fixtures.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/tests/fixtures.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,114 @@
+import grok
+import zope.interface
+
+class NoRequireView(grok.View):
+    grok.context(zope.interface.Interface)
+
+    def render(self):
+        pass
+
+class NoRequireViewletManager(grok.ViewletManager):
+    grok.context(zope.interface.Interface)
+
+    def render(self):
+        pass
+
+class NoRequireViewlet(grok.Viewlet):
+    grok.context(zope.interface.Interface)
+    grok.viewletmanager(NoRequireViewletManager)
+
+    def render(self):
+        pass
+
+class NoRequireForm(grok.Form):
+    grok.context(zope.interface.Interface)
+
+class NoRequireAddForm(grok.AddForm):
+    grok.context(zope.interface.Interface)
+
+class NoRequireEditForm(grok.EditForm):
+    grok.context(zope.interface.Interface)
+
+class NoRequireXMLRPC(grok.XMLRPC):
+    grok.context(zope.interface.Interface)
+
+    def foobar(self):
+        pass
+
+class NoRequireREST(grok.REST):
+    grok.context(zope.interface.Interface)
+
+    def foobar(self):
+        pass
+
+class NoRequireJSON(grok.JSON):
+    grok.context(zope.interface.Interface)
+    def foobar(self):
+        pass
+
+class NoRequireView(grok.View):
+    grok.context(zope.interface.Interface)
+
+    def render(self):
+        pass
+
+class RequireView(grok.View):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+    def render(self):
+        pass
+
+class RequireForm(grok.Form):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+class RequireAddForm(grok.AddForm):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+class RequireEditForm(grok.EditForm):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+class RequireXMLRPC(grok.XMLRPC):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+    def foobar(self):
+        pass
+
+class RequireREST(grok.REST):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+    def foobar(self):
+        pass
+
+class RequireJSON(grok.JSON):
+    grok.context(zope.interface.Interface)
+    grok.require('zope.Public')
+
+    def foobar(self):
+        pass
+
+class RequireOnMethodXMLRPC(grok.XMLRPC):
+    grok.context(zope.interface.Interface)
+
+    @grok.require('zope.Public')
+    def foobar(self):
+        pass
+
+class RequireOnMethodREST(grok.REST):
+    grok.context(zope.interface.Interface)
+
+    @grok.require('zope.Public')
+    def foobar(self):
+        pass
+
+class RequireOnMethodJSON(grok.JSON):
+    grok.context(zope.interface.Interface)
+
+    @grok.require('zope.Public')
+    def foobar(self):
+        pass

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/tests/ftesting.zcml
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/tests/ftesting.zcml	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/tests/ftesting.zcml	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,34 @@
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   i18n_domain="megrok.strictrequire"
+   package="megrok.strictrequire"
+   >
+
+  <include package="megrok.strictrequire" />
+
+  <!-- Typical functional testing security setup -->
+  <securityPolicy
+      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+      />
+
+  <unauthenticatedPrincipal
+      id="zope.anybody"
+      title="Unauthenticated User"
+      />
+  <grant
+      permission="zope.View"
+      principal="zope.anybody"
+      />
+
+  <principal
+      id="zope.mgr"
+      title="Manager"
+      login="mgr"
+      password="mgrpw"
+      />
+
+  <role id="zope.Manager" title="Site Manager" />
+  <grantAll role="zope.Manager" />
+  <grant role="zope.Manager" principal="zope.mgr" />
+
+</configure>

Added: megrok.strictrequire/trunk/src/megrok/strictrequire/tests/test.py
===================================================================
--- megrok.strictrequire/trunk/src/megrok/strictrequire/tests/test.py	                        (rev 0)
+++ megrok.strictrequire/trunk/src/megrok/strictrequire/tests/test.py	2009-06-22 13:43:53 UTC (rev 101218)
@@ -0,0 +1,2 @@
+import z3c.testsetup
+test_suite = z3c.testsetup.register_all_tests('megrok.strictrequire')



More information about the Checkins mailing list