/usr/share/pyshared/grokcore/component/testing.py is in python-grokcore.component 2.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ##############################################################################
#
# Copyright (c) 2007 Zope Foundation 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 test helpers
"""
import grokcore.component
from zope.configuration.config import ConfigurationMachine
from martian import scan
from grokcore.component import zcml
def grok(module_name):
config = ConfigurationMachine()
zcml.do_grok('grokcore.component.meta', config)
zcml.do_grok(module_name, config)
config.execute_actions()
def grok_component(name, component,
context=None, module_info=None, templates=None):
if module_info is None:
obj_module = getattr(component, '__grok_module__', None)
if obj_module is None:
obj_module = getattr(component, '__module__', None)
module_info = scan.module_info_from_dotted_name(obj_module)
module = module_info.getModule()
if context is not None:
grokcore.component.context.set(module, context)
if templates is not None:
module.__grok_templates__ = templates
config = ConfigurationMachine()
result = zcml.the_multi_grokker.grok(name, component,
module_info=module_info,
config=config)
config.execute_actions()
return result
|