[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/location/ Changed
ILocation interface: __name__ is not required
Dominik Huber
dominik.huber at projekt01.ch
Tue Jun 1 10:44:56 EDT 2004
Log message for revision 25149:
Changed ILocation interface: __name__ is not required
anymore and its default is None.
-=-
Modified: Zope3/trunk/src/zope/app/location/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/location/interfaces.py 2004-06-01 11:37:58 UTC (rev 25148)
+++ Zope3/trunk/src/zope/app/location/interfaces.py 2004-06-01 14:44:55 UTC (rev 25149)
@@ -25,9 +25,9 @@
__name__ = schema.TextLine(
title=u"The name within the parent",
- description=u"The parent can be traversed with this name to "
- u"get the object."
- )
+ description=u"Traverse the parent with this name to get the object.",
+ required=False,
+ default=None)
class ISublocations(Interface):
"""Provide access to sublocations
Modified: Zope3/trunk/src/zope/app/location/location.py
===================================================================
--- Zope3/trunk/src/zope/app/location/location.py 2004-06-01 11:37:58 UTC (rev 25148)
+++ Zope3/trunk/src/zope/app/location/location.py 2004-06-01 14:44:55 UTC (rev 25149)
@@ -24,6 +24,35 @@
class Location(object):
"""Stupid mix-in that defines __parent__ and __name__ attributes
+
+ Usage within an Object field:
+ >>> from zope.interface import implements, Interface
+ >>> from zope.schema import Object
+ >>> from zope.schema.fieldproperty import FieldProperty
+ >>> from zope.app.location.interfaces import ILocation
+ >>> from zope.app.location.location import Location
+
+ >>> class IA(Interface):
+ ... location = Object(schema=ILocation, required=False, default=None)
+ >>> class A(object):
+ ... implements(IA)
+ ... location = FieldProperty(IA['location'])
+
+ >>> a = A()
+ >>> a.location = Location()
+
+ >>> loc = Location(); loc.__name__ = u'foo'
+ >>> a.location = loc
+
+ >>> loc = Location(); loc.__name__ = None
+ >>> a.location = loc
+
+ >>> loc = Location(); loc.__name__ = 'foo'
+ >>> a.location = loc
+ Traceback (most recent call last):
+ ...
+ WrongContainedType: [foo <type 'unicode'>]
+
"""
zope.interface.implements(ILocation)
More information about the Zope3-Checkins
mailing list