diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-09-20 22:56:37 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-09-20 22:56:37 +0000 |
| commit | 022873d909055040a39f24fe3df34f4c154f9102 (patch) | |
| tree | 964cc5a9dde24f86f101cfabb15a5841de0f07f6 /repoze/bfg/zcml.py | |
| parent | e4610566d881f707c01d266a7e336084029c83e4 (diff) | |
| download | pyramid-022873d909055040a39f24fe3df34f4c154f9102.tar.gz pyramid-022873d909055040a39f24fe3df34f4c154f9102.tar.bz2 pyramid-022873d909055040a39f24fe3df34f4c154f9102.zip | |
Make instance grokking work again.
Diffstat (limited to 'repoze/bfg/zcml.py')
| -rw-r--r-- | repoze/bfg/zcml.py | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index d5e7ffd67..d597f860f 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -594,17 +594,27 @@ class IScanDirective(Interface): def scan(_context, package, martian=martian): # martian overrideable only for unit tests - multi_grokker = SimpleMultiGrokker() - multi_grokker.register(BFGViewFunctionGrokker()) - multi_grokker.register(BFGViewNewStyleClassGrokker()) - multi_grokker.register(BFGViewOldStyleClassGrokker()) + multi_grokker = BFGMultiGrokker() + multi_grokker.register(BFGViewGrokker()) +## multi_grokker.register(BFGViewNewStyleClassGrokker()) +## multi_grokker.register(BFGViewOldStyleClassGrokker()) module_grokker = martian.ModuleGrokker(grokker=multi_grokker) martian.grok_dotted_name(package.__name__, grokker=module_grokker, context=_context, exclude_filter=exclude) ################# utility stuff #################### -class BFGViewGrokker(object): +class BFGViewMarker(object): + pass + +class BFGMultiGrokker(martian.core.MultiInstanceOrClassGrokkerBase): + def get_bases(self, obj): + if hasattr(obj, '__is_bfg_view__'): + return [BFGViewMarker] + return [] + +class BFGViewGrokker(martian.InstanceGrokker): + martian.component(BFGViewMarker) def grok(self, name, obj, **kw): if hasattr(obj, '__is_bfg_view__'): permission = obj.__permission__ @@ -627,30 +637,11 @@ class BFGViewGrokker(object): return True return False -class BFGViewFunctionGrokker(BFGViewGrokker, martian.InstanceGrokker): - martian.component(types.FunctionType) - -class BFGViewOldStyleClassGrokker(BFGViewGrokker, martian.InstanceGrokker): - martian.component(types.ClassType) - -class BFGViewNewStyleClassGrokker(BFGViewGrokker, martian.InstanceGrokker): - martian.component(type) - def exclude(name): if name.startswith('.'): return True return False -class SimpleMultiGrokker(martian.core.MultiInstanceOrClassGrokkerBase): - # this is an amalgam of martian.core.MultiInstanceGrokker and - # martian.core.MultiClassGrokker. - def get_bases(self, obj): - if type(obj) is types.ModuleType: - return [] - if hasattr(obj, '__class__'): - return inspect.getmro(obj.__class__) - return [types.ClassType] - class Uncacheable(object): """ Include in discriminators of actions which are not cacheable; this class only exists for backwards compatibility (<0.8.1)""" |
