[Checkins] SVN: grok/trunk/src/grok/ Test that you can also pass in
an interface instead of a class for grok.context.
Philipp von Weitershausen
philikon at philikon.de
Sun Oct 15 06:31:21 EDT 2006
Log message for revision 70632:
Test that you can also pass in an interface instead of a class for grok.context.
Changed:
U grok/trunk/src/grok/adapter.txt
A grok/trunk/src/grok/tests/interface.py
-=-
Modified: grok/trunk/src/grok/adapter.txt
===================================================================
--- grok/trunk/src/grok/adapter.txt 2006-10-15 00:08:05 UTC (rev 70631)
+++ grok/trunk/src/grok/adapter.txt 2006-10-15 10:31:19 UTC (rev 70632)
@@ -198,3 +198,29 @@
Traceback (most recent call last):
...
GrokError: grok.context can only be used on class or module level.
+
+Clean up:
+
+ >>> cleanUp()
+
+You can also specify interfaces instead of classes with
+`grok.context`:
+
+ >>> grok.grok('grok.tests.interface')
+
+ >>> from grok.tests.interface import IHome, Home, Cave, Hole
+ >>> cave = Cave()
+ >>> home = IHome(cave)
+
+ >>> IHome.providedBy(home)
+ True
+ >>> isinstance(home, Home)
+ True
+
+ >>> hole = Hole()
+ >>> home = IHome(hole)
+
+ >>> IHome.providedBy(home)
+ True
+ >>> isinstance(home, Home)
+ True
Added: grok/trunk/src/grok/tests/interface.py
===================================================================
--- grok/trunk/src/grok/tests/interface.py 2006-10-15 00:08:05 UTC (rev 70631)
+++ grok/trunk/src/grok/tests/interface.py 2006-10-15 10:31:19 UTC (rev 70632)
@@ -0,0 +1,18 @@
+import grok
+from zope import interface
+
+class ICave(interface.Interface):
+ pass
+
+class Cave(grok.Model):
+ grok.implements(ICave)
+
+class Hole(grok.Model):
+ grok.implements(ICave)
+
+class IHome(interface.Interface):
+ pass
+
+class Home(grok.Adapter):
+ grok.implements(IHome)
+ grok.context(ICave)
Property changes on: grok/trunk/src/grok/tests/interface.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list