[Checkins]
SVN: grok/branches/jw-simpler-skin-registration/src/grok/
Improve wording and wrapping of test.
Philipp von Weitershausen
philikon at philikon.de
Fri Aug 1 09:34:28 EDT 2008
Log message for revision 89148:
Improve wording and wrapping of test.
Make sure the skin directive validates its arguments (it needs to be text). Test that.
Changed:
U grok/branches/jw-simpler-skin-registration/src/grok/directive.py
U grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive.py
A grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive_textonly_fixture.py
-=-
Modified: grok/branches/jw-simpler-skin-registration/src/grok/directive.py
===================================================================
--- grok/branches/jw-simpler-skin-registration/src/grok/directive.py 2008-08-01 13:19:16 UTC (rev 89147)
+++ grok/branches/jw-simpler-skin-registration/src/grok/directive.py 2008-08-01 13:34:27 UTC (rev 89148)
@@ -221,10 +221,9 @@
def setattr(self, context, directive, value):
context.setTaggedValue(directive.dotted_name(), value)
-TAGGEDVALUEONCE = TaggedValueStoreOnce()
-
class skin(martian.Directive):
# We cannot do any better than to check for a class scope. Ideally we
# would've checked whether the context is indeed an Interface class.
scope = martian.CLASS
- store = TAGGEDVALUEONCE
+ store = TaggedValueStoreOnce()
+ validate = martian.validateText
Modified: grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive.py
===================================================================
--- grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive.py 2008-08-01 13:19:16 UTC (rev 89147)
+++ grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive.py 2008-08-01 13:34:27 UTC (rev 89148)
@@ -1,34 +1,42 @@
"""
The skin directive is used to trigger the registration of a layer as a
-IBrowserSkin type. Since layers are really interface classes, we need a special
-directive implementation that will take care of storing data on the interface.
+IBrowserSkin type. Since layers are really interface classes, we need
+a special directive implementation that will take care of storing data
+on the interface.
-Import - and thus "execute" the skindirective fixture to make the directive
-have effect::
+Import -- and thus "execute" -- the skindirective fixture to make the
+directive have effect::
- >>> from grok.tests.skin import directive_fixture
+ >>> from grok.tests.skin import directive_fixture
- >>> import grok
- >>> grok.skin.bind().get(directive_fixture.IIsAnInterface)
- 'skin_name'
+ >>> import grok
+ >>> grok.skin.bind().get(directive_fixture.IIsAnInterface)
+ 'skin_name'
-Unfortunately it is not possible to check whether the directive isn't used on a
-"normal" class instead of an interface class. This means, the directive can be
-*declared* on a normal class, however, using it to retrieve data will fail due
-to the way the directive's store is implemented::
+Unfortunately it is not possible to check whether the directive isn't
+used on a "normal" class instead of an interface class. This means, the
+directive can be *declared* on a normal class, however, using it to
+retrieve data will fail due to the way the directive's store is
+implemented::
- >>> from grok.tests.skin import directive_onaclass_fixture
+ >>> from grok.tests.skin import directive_onaclass_fixture
- >>> print grok.skin.bind().get(
- ... directive_onaclass_fixture.NotAnInterfaceClass)
- Traceback (most recent call last):
+ >>> grok.skin.bind().get(directive_onaclass_fixture.NotAnInterfaceClass)
+ Traceback (most recent call last):
...
- AttributeError: type object 'NotAnInterfaceClass' has no attribute
- 'queryTaggedValue'
+ AttributeError: type object 'NotAnInterfaceClass' has no attribute
+ 'queryTaggedValue'
-In certain cases we need to set a value on a component as if the directive was
-actually used::
+Note that the directive only supports text (ASCII string or unicode):
+ >>> from grok.tests.skin import directive_textonly_fixture
+ Traceback (most recent call last):
+ ...
+ GrokImportError: The 'skin' directive can only be called with unicode or ASCII.
+
+In certain cases we need to set a value on a component as if the directive
+was actually used::
+
>>> from zope import interface
>>> class IFoo(interface.Interface):
... pass
Added: grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive_textonly_fixture.py
===================================================================
--- grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive_textonly_fixture.py (rev 0)
+++ grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive_textonly_fixture.py 2008-08-01 13:34:27 UTC (rev 89148)
@@ -0,0 +1,7 @@
+import grok
+from zope.interface import Interface
+
+some_obj = object()
+
+class BogusSkin(Interface):
+ grok.skin(some_obj)
Property changes on: grok/branches/jw-simpler-skin-registration/src/grok/tests/skin/directive_textonly_fixture.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list