logo

Personal tools
Vasudeva Documentation Recipes Archetypes - getDictFromSchema
Document Actions

Archetypes - getDictFromSchema

Convenience function to grab Archetype object variables as a dictionary. (http://blog.99hats.com/categorylist_html?cat_id=2)


def getDictFromSchema(self):
    """ get variables from schema """
    vars={}
    for key, val in self.Schema().items():
    vars[key]=val.getRaw(self)
    return vars

Egads! That only works for Archetypes 1.2.x, to work with 1.3.x use:

    def getDictFromSchema(self):
        """ get variables from schema """
        vars={}
        schema = self.aq_base.Schema() # been warned to strip acquisition
        for key in schema.fields():
            name       = key.getName()
            vars[name] = schema[name].get(self)
        return vars

Renamed getVarsFromSchema to getDictFromSchema.

page created by admin last modified 2004-08-08 22:11