[Checkins]
SVN: grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/
Incorporated another helper into the directive implementation
of the 'context' directive.
Philipp von Weitershausen
philikon at philikon.de
Sun May 4 08:21:48 EDT 2008
Log message for revision 86345:
Incorporated another helper into the directive implementation of the 'context' directive.
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
-=-
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 12:16:41 UTC (rev 86344)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/directive.py 2008-05-04 12:21:47 UTC (rev 86345)
@@ -13,10 +13,12 @@
##############################################################################
"""Grok directives.
"""
+import types
import martian
import grokcore.component
from zope.interface.interfaces import IInterface
from martian.error import GrokImportError
+from grokcore.component.util import check_module_component
class global_utility(martian.MultipleTimesDirective):
scope = martian.MODULE
@@ -66,6 +68,15 @@
store = martian.ONCE
validate = martian.validateInterfaceOrClass
+ @classmethod
+ def get(cls, component, module=None):
+ value = super(cls, context).get(component, module)
+ if not isinstance(component, types.ModuleType):
+ # 'component' must be a class then, so let's make sure
+ # that the context is not ambiguous or None.
+ check_module_component(component, value, 'context', cls)
+ return value
+
class title(martian.Directive):
scope = martian.CLASS
store = martian.ONCE
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 12:16:41 UTC (rev 86344)
+++ grokcore.component/branches/jw-philipp-using-ndir-directives/src/grokcore/component/meta.py 2008-05-04 12:21:47 UTC (rev 86345)
@@ -23,12 +23,6 @@
from grokcore.component.util import check_module_component
from grokcore.component.util import determine_module_component
-def get_context(factory, module_info):
- component = grokcore.component.context.get(factory, module_info.getModule())
- check_module_component(factory, component, 'context',
- grokcore.component.context)
- return component
-
def get_provides(factory):
provides = grokcore.component.provides.get(factory)
@@ -54,7 +48,7 @@
component_class = grokcore.component.Adapter
def grok(self, name, factory, module_info, config, **kw):
- adapter_context = get_context(factory, module_info)
+ adapter_context = grokcore.component.context.get(factory, module_info.getModule())
provides = get_provides(factory)
name = grokcore.component.name.get(factory)
More information about the Checkins
mailing list