Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to exclude more than one module or package using ``<grok:…
…grok exclude="<names>" />`` and allow to use unix shell-style wildcards within.
- Loading branch information
Michael Howitz
committed
Feb 14, 2016
1 parent
2c50001
commit 50d87a6
Showing
7 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
It allows to exclude a many packages or modules from beeing grokked. | ||
These packages or modules can be specified using unix shell-style wildcards | ||
There is a NameError in `.excludemanypkg.file_1` which is raised when this | ||
module is not excluded: | ||
>>> xmlconfig.string(''' | ||
... <configure xmlns:grok="http://namespaces.zope.org/grok"> | ||
... <include package="grokcore.component" file="meta.zcml"/> | ||
... <grok:grok package="." /> | ||
... </configure>''', context) | ||
Traceback (most recent call last): | ||
ZopeXMLConfigurationError: File "<string>", line 4.6-4.31 | ||
NameError: name 'asdf' is not defined | ||
There is a NameError in `.excludemanypkg.test_asdf`, too which is raised when | ||
this module is not excluded: | ||
>>> xmlconfig.string(''' | ||
... <configure xmlns:grok="http://namespaces.zope.org/grok"> | ||
... <include package="grokcore.component" file="meta.zcml"/> | ||
... <grok:grok package="." | ||
... exclude="file_*" /> | ||
... </configure>''', context) | ||
Traceback (most recent call last): | ||
ZopeXMLConfigurationError: File "<string>", line 4.6-5.36 | ||
NameError: name 'qwe' is not defined | ||
Excluding both 'file_1` and `test_asdf`allows to successfully grok the module: | ||
>>> xmlconfig.string(''' | ||
... <configure xmlns:grok="http://namespaces.zope.org/grok"> | ||
... <include package="grokcore.component" file="meta.zcml"/> | ||
... <grok:grok package="." | ||
... exclude="file_* | ||
... *asdf" /> | ||
... </configure>''', context) | ||
<zope.configuration.config.ConfigurationMachine ...> | ||
""" | ||
|
||
from zope.configuration import xmlconfig | ||
from grokcore.component.tests.zcml import excludemanypkg | ||
|
||
context = xmlconfig.ConfigurationMachine() | ||
xmlconfig.registerCommonDirectives(context) | ||
context.package = excludemanypkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# this is a package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
asdf # This leads to a NameError if exclude does not work correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
qwe # This leads to a NameError if exclude does not work correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters