[Checkins] SVN: martian/branches/infrae-multiple-nobase/src/martian/directive. Actually create a test that tests the new behavior.

Martijn Faassen faassen at infrae.com
Fri Sep 19 08:27:31 EDT 2008


Log message for revision 91264:
  Actually create a test that tests the new behavior.
  

Changed:
  U   martian/branches/infrae-multiple-nobase/src/martian/directive.py
  U   martian/branches/infrae-multiple-nobase/src/martian/directive.txt

-=-
Modified: martian/branches/infrae-multiple-nobase/src/martian/directive.py
===================================================================
--- martian/branches/infrae-multiple-nobase/src/martian/directive.py	2008-09-19 11:16:19 UTC (rev 91263)
+++ martian/branches/infrae-multiple-nobase/src/martian/directive.py	2008-09-19 12:27:30 UTC (rev 91264)
@@ -56,12 +56,12 @@
 
 MULTIPLE = StoreMultipleTimes()
 
-class StoreMultipleTimesGetFromThisClassOnly(StoreMultipleTimes):
+class StoreMultipleTimesNoBase(StoreMultipleTimes):
 
     def get(self, directive, component, default):
         return component.__dict__.get(directive.dotted_name(), default)
 
-MULTIPLE_NOBASE = StoreMultipleTimesGetFromThisClassOnly()
+MULTIPLE_NOBASE = StoreMultipleTimesNoBase()
 
 class StoreDict(StoreOnce):
 
@@ -210,7 +210,6 @@
     store = MULTIPLE
     default = []
 
-
 class MarkerDirective(Directive):
     store = ONCE
     default = False

Modified: martian/branches/infrae-multiple-nobase/src/martian/directive.txt
===================================================================
--- martian/branches/infrae-multiple-nobase/src/martian/directive.txt	2008-09-19 11:16:19 UTC (rev 91263)
+++ martian/branches/infrae-multiple-nobase/src/martian/directive.txt	2008-09-19 12:27:30 UTC (rev 91264)
@@ -216,7 +216,25 @@
   >>> multi.bind().get(Qux)
   [u'Once', u'Twice', u'Triple']
 
+You can also create a directive that ignores the values on the base classes::
 
+  >>> from martian import MULTIPLE_NOBASE
+  >>> class multi(Directive):
+  ...     scope = CLASS
+  ...     store = MULTIPLE_NOBASE
+
+  >>> class Foo(object):
+  ...     multi(u"Once")
+  ...     multi(u"Twice")
+  >>> multi.bind().get(Foo)
+  [u'Once', u'Twice']
+
+  >>> class Qux(Foo):
+  ...     multi(u'Triple')
+  ...     multi(u'More')
+  >>> multi.bind().get(Qux)
+  [u'Triple', u'More']
+
 Using a directive multiple times, as a dictionary
 -------------------------------------------------
 



More information about the Checkins mailing list