summaryrefslogtreecommitdiff
path: root/mtraits
diff options
context:
space:
mode:
authormichele.simionato <devnull@localhost>2008-08-16 08:58:25 +0000
committermichele.simionato <devnull@localhost>2008-08-16 08:58:25 +0000
commitb3728f24fb2ab371fc6891852d65a74d096f478d (patch)
tree90437ce8bc4dc725c352293bc65917d0e85cb7b2 /mtraits
parentb5a7b2a2ad877ffb72b7b7c0953a9c42f75e4cf6 (diff)
downloadmicheles-b3728f24fb2ab371fc6891852d65a74d096f478d.tar.gz
Some small correction to the mtrait documentation; added a picture of Zope Folder hierarchy
Diffstat (limited to 'mtraits')
-rw-r--r--mtraits/doc.py34
-rw-r--r--mtraits/mtrait.py6
2 files changed, 14 insertions, 26 deletions
diff --git a/mtraits/doc.py b/mtraits/doc.py
index 0dcaa1b..80351a0 100644
--- a/mtraits/doc.py
+++ b/mtraits/doc.py
@@ -148,7 +148,7 @@ get an ``OverridingError``:
... include(Pack, Place, Grid)
Traceback (most recent call last):
...
-OverridingError: Pack.{info, config, configure, slaves, forget} overriding names in Place
+OverridingError: Pack overrides names in Place: {info, config, configure, slaves, forget}
The reason for the error is clear: both ``Pack`` and ``Place`` provide
methods called ``{info, config, configure, slaves, forget}``
@@ -321,22 +321,7 @@ old-style class and the metaclass for ``TOSWidget2`` is just ``TOSMeta``:
However, in general you may need to build your Trait Based Framework
on top of pre-existing classes with a nontrivial metaclass, for
instance Zope classes; in that case having a class decorator smart
-enough to figure out the right metaclass to use is a convenient. Here
-is an example using Plone classes:
-
->> from OSF.Folder import Folder
-
-
-when you call
-``super(<class>, <subclass>).method``
->> from zope.plone import BaseContent
->> class
-
->> type(X)
-ExtensionClassMetaTOS
-
-
-<type 'ExtensionClass.ExtensionClass'>
+enough to figure out the right metaclass to use is a convenient.
Why multiple inheritance is forbidden
----------------------------------------------------------
@@ -513,11 +498,16 @@ class Meta(type):
pass
def test_getattr():
- class C:
- __metaclass__ = TOSMeta
- def __getattr__(self, name):
- pass
-
+ try:
+ class C:
+ __metaclass__ = TOSMeta
+ def __getattr__(self, name):
+ pass
+ except OverridingError: # expected
+ pass
+ else:
+ raise RuntimeError("OverridingError not raised!")
+
def test_multi_include():
class B(object):
__metaclass__ = Meta
diff --git a/mtraits/mtrait.py b/mtraits/mtrait.py
index c70d4b1..5e86af8 100644
--- a/mtraits/mtrait.py
+++ b/mtraits/mtrait.py
@@ -27,11 +27,9 @@ def check_overridden(mixins, exclude, raise_='error'):
"Raise an OverridingError for common names not in the exclude set"
for common, c1, c2 in find_common_names(mixins):
overridden = ', '.join(common - exclude)
- if ',' in overridden: # for better display of the names
- overridden = '{%s}' % overridden
if overridden:
- msg = '%s.%s overriding names in %s' % (
- c1.__name__, overridden, c2.__name__)
+ msg = '%s overrides names in %s: {%s}' % (
+ c1.__name__, c2.__name__, overridden)
if raise_ == 'error':
raise OverridingError(msg)
elif raise_ == 'warning':