[Checkins] SVN: martian/trunk/ Move martian.baseclass with the other martian-specific directives.

Martijn Faassen faassen at infrae.com
Fri Jun 6 11:38:22 EDT 2008


Log message for revision 87203:
  Move martian.baseclass with the other martian-specific directives.
  

Changed:
  U   martian/trunk/CHANGES.txt
  U   martian/trunk/src/martian/__init__.py
  U   martian/trunk/src/martian/directive.py
  U   martian/trunk/src/martian/directive.txt
  U   martian/trunk/src/martian/martiandirective.py

-=-
Modified: martian/trunk/CHANGES.txt
===================================================================
--- martian/trunk/CHANGES.txt	2008-06-06 15:28:42 UTC (rev 87202)
+++ martian/trunk/CHANGES.txt	2008-06-06 15:38:21 UTC (rev 87203)
@@ -30,7 +30,8 @@
   ``martian.directive`` takes the directive itself as an argument, and
   then optionally the same arguments as the ``bind`` method of
   directives (``name``, ``default`` and ``get_default``). It may be
-  used multiple times.
+  used multiple times. Note that ``martian.baseclass`` was already a
+  Martian-specific directive and this has been unchanged.
 
 * For symmetry, add an ``execute`` method to ``InstanceGrokker``.
 

Modified: martian/trunk/src/martian/__init__.py
===================================================================
--- martian/trunk/src/martian/__init__.py	2008-06-06 15:28:42 UTC (rev 87202)
+++ martian/trunk/src/martian/__init__.py	2008-06-06 15:38:21 UTC (rev 87203)
@@ -5,9 +5,8 @@
 from martian.components import MethodGrokker
 from martian.util import scan_for_classes
 from martian.directive import Directive, MarkerDirective, MultipleTimesDirective
-from martian.directive import ONCE, MULTIPLE, DICT
+from martian.directive import ONCE, ONCE_NOBASE, MULTIPLE, DICT
 from martian.directive import CLASS, CLASS_OR_MODULE, MODULE
 from martian.directive import (
     validateText, validateInterface, validateClass, validateInterfaceOrClass)
-from martian.directive import baseclass
-from martiandirective import component, directive, priority
+from martiandirective import component, directive, priority, baseclass

Modified: martian/trunk/src/martian/directive.py
===================================================================
--- martian/trunk/src/martian/directive.py	2008-06-06 15:28:42 UTC (rev 87202)
+++ martian/trunk/src/martian/directive.py	2008-06-06 15:38:21 UTC (rev 87203)
@@ -28,6 +28,8 @@
     def get(self, directive, component, default):
         return component.__dict__.get(directive.dotted_name(), default)
 
+ONCE_NOBASE = StoreOnceGetFromThisClassOnly()
+
 class StoreMultipleTimes(StoreOnce):
 
     def get(self, directive, component, default):
@@ -209,12 +211,6 @@
     def factory(self):
         return True
 
-
-class baseclass(MarkerDirective):
-    scope = CLASS
-    store = StoreOnceGetFromThisClassOnly()
-
-
 def validateText(directive, value):
     if util.not_unicode_or_ascii(value):
         raise GrokImportError("The '%s' directive can only be called with "

Modified: martian/trunk/src/martian/directive.txt
===================================================================
--- martian/trunk/src/martian/directive.txt	2008-06-06 15:28:42 UTC (rev 87202)
+++ martian/trunk/src/martian/directive.txt	2008-06-06 15:38:21 UTC (rev 87203)
@@ -569,19 +569,19 @@
 Declaring base classes
 ----------------------
 
-There's a special directive called 'baseclass' which lets you declare that a
-certain class is the base class for a series of other components.  This
-property should not be inherited by those components.  Consider the following
-base class:
+There's a special directive called ``martian.baseclass`` which lets
+you declare that a certain class is the base class for a series of
+other components.  This property should not be inherited by those
+components.  Consider the following base class:
 
-  >>> from martian import baseclass
+  >>> import martian
   >>> class MyBase(object):
-  ...     baseclass()
+  ...     martian.baseclass()
 
 As you would expect, the directive will correctly identify this class as a
 baseclass:
 
-  >>> baseclass.bind().get(MyBase)
+  >>> martian.baseclass.bind().get(MyBase)
   True
 
 But, if we create a subclass of this base class, the subclass won't inherit
@@ -590,7 +590,7 @@
   >>> class SubClass(MyBase):
   ...     pass
   ...
-  >>> baseclass.bind().get(SubClass)
+  >>> martian.baseclass.bind().get(SubClass)
   False
 
 Naturally, the directive will also report a false answer if the class doesn't
@@ -599,5 +599,5 @@
   >>> class NoBase(object):
   ...     pass
   ...
-  >>> baseclass.bind().get(NoBase)
+  >>> martian.baseclass.bind().get(NoBase)
   False

Modified: martian/trunk/src/martian/martiandirective.py
===================================================================
--- martian/trunk/src/martian/martiandirective.py	2008-06-06 15:28:42 UTC (rev 87202)
+++ martian/trunk/src/martian/martiandirective.py	2008-06-06 15:38:21 UTC (rev 87203)
@@ -1,7 +1,8 @@
 """Martian-specific directives"""
 
 from martian.directive import (Directive, MultipleTimesDirective,
-                               CLASS, ONCE, validateClass)
+                               MarkerDirective, validateClass,
+                               CLASS, ONCE, ONCE_NOBASE)
 from martian.error import GrokImportError
 
 class component(Directive):
@@ -10,6 +11,7 @@
     default = None
     validate = validateClass
 
+
 class directive(MultipleTimesDirective):
     scope = CLASS
 
@@ -26,9 +28,14 @@
     def factory(self, directive, *args, **kw):
         return directive.bind(*args, **kw)
 
+
 class priority(Directive):
     scope = CLASS
     store = ONCE
     default = 0
 
 
+class baseclass(MarkerDirective):
+    scope = CLASS
+    store = ONCE_NOBASE
+



More information about the Checkins mailing list