[Checkins] SVN: grok/branches/jw-simpler-skin-registration/src/grok/directive.py Start simplifying skin registrations: a skin directive

Jan-Wijbrand Kolman janwijbrand at gmail.com
Fri Jul 25 04:12:06 EDT 2008


Log message for revision 88808:
  Start simplifying skin registrations: a skin directive

Changed:
  U   grok/branches/jw-simpler-skin-registration/src/grok/directive.py

-=-
Modified: grok/branches/jw-simpler-skin-registration/src/grok/directive.py
===================================================================
--- grok/branches/jw-simpler-skin-registration/src/grok/directive.py	2008-07-25 07:59:41 UTC (rev 88807)
+++ grok/branches/jw-simpler-skin-registration/src/grok/directive.py	2008-07-25 08:12:06 UTC (rev 88808)
@@ -23,7 +23,7 @@
 import martian
 from martian import util
 from martian.error import GrokImportError, GrokError
-from martian.directive import StoreMultipleTimes
+from martian.directive import StoreOnce, StoreMultipleTimes
 from grokcore.component.scan import UnambiguousComponentScope
 from grok import components
 
@@ -195,3 +195,32 @@
     def factory(self, value=0):
         order._order += 1
         return value, order._order
+
+_taggedvaluekey = '__tagged_value_key__'
+
+class TaggedValueStoreOnce(StoreOnce):
+    """Stores the directive value in a interface tagged value.
+    """
+
+    def get(self, directive, component, default):
+        return component.queryTaggedValue(_taggedvaluekey, default)
+
+    def setattr(self, context, directive, value):
+        context.setTaggedValue(_taggedvaluekey, value)
+
+TAGGEDVALUEONCE = TaggedValueStoreOnce()
+
+class InterfaceScope(object):
+    description = 'interface'
+
+    def check(self, frame):
+        return IInterface.providedBy(frame)
+
+    def get(self, directive, component, module, default):
+        return directive.store.get(directive, component, default)
+
+INTERFACE_SCOPE = InterfaceScope()
+
+class skin(martian.Directive):
+    scope = INTERFACE_SCOPE
+    store = TAGGEDVALUEONCE



More information about the Checkins mailing list