[Checkins] SVN: grok/branches/regebro-guido-templates/ Wrote the test.

Lennart Regebro regebro at gmail.com
Fri Oct 5 08:52:15 EDT 2007


Log message for revision 80639:
  Wrote the test.
  

Changed:
  U   grok/branches/regebro-guido-templates/CHANGES.txt
  U   grok/branches/regebro-guido-templates/src/grok/tests/utility/utility.py

-=-
Modified: grok/branches/regebro-guido-templates/CHANGES.txt
===================================================================
--- grok/branches/regebro-guido-templates/CHANGES.txt	2007-10-05 12:47:32 UTC (rev 80638)
+++ grok/branches/regebro-guido-templates/CHANGES.txt	2007-10-05 12:52:15 UTC (rev 80639)
@@ -9,7 +9,6 @@
 
 * There is now a grok.direct() directive that can be used on GlobalUtilities to 
   mark that the class provides the utility directly and need no instantiation.
-  (XXX no test written yet /regebro)
   
 * Integrated skins and layers. grok.layer, grok.IGrokLayer, grok.Skin 
 

Modified: grok/branches/regebro-guido-templates/src/grok/tests/utility/utility.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/tests/utility/utility.py	2007-10-05 12:47:32 UTC (rev 80638)
+++ grok/branches/regebro-guido-templates/src/grok/tests/utility/utility.py	2007-10-05 12:52:15 UTC (rev 80639)
@@ -39,6 +39,16 @@
   >>> isinstance(nightclub, NightClub)
   True
 
+You can make the class the utility by providing the grok.direct() directive,
+if you also use interface.classProvides instead of grok.provides.
+This is useful for utilities that do nothing but create instances:
+
+  >>> clubmaker = component.getUtility(IClubMaker)
+  >>> IClubMaker.providedBy(clubmaker)
+  True
+  >>> clubmaker is ClubMaker
+  True
+
 Utilities (including classes that do not subclass from grok.GlobalUtility) can
 be (re-)registered using grok.global_utility:
 
@@ -133,6 +143,9 @@
 class INightClub(interface.Interface):
     pass
 
+class IClubMaker(interface.Interface):
+    pass
+
 class NormalClub(grok.GlobalUtility):
     grok.implements(IClub)
 
@@ -154,6 +167,11 @@
     grok.provides(ISmallClub)
     grok.name('tiny')
 
+class ClubMaker(grok.GlobalUtility):
+    grok.implements(IClub)
+    interface.classProvides(IClubMaker)
+    grok.direct()
+
 class IFireplace(interface.Interface):
     pass
 



More information about the Checkins mailing list