I’d like to list all the fields (and the values) of a dexterity object.
I can easily access a single field value like this myobject.myfield
But I don’t know how to list all the available fields of an object.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Dexterity objects are defined by a schema, which is enumerable:
Here I use the
.namesAndDescriptions()method, but you can also just use the interface as an iterator if you don’t have any methods on your schema:Last but not least,
zope.schemahas a utility method namedgetFieldsInOrderthat will filter onzope.schemafields in an interface; the above methods also list methods and non-schema attributes,getFieldsInOrderonly listszope.schemaspecific attribute types:If you defined the schema through-the-web, you may not know how to look up the interface for your type. You can also retrieve the schema interface through the Factory Type Information, or FTI for short:
where
schemanow holds your interface.