[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/PropertySets - PropertySetDef.py:1.3
Jeremy Hylton
jeremy@zope.com
Tue, 16 Jul 2002 18:50:34 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/PropertySets
In directory cvs.zope.org:/tmp/cvs-serv8263
Modified Files:
PropertySetDef.py
Log Message:
Simplify the implementation of PropertySetDef.
The namelist attribute was redundant, since the fields dict had the
same information as its keys. The __iter__() can be implemented more
efficiently by return the dict's values iterator.
=== Zope3/lib/python/Zope/App/OFS/PropertySets/PropertySetDef.py 1.2 => 1.3 ===
def __init__(self):
'''See interface IPropertySetDef'''
self.fields = {}
- self.namelist = []
def has_field(self, name):
'''See interface IPropertySetDef'''
@@ -36,7 +35,6 @@
if name in self.fields:
raise DuplicationError(name)
self.fields[name] = field
- self.namelist.append(name)
def getField(self, name):
'''See interface IPropertySetDef'''
@@ -44,15 +42,15 @@
def fieldNames(self):
'''See interface IPropertySetDef'''
- return self.namelist
+ return self.fields.keys()
def __len__(self):
'''See interface IPropertySetDef'''
- return len(self.namelist)
+ return len(self.fields)
def __iter__(self):
'''See interface IPropertySetDef'''
- return iter([ self.fields[x] for x in self.namelist ])
+ return self.fields.itervalues()
#
############################################################