Commit b8e599fd authored by Tres Seaver's avatar Tres Seaver

Merge pull request #161 from Goldmund-Wyldebeast-Wunderliebe/master

Simple Fix for 'Extending sections (macros)' in combination with += and -=.
parents 5a606452 200fa79a
...@@ -14,6 +14,9 @@ When you're developing buildout itself, you need to know two things: ...@@ -14,6 +14,9 @@ When you're developing buildout itself, you need to know two things:
- Don't bootstrap with ``python bootstrap/bootstrap.py`` but with ``python - Don't bootstrap with ``python bootstrap/bootstrap.py`` but with ``python
dev.py``. dev.py``.
- Run buildout with -U, to ignore user (default) settings which can interfere
with using the development version
For your convenience we provide a Makefile to build various Python versions For your convenience we provide a Makefile to build various Python versions
in subdirectories of the buildout checkout. To use these and run the tests in subdirectories of the buildout checkout. To use these and run the tests
with them do:: with them do::
......
...@@ -1269,7 +1269,10 @@ class Options(DictMixin): ...@@ -1269,7 +1269,10 @@ class Options(DictMixin):
raise zc.buildout.UserError("No section named %r" % iname) raise zc.buildout.UserError("No section named %r" % iname)
result.update(self._do_extend_raw(iname, raw, doing)) result.update(self._do_extend_raw(iname, raw, doing))
result.update(data) result = _annotate_section(result, "")
data = _annotate_section(data.copy(), "")
_update_section(result, data)
result = _unannotate_section(result)
result.pop('<', None) result.pop('<', None)
return result return result
finally: finally:
......
...@@ -1134,6 +1134,90 @@ In this example, the debug, with_file1 and with_file2 sections act as ...@@ -1134,6 +1134,90 @@ In this example, the debug, with_file1 and with_file2 sections act as
macros. In particular, the variable substitutions are performed macros. In particular, the variable substitutions are performed
relative to the myfiles section. relative to the myfiles section.
Extending sections (macros) - Adding and removing options
----------------------------------------------------
We can also add and remove options in extended sections.
This is illustrated below; first we define a base configuration.
>>> write(sample_buildout, 'base.cfg',
... """
... [buildout]
... parts = part1 part2 part3
...
... [part1]
... recipe =
... option = a1
... a2
...
... [part2]
... <= part1
... option -= a1
... option += c3 c4
...
... [part3]
... <= part2
... option += d2
... c5 d1 d6
... option -= a2
... """)
To verify that the options are adjusted correctly, we'll set up an
extension that prints out the options.
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'demo.py',
... """
... import sys
... def ext(buildout):
... sys.stdout.write(str(
... [part['option'] for name, part in sorted(buildout.items())
... if name.startswith('part')])+'\\n')
... """)
>>> write(sample_buildout, 'demo', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name="demo",
... entry_points={'zc.buildout.extension': ['ext = demo:ext']},
... )
... """)
Set up a buildout configuration for this extension.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... parts =
... """)
>>> os.chdir(sample_buildout)
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')), end='') # doctest: +ELLIPSIS
Develop: '/sample-buildout/demo'
....
Verify option values.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... extensions = demo
... extends = base.cfg
... """)
>>> print_(system(os.path.join('bin', 'buildout')), end='')
['a1/na2', 'a2/nc3 c4', 'c3 c4/nd2/nc5 d1 d6']
Develop: '/sample-buildout/demo'
Cleanup.
>>> os.remove(os.path.join(sample_buildout, 'base.cfg'))
>>> rmdir(sample_buildout, 'demo')
Conditional sections Conditional sections
-------------------- --------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment