[Checkins]
SVN: grok/branches/jw-philipp-using-ndir-directives/src/grok/
Work on traversable directive.
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Sat May 3 06:09:39 EDT 2008
Log message for revision 86165:
Work on traversable directive.
Changed:
U grok/branches/jw-philipp-using-ndir-directives/src/grok/__init__.py
U grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py
U grok/branches/jw-philipp-using-ndir-directives/src/grok/directive.py
U grok/branches/jw-philipp-using-ndir-directives/src/grok/tests/directive/multipleasdict.py
-=-
Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/__init__.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/__init__.py 2008-05-03 10:05:55 UTC (rev 86164)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/__init__.py 2008-05-03 10:09:38 UTC (rev 86165)
@@ -44,8 +44,9 @@
from grok.interfaces import IRESTSkinType
from grok.components import ViewletManager, Viewlet
+from martian.ndir import baseclass
from grokcore.component.directive import (
- context, name, title, provides, baseclass, global_utility, direct, order)
+ context, name, title, provides, global_utility, direct, order)
from grok.directive import (
template, templatedir, local_utility, permissions, require, site,
layer, viewletmanager, view, traversable)
Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py 2008-05-03 10:05:55 UTC (rev 86164)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py 2008-05-03 10:09:38 UTC (rev 86165)
@@ -436,7 +436,7 @@
if subob is not None:
return util.safely_locate_maybe(subob, self.context, name)
- traversable_dict = getattr(self.context, '__grok_traversable__', None)
+ traversable_dict = grok.traversable.get(self.context)
if traversable_dict:
if name in traversable_dict:
subob = getattr(self.context, traversable_dict[name])
Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/directive.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/directive.py 2008-05-03 10:05:55 UTC (rev 86164)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/directive.py 2008-05-03 10:09:38 UTC (rev 86165)
@@ -29,7 +29,8 @@
OptionalValueDirective,
ClassDirectiveContext,
ClassOrModuleDirectiveContext)
-from martian import util, ndir
+from martian import util
+from martian import ndir
from grok import components
class MultiValueOnceDirective(OnceDirective):
@@ -135,4 +136,12 @@
ClassOrModuleDirectiveContext())
view = InterfaceOrClassDirective('grok.view',
ClassOrModuleDirectiveContext())
-traversable = TraversableDirective('grok.traversable', ClassDirectiveContext())
+
+class traversable(ndir.Directive):
+ scope = ndir.CLASS
+ store = ndir.DICT
+
+ def factory(self, attr, name=None):
+ if name is None:
+ name = attr
+ return (name, attr)
Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/tests/directive/multipleasdict.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/tests/directive/multipleasdict.py 2008-05-03 10:05:55 UTC (rev 86164)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/tests/directive/multipleasdict.py 2008-05-03 10:09:38 UTC (rev 86165)
@@ -3,10 +3,8 @@
attributes can be mentioned.
>>> from martian import scan
- >>> from grok.tests.directive import multipleasdict
- >>> module_info = scan.module_info_from_module(multipleasdict)
-
- >>> g = Club.__grok_traversable__
+ >>> import grok
+ >>> g = grok.traversable.get(Club)
>>> isinstance(g, dict)
True
>>> g['demo']
More information about the Checkins
mailing list