Zope Subversion Repository

  Zope

Zope: martian/branches/jw-philipp-using-ndir-directives/src/martian/directive.txt

Diff for /martian/branches/jw-philipp-using-ndir-directives/src/martian/directive.txt between version 86262 and 86264

version 86262, Sat May 3 18:19:38 2008 UTC version 86264, Sat May 3 18:41:27 2008 UTC
Line 195 
Line 195 
   []    []
   
 Whenever the directive is used on a sub class of a component, the values set by  Whenever the directive is used on a sub class of a component, the values set by
 directives on the base classes are concatenated::  directives on the base classes are combined::
   
   >>> class Qux(Foo):    >>> class Qux(Foo):
   ...     multi(u'Triple')    ...     multi(u'Triple')
Line 258 
Line 258 
   GrokImportError: The factory method for the 'wrongmulti2' directive should    GrokImportError: The factory method for the 'wrongmulti2' directive should
   return a key-value pair.    return a key-value pair.
   
   Like with MULTIPLE store, values set by directives using the DICT store are
   combined::
   
   >>> class multi(Directive):    >>> class multi(Directive):
   ...     scope = CLASS    ...     scope = CLASS
   ...     store = DICT    ...     store = DICT
Line 277 
Line 280 
   >>> print sorted(d.items())    >>> print sorted(d.items())
   [(1, 'CCC'), (2, 'BBB'), (3, 'DDD'), (4, 'EEE')]    [(1, 'CCC'), (2, 'BBB'), (3, 'DDD'), (4, 'EEE')]
   
   Using MULTIPLE and DICT can also work on a module level, even though
   inheritance has no meaning there::
   
     >>> from martian import MODULE
     >>> class multi(MultipleTimesDirective):
     ...     scope = MODULE
     ...
     >>> multi.__module__ = 'somethingelse'
     >>> class module_with_directive(FakeModule):
     ...     fake_module = True
     ...
     ...     multi('One')
     ...     multi('Two')
     ...
     >>> module_with_directive = fake_import(module_with_directive)
     >>> print multi.get(module_with_directive)
     ['One', 'Two']
   
     >>> from martian import MODULE
     >>> class multi(Directive):
     ...     scope = MODULE
     ...     store = DICT
     ...     def factory(self, value, andanother):
     ...         return value, andanother
     ...
     >>> multi.__module__ = 'somethingelse'
     >>> class module_with_directive(FakeModule):
     ...     fake_module = True
     ...
     ...     multi(1, 'One')
     ...     multi(2, 'Two')
     ...
     >>> module_with_directive = fake_import(module_with_directive)
     >>> d = multi.get(module_with_directive)
     >>> print sorted(d.items())
     [(1, 'One'), (2, 'Two')]
   
 Calculated defaults  Calculated defaults
 -------------------  -------------------
   


Generate output suitable for use with a patch program
Legend:
Removed from v.86262  
changed lines
  Added in v.86264

webmaster@zope.org

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help