Title: [commits] (pje) [11267] Remove displayName support for attributes, per bug 1745 and bug 6237.
Revision
11267
Author
pje
Date
2006-07-26 15:16:15 -0700 (Wed, 26 Jul 2006)

Log Message

Remove displayName support for attributes, per bug 1745 and bug 6237.
This does not remove displayName kindInfo support yet, nor does it
do anything with displayAttribute. Some investigation is required
before those other bits can be removed.

Modified Paths

Diff

Modified: trunk/chandler/application/parcel-schema-guide.txt (11266 => 11267)

--- trunk/chandler/application/parcel-schema-guide.txt	2006-07-26 22:09:15 UTC (rev 11266)
+++ trunk/chandler/application/parcel-schema-guide.txt	2006-07-26 22:16:15 UTC (rev 11267)
@@ -226,20 +226,17 @@
 example::
 
     >>> class Knight(schema.Item):
-    ...     who = schema.One(schema.Text, displayName="What is your name?")
-    ...     what = schema.One(schema.Text, displayName="What is your quest?")
+    ...     who = schema.One(schema.Text, doc="What is your name?")
+    ...     what = schema.One(schema.Text, doc="What is your quest?")
     ...     numbers = schema.Sequence(
-    ...         schema.Integer, displayName="What are your favorite numbers?"
+    ...         schema.Integer, doc="What are your favorite numbers?"
     ...     )
 
 ``schema.One`` and ``schema.Sequence`` are attribute descriptors that tell
 the repository you want either a simple attribute value, or a sequence of
 values.  The first argument to each is a **type reference**; it can be one of
 the predefined type references like ``schema.Text`` or ``schema.Integer``, or
-else it can be an existing item class.  (The ``displayName`` argument is used
-by some parts of Chandler to display e.g. column names, so you should generally
-wrap them with calls to the translation function (``_()``) from Chandler's
-``i18n`` package, even though we aren't doing that in this document.)
+else it can be an existing item class.
 
 Now that we've defined a schema for the ``Knight`` class, we can create
 instances with data in the specified attributes::
@@ -396,10 +393,9 @@
 You *must* set the type of the main attribute (``attendees`` in this case), so
 that the schema API will know what type the anonymous inverse attribute
 should be attached to (``Person`` in this case).  Both sides of the
-bidirectional reference can include a ``displayName``, ``description``,
-``initialValue``, or any of the other standard attribute descriptor arguments.
-(See the API Details section on `Attribute Descriptors`_, below, for a more
-complete list.)
+bidirectional reference can include a ``description``, ``initialValue``, or any
+of the other standard attribute descriptor arguments.  (See the API Details
+section on `Attribute Descriptors`_, below, for a more complete list.)
 
 You can't tell from the example above, but the ``inverse`` attribute actually
 gets attached to the ``Person`` kind, and the ``Joe`` item actually has an
@@ -583,7 +579,7 @@
     >>> fJoe.connect()
     opening jabber connection 1
     checking if Mary Quite Contrary is on-line
-    
+
 The attributes defined using ``__slots__``, however, are *not* persistent, and
 they will not be stored in the repository.  Each annotation wrapper also has
 its own separate value for each attribute, no matter what item is wrapped.
@@ -1283,8 +1279,8 @@
 
 When a parcel is created, persistent items are created that correspond to each
 class, to store each class' schema.  These items can have attributes of their
-own, such as ``displayName`` and ``description``.  Depending on whether the
-class is a ``schema.Item``, ``schema.Struct``, or ``schema.Enumeration``, the
+own, such as ``description``.  Depending on whether the class is a
+``schema.Item``, ``schema.Struct``, or ``schema.Enumeration``, the
 attributes may be different, as the type of the persistent item will be
 different.  For all classes, however, you can set attributes of the
 corresponding items by using the ``schema.kindInfo()`` function in the body of
@@ -1491,7 +1487,7 @@
         >>> Kind.superkinds.type
         <class '...Kind'>
 
-``displayName``, ``description``, and ``doc``
+``description``, and ``doc``
     The name and description of this attribute descriptor, if any.  They will
     be used to collectively form a ``__doc__`` string, so that ``help()`` is
     informative for Item classes::
@@ -1499,7 +1495,6 @@
         >>> Kind.subkinds.doc = "Sub-kinds of this kind"
         >>> Kind.superkinds.doc = "Super-kinds of this kind"
         >>> Kind.name.doc = "This kind's name"
-        >>> Kind.name.displayName = "Kind Name"
 
         >>> help(Kind)                      # doctest: +NORMALIZE_WHITESPACE
         Help on class Kind ...
@@ -1509,7 +1504,7 @@
          |  Data and other attributes defined here:
          |
          |  name = <Descriptor name of <class '...Kind'>>
-         |      Kind Name -- One(Text)
+         |      One(Text)
          |
          |      This kind's name
          |

Modified: trunk/chandler/application/schema.py (11266 => 11267)

--- trunk/chandler/application/schema.py	2006-07-26 22:09:15 UTC (rev 11266)
+++ trunk/chandler/application/schema.py	2006-07-26 22:16:15 UTC (rev 11267)
@@ -31,8 +31,7 @@
     'assertResolved', 'Annotation', 'AnnotationItem',
 ]
 
-all_aspects = Attribute.valueAspects + Attribute.refAspects + \
-    ('displayName','description')
+all_aspects = Attribute.valueAspects + Attribute.refAspects + ('description',)
 
 global_lock = threading.RLock()
 
@@ -287,22 +286,9 @@
     doc = property(lambda self: self.__dict__.get('doc',None),__setDoc)
     description = property(lambda self: self.__dict__.get('doc',''),__setDoc)
 
-    def __getDisplayName(self):
-        return self.__dict__.get('displayName')
-
-    def __setDisplayName(self,val):
-        self.__dict__['displayName'] = val
-        self.setDoc()
-
-    displayName = property(__getDisplayName,__setDisplayName)
-
     def setDoc(self):
         doc = self.doc
-        name = self.displayName
-        if not name:
-            name = self.docInfo()
-        else:
-            name = "%s -- %s" % (name.encode('utf8'),self.docInfo())
+        name = self.docInfo()
         if not doc:
             doc = name
         else:
@@ -336,9 +322,7 @@
         for aspect in all_aspects:
             if hasattr(self,aspect):
                 val = getattr(self,aspect)
-                if aspect=='displayName':
-                    val = val or unicode(self.name)  # default displayName=name
-                elif aspect=='type':
+                if aspect=='type':
                     if val is None:
                         continue    # don't set type to None
                     else:

Modified: trunk/chandler/application/schema_api.txt (11266 => 11267)

--- trunk/chandler/application/schema_api.txt	2006-07-26 22:09:15 UTC (rev 11266)
+++ trunk/chandler/application/schema_api.txt	2006-07-26 22:16:15 UTC (rev 11267)
@@ -78,7 +78,7 @@
         >>> Kind.superkinds.type
         <class '...Kind'>
 
-``displayName``, ``description``, and ``doc``
+``description``, and ``doc``
     The name and description of this role, if any.  They will be used to
     collectively form a ``__doc__`` string, so that ``help()`` is informative
     for Item classes::
@@ -86,7 +86,6 @@
         >>> Kind.subkinds.doc = "Sub-kinds of this kind"
         >>> Kind.superkinds.doc = "Super-kinds of this kind"
         >>> Kind.name.doc = "This kind's name"
-        >>> Kind.name.displayName = u"Kind Name"
 
         >>> help(Kind)  # doctest: +NORMALIZE_WHITESPACE
         Help on class Kind ...
@@ -96,7 +95,7 @@
          |  Data and other attributes defined here:
          |
          |  name = <Descriptor name of <class '...Kind'>>
-         |      Kind Name -- One(Text)
+         |      One(Text)
          |
          |      This kind's name
          |
@@ -243,8 +242,8 @@
     ``Attribute``, including ``required``, ``persisted``, ``indexed``,
     ``cardinality``, ``defaultValue``, ``initialValue``, ``inheritFrom``,
     ``redirectTo``, ``otherName``, ``companion``, ``deletePolicy``,
-    ``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``,
-    ``displayName``, and ``description``.  You can supply any of these as
+    ``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``, and
+    ``description``.  You can supply any of these as
     keyword arguments to a Descriptor constructor (such as ``schema.One``,
     ``schema.Many``, etc.), in order to set the corresponding value for the
     attribute.  Unspecified aspects will take on their normal default values,
@@ -385,7 +384,7 @@
 Sometimes, you need a bidirectional reference between a new kind and an
 existing kind.  You can do this by creating an "anonymous inverse" - a
 role that just indicates the cardinality of the other end (optionally with
-a displayName, description, initialValue, or other options):
+a description, initialValue, or other options):
 
 
     #>>> __name__ = "application.tests"    # pretend we're in this parcel
@@ -407,10 +406,10 @@
     >>> sorted(
     ...     a.itsName for a in Person.getKind(rv).attributes
     ... ) # doctest: +NORMALIZE_WHITESPACE
-    ... 
+    ...
     ['age', 'application.tests.School.attendees.inverse', 'children',
      'fullname', 'parents']
-    
+
 Notice that the attribute name is a combination of:
 
 1. the parcel name (from the module's ``__parcel__``, if applicable)
@@ -516,7 +515,7 @@
 Annotation classes do not create persistent items.  Instead, their instances
 are wrappers that give you access to the annotation attributes, which are
 actually stored on the wrapped item::
-   
+
     >>> ProfMary = Teacher(Mary)
     >>> gym = TeachingCertificate("gym", rv, subject=u"Physical Education")
     >>> ProfMary.certifications = [gym]
@@ -534,7 +533,7 @@
 
     >>> list(Teacher(Mary).certifications)
     [<TeachingCertificate ... gym ...>]
-    
+
 These additional attributes are added to the annotated kinds, using their
 module/class names to distinguish them from "native" or "essential" attributes
 of the kind::
@@ -542,7 +541,7 @@
     >>> sorted(
     ...     a.itsName for a in Person.getKind(rv).attributes
     ... ) # doctest: +NORMALIZE_WHITESPACE
-    ... 
+    ...
     ['age', 'application.tests.School.attendees.inverse',
      'application.tests.Teacher.certifications',
      'application.tests.Teacher.supervisor', 'children', 'fullname', 'parents']
@@ -591,7 +590,7 @@
     >>> fMary.jabberConnection = "just pretending"
     >>> fMary.jabberConnection
     'just pretending'
-    
+
     >>> f2Mary = Friend(Mary)
     >>> f2Mary.jabberConnection
     Traceback (most recent call last):
@@ -611,7 +610,7 @@
 
     >>> Teacher(fMary)
     Teacher(Mary Quite Contrary)
-    
+
     >>> Friend(ProfMary)
     Friend(Mary Quite Contrary)
 
@@ -877,7 +876,7 @@
     >>> stranger = api_tests.fwdRef(Person, u'Stranger')
 
 At this point, the item exists and can be used::
-    
+
     >>> carlos.parents = [stranger]
     >>> list(stranger.children)
     [Carlos Marron]




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to