Logo Search packages:      
Sourcecode: zope-archetypes version File versions

def Archetypes::ArchetypeTool::ArchetypeTool::manage_updateSchema (   self,
  REQUEST = None 

Make sure all objects' schema are up to date

Definition at line 784 of file ArchetypeTool.py.

00784                                                :
        """Make sure all objects' schema are up to date"""

        out = StringIO()
        print >> out, 'Updating schema...'

        update_types = []
        if REQUEST is None:
            for t in self._types.keys():
                if self._types[t]['update']:
            update_all = 0
            for t in self._types.keys():
                if REQUEST.form.get(t, 0):
            update_all = REQUEST.form.get('update_all', 0)

        # Use the catalog's ZopeFindAndApply method to walk through
        # all objects in the portal.  This works much better than
        # relying on the catalog to find objects, because an object
        # may be uncatalogable because of its schema, and then you
        # can't update it if you require that it be in the catalog.
        catalog = getToolByName(self, 'portal_catalog')
        portal = getToolByName(self, 'portal_url').getPortalObject()
        meta_types = [_types[t]['name'] for t in update_types]
        if update_all:
            catalog.ZopeFindAndApply(portal, obj_metatypes=meta_types,
                search_sub=1, apply_func=self._updateObject)
            catalog.ZopeFindAndApply(portal, obj_metatypes=meta_types,
                search_sub=1, apply_func=self._updateChangedObject)
        for t in update_types:
            self._types[t]['update'] = 0
        self._p_changed = 1
        return out.getvalue()

    def _updateObject(self, o, path):

Generated by  Doxygen 1.6.0   Back to index