[Checkins] SVN: zc.recipe.macro/branches/aaron-merge-infrae/ Fixed a ReST error in the setup.py, and implemented the following order of

Aaron Lehmann aaron at zope.com
Sun Mar 8 01:42:08 EST 2009


Log message for revision 97644:
  Fixed a ReST error in the setup.py, and implemented the following order of
  precedence for getting the recipe of result sections.
  
      1) recipe in the parameters section of the macro target
      2) result-recipe in the parameters section for the macro target
      3) result-recipe in the macro invocation
      4) recipe in the macro definition
  
  

Changed:
  U   zc.recipe.macro/branches/aaron-merge-infrae/CHANGES.txt
  U   zc.recipe.macro/branches/aaron-merge-infrae/setup.py
  U   zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/QUICKSTART.txt
  U   zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/README.txt
  U   zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/recipe.py

-=-
Modified: zc.recipe.macro/branches/aaron-merge-infrae/CHANGES.txt
===================================================================
--- zc.recipe.macro/branches/aaron-merge-infrae/CHANGES.txt	2009-03-07 22:26:44 UTC (rev 97643)
+++ zc.recipe.macro/branches/aaron-merge-infrae/CHANGES.txt	2009-03-08 06:42:07 UTC (rev 97644)
@@ -1,6 +1,20 @@
 CHANGES
 =======
 
+1.2.6 (unreleased)
+------------------
+
+- The recipe option for result sections is now pulled from the following
+  sources, in this order:
+
+    1) recipe in the parameters section of the macro target
+    2) result-recipe in the parameters section for the macro target
+    3) result-recipe in the macro invocation
+    4) recipe in the macro definition
+
+- Correct a rest error, that prevent the package of being installed with
+  docutils 0.4.
+
 1.2.5 (2009-03-05)
 ------------------
 

Modified: zc.recipe.macro/branches/aaron-merge-infrae/setup.py
===================================================================
--- zc.recipe.macro/branches/aaron-merge-infrae/setup.py	2009-03-07 22:26:44 UTC (rev 97643)
+++ zc.recipe.macro/branches/aaron-merge-infrae/setup.py	2009-03-08 06:42:07 UTC (rev 97644)
@@ -75,7 +75,10 @@
 ENTRY_POINTS = """
 [zc.buildout]
 default = zc.recipe.macro:Macro
-test = zc.recipe.macro:Test
+test1 = zc.recipe.macro:Test
+test2 = zc.recipe.macro:Test
+test3 = zc.recipe.macro:Test
+test4 = zc.recipe.macro:Test
 empty = zc.recipe.macro:Empty
 """
 

Modified: zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/QUICKSTART.txt
===================================================================
--- zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/QUICKSTART.txt	2009-03-07 22:26:44 UTC (rev 97643)
+++ zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/QUICKSTART.txt	2009-03-08 06:42:07 UTC (rev 97644)
@@ -77,14 +77,14 @@
 
     [hard-rocker]
     recipe = zc.recipe.macro
-    result-recipe = zc.recipe.macro:test
+    result-recipe = zc.recipe.macro:test1
     macro = rock
     rocking-style = so hard
 
 Result::
 
     [hard-rocker]
-    recipe = zc.recipe.macro:test
+    recipe = zc.recipe.macro:test1
     result-sections = hard-rocker
     question = Why do I rock so hard?
     rocking-style = so hard
@@ -171,7 +171,7 @@
 
     [rockers]
     recipe = zc.recipe.macro
-    result-recipe = zc.recipe.macro:test
+    result-recipe = zc.recipe.macro:test1
     macro = rock
     targets =
         hard-rocker:hard-rocker-parameters
@@ -180,22 +180,151 @@
 
 Result::
 
+    [rockers]
+    result-sections = hard-rocker socks-rocker tired-rocker
+
     [hard-rocker]
     question = Why do I rock so hard?
-    recipe = zc.recipe.macro:test
+    recipe = zc.recipe.macro:test1
     rocking-style = so hard
 
     [socks-rocker]
     question = Why do I rock my socks?
-    recipe = zc.recipe.macro:test
+    recipe = zc.recipe.macro:test1
     rocking-style = my socks
 
     [tired-rocker]
     question = Why do I rock all night?
-    recipe = zc.recipe.macro:test
+    recipe = zc.recipe.macro:test1
     rocking-style = all night
 
 
+Order of Precedence for Recipes for Result Sections
+---------------------------------------------------
+
+The source for the `recipe` option for result sections has a particular
+precedence, as follows::
+
+    1) recipe in the parameters section of the macro target
+    2) result-recipe in the parameters section for the macro target
+    3) result-recipe in the macro invocation
+    4) recipe in the macro definition
+
+The following tests will illustrate these rules, starting with rule 4 and
+building up.
+
+In the following buildout, rock:recipe will be used in the [hard-rockers]
+section as the recipe, because of rule 4.
+Buildout::
+
+    [buildout]
+    parts = rockers
+
+    [rock]
+    question = Why do I rock $${:rocking-style}?
+    rocking-style = $${:rocking-style}
+    recipe = zc.recipe.macro:test4
+
+    [hard-rocker-parameters]
+    rocking-style = so hard
+
+    [rockers]
+    recipe = zc.recipe.macro
+    macro = rock
+    targets = hard-rocker:hard-rocker-parameters
+
+Result::
+
+    [hard-rocker]
+    question = Why do I rock so hard?
+    recipe = zc.recipe.macro:test4
+    rocking-style = so hard
+
+In the following buildout, ${rockers:result-recipe} will be used because of rule 3.
+Buildout::
+
+    [buildout]
+    parts = rockers
+
+    [rock]
+    question = Why do I rock $${:rocking-style}?
+    rocking-style = $${:rocking-style}
+    recipe = zc.recipe.macro:test4
+
+    [hard-rocker-parameters]
+    rocking-style = so hard
+
+    [rockers]
+    recipe = zc.recipe.macro
+    result-recipe = zc.recipe.macro:test3
+    macro = rock
+    targets = hard-rocker:hard-rocker-parameters
+
+Result::
+
+    [hard-rocker]
+    question = Why do I rock so hard?
+    recipe = zc.recipe.macro:test3
+    rocking-style = so hard
+
+In the following buildout, ${hard-rocker-paramers:result-recipe} will be used because of rule 2.
+Buildout::
+
+    [buildout]
+    parts = rockers
+
+    [rock]
+    question = Why do I rock $${:rocking-style}?
+    rocking-style = $${:rocking-style}
+    recipe = zc.recipe.macro:test4
+
+    [hard-rocker-parameters]
+    result-recipe = zc.recipe.macro:test2
+    rocking-style = so hard
+
+    [rockers]
+    recipe = zc.recipe.macro
+    result-recipe = zc.recipe.macro:test3
+    macro = rock
+    targets = hard-rocker:hard-rocker-parameters
+
+Result::
+
+    [hard-rocker]
+    question = Why do I rock so hard?
+    recipe = zc.recipe.macro:test2
+    rocking-style = so hard
+
+In the following buildout, ${hard-rocker-parameters:recipe} will be used because of rule 1.
+Buildout::
+
+    [buildout]
+    parts = rockers
+
+    [rock]
+    question = Why do I rock $${:rocking-style}?
+    rocking-style = $${:rocking-style}
+    recipe = zc.recipe.macro:test4
+
+    [hard-rocker-parameters]
+    recipe = zc.recipe.macro:test1
+    result-recipe = zc.recipe.macro:test2
+    rocking-style = so hard
+
+    [rockers]
+    recipe = zc.recipe.macro
+    result-recipe = zc.recipe.macro:test3
+    macro = rock
+    targets = hard-rocker:hard-rocker-parameters
+
+Result::
+
+    [hard-rocker]
+    question = Why do I rock so hard?
+    recipe = zc.recipe.macro:test1
+    rocking-style = so hard
+
+
 Special Variables
 -----------------
 

Modified: zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/README.txt
===================================================================
--- zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/README.txt	2009-03-07 22:26:44 UTC (rev 97643)
+++ zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/README.txt	2009-03-08 06:42:07 UTC (rev 97644)
@@ -38,14 +38,14 @@
 
     [instance0]
     recipe = zc.recipe.macro
-    result-recipe = zc.recipe.macro:test
+    result-recipe = zc.recipe.macro:test1
     macro = instance-macro
     address = 8080
     monitor-port = 8089
 
     [instance1]
     recipe = zc.recipe.macro
-    result-recipe = zc.recipe.macro:test
+    result-recipe = zc.recipe.macro:test1
     macro = instance-macro
     address = 9080
     monitor-port = 9089
@@ -56,7 +56,7 @@
 - These parts in turn specified that they would be using the
   macro system: ``recipe = zc.recipe.macro``.
 
-- The output of the macro should be used with the ``zc.recipe.macro:test``
+- The output of the macro should be used with the ``zc.recipe.macro:test1``
   recipe, as specified by the ``result-recipe`` option.
 
 - This resulting recipe will receive the ``address`` option from the two
@@ -337,7 +337,7 @@
 
     [instance0]
     recipe = zc.recipe.macro
-    result-recipe = zc.recipe.macro:test
+    result-recipe = zc.recipe.macro:test1
     macro = instance-macro
 
 Result::
@@ -346,7 +346,7 @@
     address = 8080
     application = application
     monitor-port = 8089
-    recipe = zc.recipe.macro:test
+    recipe = zc.recipe.macro:test1
     result-sections = instance0
     zope.conf =
         <eventlog>
@@ -421,7 +421,7 @@
     ...
     ... [instance0]
     ... recipe = zc.recipe.macro
-    ... result-recipe = zc.recipe.macro:test
+    ... result-recipe = zc.recipe.macro:test1
     ... macro = instance-macro
     ... """)
     >>> buildout.install([])
@@ -442,7 +442,7 @@
      'instance0': {'address': '8080',
                    'application': 'application',
                    'monitor-port': '8089',
-                   'recipe': 'zc.recipe.macro:test',
+                   'recipe': 'zc.recipe.macro:test1',
                    'result-sections': 'instance0',
                    'zope.conf': '
             <eventlog>

Modified: zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/recipe.py
===================================================================
--- zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/recipe.py	2009-03-07 22:26:44 UTC (rev 97643)
+++ zc.recipe.macro/branches/aaron-merge-infrae/src/zc/recipe/macro/recipe.py	2009-03-08 06:42:07 UTC (rev 97644)
@@ -35,7 +35,7 @@
             new_macro[key] = c_re.sub(
                 replace_match, value.replace('$${:__name__}', name))
     if recipe:
-        new_macro['recipe'] = new_macro.get('recipe', recipe)
+        new_macro['recipe'] = recipe
     return new_macro
 
 def parse_target(invoker, target):
@@ -44,9 +44,21 @@
         target, input_section = target.split(':')
     return target, input_section
 
+def get_recipe(invocation_section, macro_section, parameter_section, default=None):
+    if 'recipe' in parameter_section:
+        return parameter_section['recipe']
+    elif 'result-recipe' in parameter_section:
+        return parameter_section['result-recipe']
+    elif 'result-recipe' in invocation_section:
+        return invocation_section['result-recipe']
+    elif 'recipe' in macro_section:
+        return macro_section['recipe']
+    else:
+        return default
+
+
 def Macro(buildout, name, options):
     del options['recipe']
-    recipe = options.pop('result-recipe', '')
     macro = options.pop('macro').strip()
     targets = options.pop('targets', name).strip().split()
     macro_summation = {}
@@ -55,12 +67,14 @@
 
     new_sections = []
     for output, input in (parse_target(name, target) for target in targets):
+        recipe = get_recipe(options, macro_summation, buildout[input])
         new_sections.append(output)
         opt = Options(
                 buildout,
                 output,
                 evaluate_macro(
                     buildout, output, macro_summation, input, recipe))
+        opt.pop('result-recipe', '')
         if output == name:
             # If we're targetting the invoker
             options._raw.update(opt._raw)
@@ -68,7 +82,7 @@
         else:
             # If we're targetting some other section
             buildout._raw[output] = opt._raw
-            #opt._initialize()
+    options.pop('result-recipe', '')
 
     #Make a result-sections variable holding the sections that are modified
     if new_sections:
@@ -116,3 +130,5 @@
 
     def uninstall(self):
         pass
+
+



More information about the Checkins mailing list