[Checkins] SVN: grokcore.annotation/trunk/s Fix tests and dependency information.

Sylvain Viollon sylvain at infrae.com
Tue Jun 16 05:24:59 EDT 2009


Log message for revision 101063:
  Fix tests and dependency information.
  
  

Changed:
  U   grokcore.annotation/trunk/setup.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/__init__.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/components.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/ftesting.zcml
  U   grokcore.annotation/trunk/src/grokcore/annotation/testing.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/util.py

-=-
Modified: grokcore.annotation/trunk/setup.py
===================================================================
--- grokcore.annotation/trunk/setup.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/setup.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -38,7 +38,9 @@
                       'zope.interface',
                       'zope.annotation',
                       'grokcore.component',
-                      # for ftests:
-                      'z3c.testsetup',
+                      'ZODB3',
+                      'zope.app.container',
+                      'zope.configuration',
+                      'zope.testing',
                       ],
-)
+    )

Modified: grokcore.annotation/trunk/src/grokcore/annotation/__init__.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/__init__.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/__init__.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -16,11 +16,11 @@
 
 from grokcore.component import *
 
-from grokcore.annotation.components import Annotation
+from grokcore.annotation.components import Annotation, Model
 
 # BBB These two functions are meant for test fixtures and should be
 # imported from grok.testing, not from grok.
-from grokcore.annotation.testing import grok, grok_component
+from grokcore.annotation.testing import grok
 
 # Our __init__ provides the grok API directly so using 'import grok' is enough.
 from grokcore.annotation.interfaces import IGrokcoreAnnotationAPI

Modified: grokcore.annotation/trunk/src/grokcore/annotation/components.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -14,8 +14,18 @@
 """Base classes for Grok application components.
 
 """
+
+from zope.annotation.interfaces import IAttributeAnnotatable
 import persistent
+import grokcore.component
 
 
+class Model(grokcore.component.Context):
+    """Base class for an object which is able to handle annotations
+    """
+    grokcore.component.implements(IAttributeAnnotatable)
+
+
 class Annotation(persistent.Persistent):
-    """The base class for annotation classes in Grok applications."""
+    """The base class for annotation classes in Grok applications.
+    """

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/ftesting.zcml
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/ftesting.zcml	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/ftesting.zcml	2009-06-16 09:24:59 UTC (rev 101063)
@@ -1,35 +0,0 @@
-<configure
-   xmlns="http://namespaces.zope.org/zope"
-   xmlns:grok="http://namespaces.zope.org/grok"
-   i18n_domain="grok"
-   package="grok"
-   >
-
-  <include package="grok" />
-  <grok:grok package="grok.ftests" />
-
-  <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>

Modified: grokcore.annotation/trunk/src/grokcore/annotation/testing.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/testing.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/testing.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -14,31 +14,10 @@
 """Grok test helpers
 """
 import sys
-import os.path
-import z3c.testsetup
 from zope.configuration.config import ConfigurationMachine
 from grokcore.component import zcml
 # Provide this import here for BBB reasons:
-from grokcore.component.testing import grok_component
 
-class GrokTestCollector(z3c.testsetup.TestCollector):
-
-    def initialize(self):
-        # inject the grok ftesting ZCML as fallback...
-        if 'zcml_config' in self.settings.keys():
-            return
-        pkg_path = os.path.dirname(self.package.__file__)
-        if os.path.isfile(os.path.join(pkg_path, 'ftesting.zcml')):
-            return
-        self.settings['zcml_config'] = os.path.join(
-            os.path.dirname(__file__), 'ftesting.zcml')
-        if 'layer_name' in self.settings.keys():
-            return
-        self.settings['layer_name'] = 'GrokFunctionalLayer'
-
-def register_all_tests(pkg, *args, **kw):
-    return GrokTestCollector(pkg, *args, **kw)
-
 def grok(module_name):
     config = ConfigurationMachine()
     zcml.do_grok('grokcore.component.meta', config)

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -6,7 +6,7 @@
   >>> grok.testing.grok(__name__)
   Traceback (most recent call last):
   GrokError: <class
-  'grok.tests.annotation.implementsmany.MammothAnnotations'> is
+  'grokcore.annotation.tests.annotation.implementsmany.MammothAnnotations'> is
   implementing more than one interface (use grok.provides to specify
   which one to use).
 """

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -5,7 +5,7 @@
 
   >>> grok.testing.grok(__name__)
   Traceback (most recent call last):
-  GrokError: <class 'grok.tests.annotation.implementsnone.Branding'>
+  GrokError: <class 'grokcore.annotation.tests.annotation.implementsnone.Branding'>
   must implement at least one interface (use grok.implements to
   specify).
 

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -11,7 +11,8 @@
   >>> ann = IImplicitName(manfred)
 
   >>> from zope.annotation.interfaces import IAnnotations
-  >>> 'grok.tests.annotation.name.ImplicitName' in IAnnotations(manfred)
+  >>> availables_ann = IAnnotations(manfred)
+  >>> 'grokcore.annotation.tests.annotation.name.ImplicitName' in availables_ann
   True
 
 Of course, annotation classes can explicity specify the name of the
@@ -21,7 +22,8 @@
 the dotted name will obviously change)
 
   >>> ann = IExplicitName(manfred)
-  >>> 'grok.tests.annotation.name.ExplicitName' in IAnnotations(manfred)
+  >>> availables_ann = IAnnotations(manfred)
+  >>> 'grokcore.annotation.tests.annotation.name.ExplicitName' in availables_ann
   False
   >>> 'mammoth.branding' in IAnnotations(manfred)
   True

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -14,7 +14,7 @@
 
   >>> IAnotherOne(manfred)
   Traceback (most recent call last):
-  TypeError: ('Could not adapt', <grok.tests.annotation.provides.Mammoth object at ...>, <InterfaceClass grok.tests.annotation.provides.IAnotherOne>)
+  TypeError: ('Could not adapt', <grokcore.annotation.tests.annotation.provides.Mammoth object at ...>, <InterfaceClass grokcore.annotation.tests.annotation.provides.IAnotherOne>)
 
 
 """

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/util.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/util.py	2009-06-16 09:13:02 UTC (rev 101062)
+++ grokcore.annotation/trunk/src/grokcore/annotation/util.py	2009-06-16 09:24:59 UTC (rev 101063)
@@ -1,58 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok utility functions.
-"""
-import zope.location.location
-from zope import interface
-from zope.security.checker import NamesChecker, defineChecker
-
-from grokcore.security.util import check_permission
-
-def make_checker(factory, view_factory, permission, method_names=None):
-    """Make a checker for a view_factory associated with factory.
-
-    These could be one and the same for normal views, or different
-    in case we make method-based views such as for JSON and XMLRPC.
-    """
-    if method_names is None:
-        method_names = ['__call__']
-    if permission is not None:
-        check_permission(factory, permission)
-    if permission is None or permission == 'zope.Public':
-        checker = NamesChecker(method_names)
-    else:
-        checker = NamesChecker(method_names, permission)
-    defineChecker(view_factory, checker)
-
-def safely_locate_maybe(obj, parent, name):
-    """Set an object's __parent__ (and __name__) if the object's
-    __parent__ attribute doesn't exist yet or is None.
-
-    If the object provides ILocation, __parent__ and __name__ will be
-    set directly.  A location proxy will be returned otherwise.
-    """
-    if getattr(obj, '__parent__', None) is not None:
-        return obj
-    # This either sets __parent__ or wraps 'obj' in a LocationProxy
-    return zope.location.location.located(obj, parent, name)
-
-def applySkin(request, skin, skin_type):
-    """Change the presentation skin for this request.
-    """
-    # Remove all existing skin declarations (commonly the default skin).
-    ifaces = [iface for iface in interface.directlyProvidedBy(request)
-              if not skin_type.providedBy(iface)]
-    # Add the new skin.
-    ifaces.append(skin)
-    interface.directlyProvides(request, *ifaces)



More information about the Checkins mailing list