[Checkins]
SVN: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/
Renamed util.py to scan.py
Philipp von Weitershausen
philikon at philikon.de
Sun May 4 09:12:15 EDT 2008
Log message for revision 86364:
Renamed util.py to scan.py
Changed:
U grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/directive.py
U grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/meta.py
A grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/scan.py
D grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/util.py
-=-
Modified: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/directive.py
===================================================================
--- grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/directive.py 2008-05-04 13:09:20 UTC (rev 86363)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/directive.py 2008-05-04 13:12:15 UTC (rev 86364)
@@ -18,7 +18,7 @@
import grokcore.component
from zope.interface.interfaces import IInterface
from martian.error import GrokImportError
-from grokcore.component.util import check_module_component
+from grokcore.component.scan import check_module_component
class global_utility(martian.MultipleTimesDirective):
scope = martian.MODULE
Modified: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/meta.py
===================================================================
--- grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/meta.py 2008-05-04 13:09:20 UTC (rev 86363)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/meta.py 2008-05-04 13:12:15 UTC (rev 86364)
@@ -19,8 +19,8 @@
from zope import component, interface
from martian.error import GrokError
-from grokcore.component.util import check_module_component
-from grokcore.component.util import determine_module_component
+from grokcore.component.scan import check_module_component
+from grokcore.component.scan import determine_module_component
from grokcore.component.interfaces import IContext
def get_provides(factory):
Copied: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/scan.py (from rev 86361, grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/util.py)
===================================================================
--- grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/scan.py (rev 0)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/scan.py 2008-05-04 13:12:15 UTC (rev 86364)
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Grok utility functions.
+"""
+
+from martian.error import GrokError
+from martian.util import methods_from_class, scan_for_classes
+
+AMBIGUOUS_COMPONENT = object()
+def check_module_component(factory, component, component_name, directive):
+ """Raise error if module-level component cannot be determined.
+
+ If the module-level component is None, it's never been specified;
+ raise error telling developer to specify.
+
+ if the module-level component is AMBIGUOUS_COMPONENT, raise
+ an error telling developer to specify which one to use.
+ """
+ if component is None:
+ raise GrokError("No module-level %s for %r, please use the '%s' "
+ "directive."
+ % (component_name, factory, directive.__name__),
+ factory)
+ elif component is AMBIGUOUS_COMPONENT:
+ raise GrokError("Multiple possible %ss for %r, please use the '%s' "
+ "directive."
+ % (component_name, factory, directive.__name__),
+ factory)
+
+def determine_module_component(module_info, directive, iface):
+ """Determine module-level component.
+
+ The module-level component can be set explicitly using the
+ annotation (such as grok.context).
+
+ If there is no annotation, the module-level component is determined
+ by scanning for classes that implement an interface.
+
+ If there is no module-level component, the module-level component is
+ None.
+
+ If there is one module-level component, it is returned.
+
+ If there are more than one module-level component, AMBIGUOUS_COMPONENT
+ is returned.
+ """
+ module = module_info.getModule()
+ components = list(scan_for_classes(module, interface=iface))
+ if len(components) == 0:
+ component = None
+ elif len(components) == 1:
+ component = components[0]
+ else:
+ component= AMBIGUOUS_COMPONENT
+
+ module_component = directive.get(module)
+ if module_component is not None:
+ component = module_component
+ return component
Deleted: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/util.py
===================================================================
--- grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/util.py 2008-05-04 13:09:20 UTC (rev 86363)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/util.py 2008-05-04 13:12:15 UTC (rev 86364)
@@ -1,70 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok utility functions.
-"""
-
-from martian.error import GrokError
-from martian.util import methods_from_class, scan_for_classes
-
-AMBIGUOUS_COMPONENT = object()
-def check_module_component(factory, component, component_name, directive):
- """Raise error if module-level component cannot be determined.
-
- If the module-level component is None, it's never been specified;
- raise error telling developer to specify.
-
- if the module-level component is AMBIGUOUS_COMPONENT, raise
- an error telling developer to specify which one to use.
- """
- if component is None:
- raise GrokError("No module-level %s for %r, please use the '%s' "
- "directive."
- % (component_name, factory, directive.__name__),
- factory)
- elif component is AMBIGUOUS_COMPONENT:
- raise GrokError("Multiple possible %ss for %r, please use the '%s' "
- "directive."
- % (component_name, factory, directive.__name__),
- factory)
-
-def determine_module_component(module_info, directive, iface):
- """Determine module-level component.
-
- The module-level component can be set explicitly using the
- annotation (such as grok.context).
-
- If there is no annotation, the module-level component is determined
- by scanning for classes that implement an interface.
-
- If there is no module-level component, the module-level component is
- None.
-
- If there is one module-level component, it is returned.
-
- If there are more than one module-level component, AMBIGUOUS_COMPONENT
- is returned.
- """
- module = module_info.getModule()
- components = list(scan_for_classes(module, interface=iface))
- if len(components) == 0:
- component = None
- elif len(components) == 1:
- component = components[0]
- else:
- component= AMBIGUOUS_COMPONENT
-
- module_component = directive.get(module)
- if module_component is not None:
- component = module_component
- return component
More information about the Checkins
mailing list