[Checkins] SVN: grok/branches/darrylcousins-martian-layers/ Merged jw's decorators into this branch and replaced my egg buildout with that from Philipp's eggification branch

Darryl Cousins darryl at darrylcousins.net.nz
Thu Jun 28 00:35:50 EDT 2007


Log message for revision 77161:
  Merged jw's decorators into this branch and replaced my egg buildout with that from Philipp's eggification branch

Changed:
  U   grok/branches/darrylcousins-martian-layers/buildout.cfg
  D   grok/branches/darrylcousins-martian-layers/buildout.cfg.orig
  D   grok/branches/darrylcousins-martian-layers/buildout.cfg1
  U   grok/branches/darrylcousins-martian-layers/ftesting.zcml
  U   grok/branches/darrylcousins-martian-layers/setup.py
  D   grok/branches/darrylcousins-martian-layers/setup.py.1
  D   grok/branches/darrylcousins-martian-layers/setup.py.orig
  U   grok/branches/darrylcousins-martian-layers/src/grok/__init__.py
  U   grok/branches/darrylcousins-martian-layers/src/grok/_grok.py
  U   grok/branches/darrylcousins-martian-layers/src/grok/meta.py
  A   grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/adapterdecorator.py
  A   grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/functionasargument_fixture.py
  A   grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/noarguments_fixture.py

-=-
Modified: grok/branches/darrylcousins-martian-layers/buildout.cfg
===================================================================
--- grok/branches/darrylcousins-martian-layers/buildout.cfg	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/buildout.cfg	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,71 +1,91 @@
 [buildout]
 develop = . grokwiki ldapaddressbook martian
-parts = grok test
+parts = app data instance test devpython
+find-links = http://download.zope.org/distribution/
 
 [zope3]
-location = .
+# this dead chicken is needed by some other recipe(s)
+location =
 
-[grok-app]
-recipe = zc.zope3recipes:app
-site.zcml = <configure
-                xmlns="http://namespaces.zope.org/zope"
-                xmlns:browser="http://namespaces.zope.org/browser"
-                i18n_domain="zope">
-  <include package="zope.app.zcmlfiles" />
-  <include package="zope.contentprovider" />
-  <include package="zope.formlib" />
-  <include package="zope.i18n" file="meta.zcml" />
-  <include package="zope.i18n.locales" />
-  <include package="zope.security" file="meta.zcml" />
-  <include package="zope.traversing.browser" />
-  <include package="zope.app.securitypolicy" file="meta.zcml" />
-  <include package="zope.app.securitypolicy" file="configure.zcml" />
-  <include package="zope.app.authentication" />
-  <include package="zope.app.catalog" />
-  <include package="zope.app.intid" />
-  <include package="zope.app.keyreference" />
-  <include package="zope.app.twisted" />
-  <include package="zope.app.session" />
-  <include package="zope.viewlet" />
-  <!-- basic security setup to get me into grok admin -->
-  <securityPolicy component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-  <role id="zope.Anonymous" title="Everybody" description="All users have this role implicitly" />
-  <role id="zope.Manager" title="Site Manager" />
-  <grant permission="zope.View" role="zope.Anonymous" />
-  <grant permission="zope.app.dublincore.view" role="zope.Anonymous" />
-  <grantAll role="zope.Manager" />
-  <unauthenticatedPrincipal id="zope.anybody" title="Unauthenticated User" />
-  <unauthenticatedGroup id="zope.Anybody" title="Unauthenticated Users" />
-  <authenticatedGroup id="zope.Authenticated" title="Authenticated Users" />
-  <everybodyGroup id="zope.Everybody" title="All Users" />
-  <!-- initial manager login and password -->
-  <principal id="zope.manager" title="Manager" login="grok" password="grok" />
-  <grant role="zope.Manager" principal="zope.manager" />
-  <!-- my friend the caveman -->
-  <include package="grok" file="meta.zcml" />
-  <include package="grok" file="configure.zcml" />
-  <include package="grokwiki" file="configure.zcml" />
-  </configure>
-
+[app]
 eggs = grok
        grokwiki
-       ldapaddressbook
        martian
+recipe = zc.zope3recipes:app
+site.zcml = <include package="zope.security" file="meta.zcml" />
+            <include package="zope.i18n" file="meta.zcml" />
+            <include package="zope.app.securitypolicy" file="meta.zcml" />
+            <include package="zope.app.zcmlfiles" file="meta.zcml" />
+            <include package="grok" file="meta.zcml" />
 
-[grok]
-recipe = zc.zope3recipes:instance
-application = grok-app
-zope.conf = ${database:zconfig}
+            <include package="zope.annotation" />
+            <include package="zope.copypastemove" />
+            <include package="zope.formlib" />
+            <include package="zope.i18n.locales" />
+            <include package="zope.publisher" />
+            <include package="zope.size" />
+            <include package="zope.traversing" />
+            <include package="zope.traversing.browser" />
+            <include package="zope.publisher" />
+            <include package="zope.app.zcmlfiles" />
+            <include package="zope.app.securitypolicy" />
+            <include package="zope.app.authentication" />
+            <include package="zope.app.catalog" />
+            <include package="zope.app.intid" />
+            <include package="zope.app.keyreference" />
+            <include package="zope.app.twisted" />
+            <include package="martian" />
+            <include package="grok" />
+            <include package="grokwiki" />
 
-[database]
+            <securityPolicy 
+                component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+            <unauthenticatedPrincipal id="zope.anybody"
+                                      title="Unauthenticated User" />
+            <unauthenticatedGroup id="zope.Anybody"
+                                  title="Unauthenticated Users" />
+            <authenticatedGroup id="zope.Authenticated"
+                                title="Authenticated Users" />
+            <everybodyGroup id="zope.Everybody"
+                            title="All Users" />
+            <principal id="zope.manager"
+                       title="Manager"
+                       login="grok"
+                       password_manager="Plain Text"
+                       password="grok"
+                       />
+
+            <!-- Replace the following directive if you don't want
+                 public access -->
+            <grant permission="zope.View"
+                   principal="zope.Anybody" />
+            <grant permission="zope.app.dublincore.view"
+                   principal="zope.Anybody" />
+
+            <role id="zope.Manager" title="Site Manager" />
+            <role id="zope.Member" title="Site Member" />
+            <grantAll role="zope.Manager" />
+            <grant role="zope.Manager"
+                   principal="zope.manager" />
+
+[data]
 recipe = zc.recipe.filestorage
 
+[instance]
+recipe = zc.zope3recipes:instance
+application = app
+zope.conf = ${data:zconfig}
+
 [test]
 recipe = zc.recipe.testrunner
 eggs = grok
-       grokwiki
-       ldapaddressbook
        martian
-defaults = ['--tests-pattern', '^f?tests$',
-            '-v'
-           ]
+defaults = ['--tests-pattern', '^f?tests$', '-v']
+
+# installs bin/devpython to do simple interpreter tests
+[devpython]
+recipe = zc.recipe.egg
+interpreter = devpython
+eggs = grok
+       martian

Deleted: grok/branches/darrylcousins-martian-layers/buildout.cfg.orig
===================================================================
--- grok/branches/darrylcousins-martian-layers/buildout.cfg.orig	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/buildout.cfg.orig	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,62 +0,0 @@
-[buildout]
-develop = . grokwiki ldapaddressbook martian
-parts = data instance testdata testinstance test
-
-[zope3]
-#recipe = zc.recipe.zope3checkout
-#url = svn://svn.zope.org/repos/main/Zope3/branches/3.3
-location = /home/faassen/buildout/z331-lp
-
-[data]
-recipe = zc.recipe.filestorage
-
-[testdata]
-recipe = zc.recipe.filestorage
-
-[testinstance]
-recipe = zc.recipe.zope3instance
-database = testdata
-user = grok:grok
-eggs = setuptools
-       grok
-zcml = zope.annotation
-       zope.copypastemove
-       zope.formlib
-       zope.i18n-meta
-       zope.i18n.locales
-       zope.publisher
-       zope.security-meta
-       zope.size
-       zope.traversing
-       zope.traversing.browser
-       zope.app    
-       zope.app-meta
-       zope.app.securitypolicy
-       zope.app.securitypolicy-meta
-       zope.app.authentication
-       zope.app.catalog
-       zope.app.intid
-       zope.app.keyreference
-       grok
-       grok-meta
-
-[instance]
-recipe = zc.recipe.zope3instance
-database = data
-user = grok:grok
-eggs = setuptools
-       grok
-       grokwiki
-
-zcml = ${testinstance:zcml}
-       zope.app.twisted
-       grokwiki
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = grok
-extra-paths = /home/faassen/buildout/z331-lp/lib/python
-working-directory = parts/testinstance
-defaults = ['--tests-pattern', '^f?tests$',
-            '-v'
-           ]

Deleted: grok/branches/darrylcousins-martian-layers/buildout.cfg1
===================================================================
--- grok/branches/darrylcousins-martian-layers/buildout.cfg1	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/buildout.cfg1	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,94 +0,0 @@
-[buildout]
-develop = . grokwiki ldapaddressbook martian
-parts = grok test
-
-[zope3]
-location = .
-
-[grok-app]
-recipe = zc.zope3recipes:app
-site.zcml = <configure
-                xmlns="http://namespaces.zope.org/zope"
-                xmlns:browser="http://namespaces.zope.org/browser"
-                i18n_domain="zope">
-            <include package="zope.app.component" file="meta.zcml" />
-            <include package="zope.app.component.browser" file="meta.zcml" />
-            <include package="zope.app.form.browser" file="meta.zcml" />
-            <include package="zope.app.pagetemplate" file="meta.zcml" />
-            <include package="zope.app.publication" file="meta.zcml" />
-            <include package="zope.app.publisher" file="meta.zcml" />
-            <include package="zope.app.security" file="meta.zcml" />
-            <include package="zope.app.securitypolicy" file="meta.zcml" />
-            <include package="zope.rdb" file="meta.zcml" />
-            <include package="zope.viewlet" file="meta.zcml" />
-            <include package="z3c.form" file="meta.zcml" />
-            <include package="z3c.macro" file="meta.zcml" />
-            <include package="z3c.pagelet" file="meta.zcml" />
-            <include package="z3c.template" file="meta.zcml" />
-            <include package="z3c.zrtresource" file="meta.zcml" />
-            <include package="zc.resourcelibrary" file="meta.zcml" />
-
-            <browser:menu id="zmi_views" title="Views" />
-            <browser:menu id="zmi_actions" title="Actions" />
-
-            <include package="zope.app.appsetup" />
-            <include package="zope.app.component" />
-            <include package="zope.app.container" />
-            <include package="zope.app.error" />
-            <include package="zope.app.i18n" />
-            <include package="zope.app.intid" />
-            <include package="zope.app.publication" />
-            <include package="zope.app.security" />
-            <include package="zope.app.securitypolicy" />
-            <include package="zope.app.session" />
-            <include package="zope.app.twisted" />
-            <include package="zope.app.wsgi" />
-            <include package="zope.annotation" />
-            <include package="zope.component" />
-            <include package="zope.contentprovider" />
-            <include package="zope.location" />
-            <include package="zope.publisher" />
-            <include package="zope.rdb" />
-            <include package="zope.traversing" />
-            <include package="zope.traversing.browser" />
-            <include package="zope.viewlet" />
-
-            <include package="z3c.form" />
-            <include package="z3c.formui" />
-            <include package="z3c.layer.pagelet" />
-            <include package="z3c.macro" />
-            <include package="z3c.pagelet" />
-
-            <include package="zc.resourcelibrary" />
-            <include package="zc.table" />
-
-            <include package="grok" file="meta.zcml" />
-            <include package="grok" file="configure.zcml" />
-
-            <!--browser:defaultView name="index.html" /-->
-            <!--browser:defaultSkin name="Z3CFormDemo" /-->
-
-            <securityPolicy
-            component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
-            <role id="zope.Anonymous" title="Everybody" />
-            <grantAll role="zope.Anonymous" />
-            </configure>
-eggs = grok
-       martian
-
-[grok]
-recipe = zc.zope3recipes:instance
-application = grok-app
-zope.conf = ${database:zconfig}
-
-[database]
-recipe = zc.recipe.filestorage
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = grok
-       martian
-defaults = ['--tests-pattern', '^f?tests$',
-            '-v'
-           ]

Modified: grok/branches/darrylcousins-martian-layers/ftesting.zcml
===================================================================
--- grok/branches/darrylcousins-martian-layers/ftesting.zcml	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/ftesting.zcml	2007-06-28 04:35:50 UTC (rev 77161)
@@ -6,25 +6,30 @@
 
   <!-- This file is the equivalent of site.zcml and it is -->
   <!-- used for functional testing setup -->
+  <include package="zope.security" file="meta.zcml" />
+  <include package="zope.i18n" file="meta.zcml" />
+  <include package="zope.app.securitypolicy" file="meta.zcml" />
+  <include package="zope.app.zcmlfiles" file="meta.zcml" />
+  <include package="grok" file="meta.zcml" />
 
-  <!-- zope dependency includes -->
-  <include package="zope.app.securitypolicy" file="meta.zcml" />
-  <include package="zope.i18n" file="meta.zcml" />
-  <include package="zope.security" file="meta.zcml" />
-  <include package="zope.app.zcmlfiles" />
-  <include package="zope.app.securitypolicy" file="configure.zcml" />
-  <include package="zope.contentprovider" />
+  <include package="zope.annotation" />
+  <include package="zope.copypastemove" />
   <include package="zope.formlib" />
   <include package="zope.i18n.locales" />
+  <include package="zope.publisher" />
+  <include package="zope.size" />
+  <include package="zope.traversing" />
   <include package="zope.traversing.browser" />
+  <include package="zope.publisher" />
+  <include package="zope.app.zcmlfiles" />
+  <include package="zope.app.securitypolicy" />
   <include package="zope.app.authentication" />
   <include package="zope.app.catalog" />
   <include package="zope.app.intid" />
   <include package="zope.app.keyreference" />
   <include package="zope.app.twisted" />
-  <include package="zope.app.session" />
-  <include package="zope.viewlet" />
 
+  <!-- zope dependency includes -->
   <include package="zope.app.zcmlfiles" file="ftesting.zcml" />
 
   <!-- my friend the caveman -->

Modified: grok/branches/darrylcousins-martian-layers/setup.py
===================================================================
--- grok/branches/darrylcousins-martian-layers/setup.py	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/setup.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,26 +1,5 @@
-##############################################################################
-#
-# Copyright (c) 2007 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.
-#
-##############################################################################
-"""Setup
-
-$Id$
-"""
-import os
 from setuptools import setup, find_packages
 
-def read(*rnames):
-    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
 setup(
     name='grok',
     version='0.9',
@@ -31,37 +10,42 @@
     description='Grok: Now even cavemen can use Zope 3!',
     long_description=open('README.txt').read(),
     license='ZPL',
-    packages = find_packages('src'),
+
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
     include_package_data = True,
-    package_dir = {'':'src'},
-    dependency_links = ['http://download.zope.org/distribution'],
-    zip_safe = False,
-      install_requires=['setuptools',
-                        'zope.annotation',
-                        'zope.copypastemove',
-                        'zope.contentprovider',
-                        'zope.event',
-                        'zope.formlib',
-                        'zope.i18n',
-                        'zope.publisher',
-                        'zope.security',
-                        'zope.size',
-                        'zope.traversing',
-                        'zope.testbrowser',
-                        'zope.viewlet',
-                        'zope.app.securitypolicy',
-                        'zope.app.authentication',
-                        'zope.app.catalog',
-                        'zope.app.intid',
-                        'zope.app.keyreference',
-                        'zope.app.twisted',
-                        'zope.app.session',
-                        'zope.app.zcmlfiles',
-                        'zope.app.file',
-                        'simplejson',
-                        # -*- Extra requirements: -*-
-                        ],
-      entry_points="""
-      # -*- Entry points: -*-
-      """,
-    )
+    zip_safe=False,    
+    install_requires=['setuptools',
+                      'simplejson',
+                      'pytz',
+                      'ZODB3',
+                      'zope.annotation',
+                      'zope.app.catalog',
+                      'zope.app.component',
+                      'zope.app.container',
+                      'zope.app.folder',
+                      'zope.app.intid',
+                      'zope.app.pagetemplate',
+                      'zope.app.publication',
+                      'zope.app.publisher',
+                      'zope.app.testing',
+                      'zope.component',
+                      'zope.configuration',
+                      'zope.dottedname',
+                      'zope.event',
+                      'zope.formlib',
+                      'zope.interface',
+                      'zope.lifecycleevent',
+                      'zope.pagetemplate',
+                      'zope.publisher',
+                      'zope.schema',
+                      'zope.security',
+                      'zope.testing',
+                      'zope.traversing',
+
+                      # needed for ftests and typical deployments
+                      'zope.testbrowser',
+                      'zope.app.twisted',
+                      'zope.app.securitypolicy',
+                      'zope.app.zcmlfiles'],
+)

Deleted: grok/branches/darrylcousins-martian-layers/setup.py.1
===================================================================
--- grok/branches/darrylcousins-martian-layers/setup.py.1	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/setup.py.1	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,84 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 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.
-#
-##############################################################################
-"""Setup
-
-$Id: setup.py 77034 2007-06-25 12:57:23Z srichter $
-"""
-import os
-from setuptools import setup, find_packages
-
-def read(*rnames):
-    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-setup(
-    name='grok',
-    version='0.9',
-    author='Grok Team',
-    author_email='grok-dev at zope.org',
-    url='https://launchpad.net/grok',
-    download_url='svn://svn.zope.org/repos/main/grok/trunk#egg=grok-dev',
-    description='Grok: Now even cavemen can use Zope 3!',
-    long_description=open('README.txt').read(),
-    license='ZPL',
-    packages = find_packages('src'),
-    include_package_data = True,
-    package_dir = {'':'src'},
-    install_requires = [
-        'setuptools',
-        'z3c.csvvocabulary',
-        'z3c.form',
-        'z3c.formui',
-        'z3c.layer',
-        'z3c.pagelet',
-        'z3c.template',
-        'z3c.viewlet',
-        'z3c.zrtresource',
-        'zc.resourcelibrary',
-        'zc.table',
-        'zope.annotation',
-        'zope.app.container',
-        'zope.app.catalog',
-        'zope.app.intid',
-        'zope.app.pagetemplate',
-        'zope.app.rotterdam',
-        'zope.app.session',
-        'zope.app.appsetup',
-        'zope.app.authentication',
-        'zope.app.component',
-        'zope.app.container',
-        'zope.app.error',
-        'zope.app.form',
-        'zope.app.publisher',
-        'zope.app.publication',
-        'zope.app.security',
-        'zope.app.securitypolicy',
-        'zope.app.twisted',
-        'zope.app.wsgi',
-        'zope.app.zcmlfiles',
-        'zope.contentprovider',
-        'zope.component',
-        'zope.interface',
-        'zope.location',
-        'zope.pagetemplate',
-        'zope.publisher',
-        'zope.rdb',
-        'zope.schema',
-        'zope.testbrowser',
-        'zope.traversing',
-        'zope.viewlet',
-        'simplejson',
-        ],
-    dependency_links = ['http://download.zope.org/distribution'],
-    zip_safe = False,
-    )

Deleted: grok/branches/darrylcousins-martian-layers/setup.py.orig
===================================================================
--- grok/branches/darrylcousins-martian-layers/setup.py.orig	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/setup.py.orig	2007-06-28 04:35:50 UTC (rev 77161)
@@ -1,21 +0,0 @@
-from setuptools import setup, find_packages
-
-setup(
-    name='grok',
-    version='0.9',
-    author='Grok Team',
-    author_email='grok-dev at zope.org',
-    url='https://launchpad.net/grok',
-    download_url='svn://svn.zope.org/repos/main/grok/trunk#egg=grok-dev',
-    description='Grok: Now even cavemen can use Zope 3!',
-    long_description=open('README.txt').read(),
-    license='ZPL',
-
-    packages=find_packages('src'),
-    package_dir = {'': 'src'},
-    include_package_data = True,
-    zip_safe=False,    
-    install_requires=['setuptools',
-                      'martian',
-                      'simplejson'],
-)

Modified: grok/branches/darrylcousins-martian-layers/src/grok/__init__.py
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/__init__.py	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/src/grok/__init__.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -41,6 +41,7 @@
 from grok._grok import do_grok as grok  # Avoid name clash within _grok
 from grok._grok import grok_component
 from grok._grok import SubscribeDecorator as subscribe
+from grok._grok import adapter, implementer
 from martian.error import GrokError, GrokImportError
 from grok.formlib import action, AutoFields, Fields
 from grok.util import url

Modified: grok/branches/darrylcousins-martian-layers/src/grok/_grok.py
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/_grok.py	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/src/grok/_grok.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -15,6 +15,7 @@
 """
 import os
 import sys
+import types
 
 from zope import component
 from zope import interface
@@ -52,7 +53,7 @@
 
     # now grok the grokkers
     martian.grok_module(scan.module_info_from_module(meta), the_module_grokker)
-   
+
 def addSiteHandler(site, event):
     sitemanager = LocalSiteManager(site)
     # LocalSiteManager creates the 'default' folder in its __init__.
@@ -89,15 +90,15 @@
 
 def prepare_grok(name, module, kw):
     module_info = scan.module_info_from_module(module)
-    
+
     # XXX hardcoded in here which base classes are possible contexts
     # this should be made extensible
     possible_contexts = martian.scan_for_classes(module, [grok.Model,
                                                           grok.LocalUtility,
                                                           grok.Container])
     context = determine_module_context(module_info, possible_contexts)
-    
-    kw['context'] = context    
+
+    kw['context'] = context
     kw['module_info'] = module_info
     kw['templates'] = templatereg.TemplateRegistry()
 
@@ -137,3 +138,30 @@
         if subscribers is None:
             frame.f_locals['__grok_subscribers__'] = subscribers = []
         subscribers.append((function, self.subscribed))
+
+from zope.component._declaration import adapter as _adapter
+class adapter(_adapter):
+
+    def __init__(self, *interfaces):
+        # Override the z.c.adapter decorator to force sanity checking
+        # and have better error reporting.
+        if not interfaces:
+            raise GrokImportError(
+                "@grok.adapter requires at least one argument.")
+        if type(interfaces[0]) is types.FunctionType:
+            raise GrokImportError(
+                "@grok.adapter requires at least one argument.")
+        self.interfaces = interfaces
+
+from zope.interface.declarations import implementer as _implementer
+class implementer(_implementer):
+
+    def __call__(self, ob):
+        # XXX we do not have function grokkers (yet) so we put the annotation
+        # on the module.
+        frame = sys._getframe(1)
+        implementers = frame.f_locals.get('__implementers__', None)
+        if implementers is None:
+            frame.f_locals['__implementers__'] = implementers = []
+        implementers.append(ob)
+        return _implementer.__call__(self, ob)

Modified: grok/branches/darrylcousins-martian-layers/src/grok/meta.py
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/meta.py	2007-06-28 00:21:20 UTC (rev 77160)
+++ grok/branches/darrylcousins-martian-layers/src/grok/meta.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -60,7 +60,7 @@
                                  provides=provides,
                                  name=name)
         return True
-        
+
 class MultiAdapterGrokker(martian.ClassGrokker):
     component_class = grok.MultiAdapter
 
@@ -94,7 +94,7 @@
         methods = util.methods_from_class(factory)
 
         default_permission = get_default_permission(factory)
-        
+
         for method in methods:
             # Make sure that the class inherits MethodPublisher, so that the
             # views have a location
@@ -114,7 +114,7 @@
                                  default_permission)
             make_checker(factory, method_view, permission)
         return True
-    
+
 class ViewGrokker(martian.ClassGrokker):
     component_class = grok.View
 
@@ -184,7 +184,7 @@
         # protect view, public by default
         default_permission = get_default_permission(factory)
         make_checker(factory, factory, default_permission)
-    
+
         # safety belt: make sure that the programmer didn't use
         # @grok.require on any of the view's methods.
         methods = util.methods_from_class(factory)
@@ -195,8 +195,8 @@
                                 'for XML-RPC methods.'
                                 % (method.__name__, factory), factory)
         return True
-    
 
+
 class JSONGrokker(martian.ClassGrokker):
     component_class = grok.JSON
 
@@ -205,7 +205,7 @@
         methods = util.methods_from_class(factory)
 
         default_permission = get_default_permission(factory)
-        
+
         for method in methods:
             # Create a new class with a __view_name__ attribute so the
             # JSON class knows what method to call.
@@ -226,7 +226,7 @@
                                  default_permission)
             make_checker(factory, method_view, permission)
         return True
-    
+
 class TraverserGrokker(martian.ClassGrokker):
     component_class = grok.Traverser
 
@@ -236,14 +236,14 @@
                                  adapts=(factory_context, IBrowserRequest),
                                  provides=IBrowserPublisher)
         return True
-    
+
 class ModulePageTemplateGrokker(martian.InstanceGrokker):
     # this needs to happen before any other grokkers execute that actually
     # use the templates
     priority = 1000
 
     component_class = grok.PageTemplate
-    
+
     def grok(self, name, instance, context, module_info, templates):
         templates.register(name, instance)
         instance._annotateGrokInfo(name, module_info.dotted_name)
@@ -274,6 +274,21 @@
                 zope.component.interface.provideInterface('', iface)
         return True
 
+class AdapterDecoratorGrokker(martian.GlobalGrokker):
+
+    def grok(self, name, module, context, module_info, templates):
+        implementers = module_info.getAnnotation('implementers', [])
+        for function in implementers:
+            interfaces = getattr(function, '__component_adapts__', None)
+            if interfaces is None:
+                # There's no explicit interfaces defined, so we assume the
+                # module context to be the thing adapted.
+                util.check_context(module_info.getModule(), context)
+                interfaces = (context, )
+            component.provideAdapter(
+                function, adapts=interfaces, provides=function.__implemented__)
+        return True
+
 class StaticResourcesGrokker(martian.GlobalGrokker):
 
     def grok(self, name, module, context, module_info, templates):
@@ -443,10 +458,10 @@
 
     if setup is not None:
         setup(utility)
-        
+
     site_manager.registerUtility(utility, provided=provides,
                                  name=name)
-    
+
 class DefinePermissionGrokker(martian.GlobalGrokker):
 
     priority = 1500
@@ -464,10 +479,10 @@
                                      name=permission)
 
         return True
-    
+
 class AnnotationGrokker(martian.ClassGrokker):
     component_class = grok.Annotation
- 
+
     def grok(self, name, factory, context, module_info, templates):
         adapter_context = util.determine_class_context(factory, context)
         provides = util.class_annotation(factory, 'grok.provides', None)
@@ -513,7 +528,7 @@
                                       name='%s.%s' % (module_info.dotted_name,
                                                       name))
         return True
-    
+
 class IndexesGrokker(martian.InstanceGrokker):
     component_class = components.IndexesClass
 
@@ -535,14 +550,14 @@
             adapts=(site,
                     grok.IObjectAddedEvent))
         return True
-    
+
 class IndexesSetupSubscriber(object):
     def __init__(self, catalog_name, indexes, context, module_info):
         self.catalog_name = catalog_name
         self.indexes = indexes
         self.context = context
         self.module_info = module_info
-        
+
     def __call__(self, site, event):
         # make sure we have an intids
         self._createIntIds(site)
@@ -572,7 +587,7 @@
         catalog = Catalog()
         setupUtility(site, catalog, ICatalog, name=self.catalog_name)
         return catalog
-    
+
     def _createIntIds(self, site):
         """Create intids if needed, and return it.
         """

Copied: grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/adapterdecorator.py (from rev 77119, grok/branches/grok-martian/src/grok/tests/adapter/adapterdecorator.py)
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/adapterdecorator.py	                        (rev 0)
+++ grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/adapterdecorator.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -0,0 +1,71 @@
+"""
+  >>> grok.grok(__name__)
+  >>>
+  >>> cave = Cave()
+  >>> home = IHome(cave)
+  >>> IHome.providedBy(home)
+  True
+  >>>
+  >>> isinstance(home, Home)
+  True
+  >>> morehome = IMoreHome(cave)
+  >>> IHome.providedBy(morehome)
+  True
+  >>> isinstance(morehome, Home)
+  True
+  >>> yetanotherhome = IYetAnotherHome(cave)
+  >>> IHome.providedBy(yetanotherhome)
+  True
+  >>> isinstance(yetanotherhome, Home)
+  True
+
+  >>> from grok.tests.adapter import noarguments_fixture
+  Traceback (most recent call last):
+  ...
+  GrokImportError: @grok.adapter requires at least one argument.
+
+  >>> from grok.tests.adapter import functionasargument_fixture
+  Traceback (most recent call last):
+  ...
+  GrokImportError: @grok.adapter requires at least one argument.
+
+"""
+
+import grok
+from zope import interface
+
+class IDummy(interface.Interface):
+    pass
+
+class ICave(interface.Interface):
+    pass
+
+class IHome(interface.Interface):
+    pass
+
+class IMoreHome(interface.Interface):
+    pass
+
+class IYetAnotherHome(interface.Interface):
+    pass
+
+class Cave(grok.Model):
+    grok.implements(ICave)
+    pass
+
+class Home(object):
+    grok.implements(IHome)
+
+ at grok.adapter(Cave)
+ at grok.implementer(IHome)
+def home_for_cave(cave):
+    return Home()
+
+ at grok.adapter(ICave)
+ at grok.implementer(IMoreHome)
+def more_home_for_cave(cave):
+    return Home()
+
+ at grok.implementer(IYetAnotherHome)
+def yet_another_home_for_cave(cave):
+    return Home()

Copied: grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/functionasargument_fixture.py (from rev 77119, grok/branches/grok-martian/src/grok/tests/adapter/functionasargument_fixture.py)
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/functionasargument_fixture.py	                        (rev 0)
+++ grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/functionasargument_fixture.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -0,0 +1,10 @@
+import grok
+from zope import interface
+
+class IDummy(interface.Interface):
+    pass
+
+ at grok.adapter
+ at grok.implementer(IDummy)
+def decorator_called_with_function_as_argument(cave):
+    pass

Copied: grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/noarguments_fixture.py (from rev 77119, grok/branches/grok-martian/src/grok/tests/adapter/noarguments_fixture.py)
===================================================================
--- grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/noarguments_fixture.py	                        (rev 0)
+++ grok/branches/darrylcousins-martian-layers/src/grok/tests/adapter/noarguments_fixture.py	2007-06-28 04:35:50 UTC (rev 77161)
@@ -0,0 +1,10 @@
+import grok
+from zope import interface
+
+class IDummy(interface.Interface):
+    pass
+
+ at grok.adapter()
+ at grok.implementer(IDummy)
+def decorator_called_with_no_arguments(cave):
+    pass



More information about the Checkins mailing list