Changeset 7941 for main/waeup.kofa/trunk/src
- Timestamp:
- 22 Mar 2012, 01:48:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py
r7933 r7941 28 28 from zope.component.interfaces import IFactory 29 29 from zope.interface import implementedBy 30 from zope.interface.interface import Method, Attribute 30 31 from zope.schema import getFieldNames 31 32 from zope.schema.fieldproperty import FieldProperty … … 478 479 account = authenticator.getAccount(principal_id) 479 480 return account 481 482 def iface_names(iface, omit=[], exclude_attribs=True, exclude_methods=True): 483 """Get all attribute names of an interface. 484 485 Searches also base interfaces. 486 487 Names of fields that are pure attributes 488 (i.e. zope.interface.Attribute) or methods are excluded by 489 default. 490 491 Names of typical fields derived from zope.schema are included. 492 493 The `omit` paramter can give a list of names to exclude. 494 495 Returns an unsorted list of strings. 496 """ 497 ifaces = [iface] + list(iface.getBases()) 498 names = [] 499 for item in ifaces: 500 names += item.names() 501 names = [x for x in names if x not in omit] 502 result = [] 503 for name in names: 504 cls = iface.get(name).__class__ 505 if exclude_attribs and cls is Attribute: 506 continue 507 if exclude_methods and cls is Method: 508 continue 509 result.append(name) 510 return result
Note: See TracChangeset for help on using the changeset viewer.