hooks/syncschema.py
changeset 8943 58b3b2d9c965
parent 8821 c4aa23af0baa
child 9080 f0c00b07799a
child 9299 c5eed908117d
child 9559 072429be2d95
equal deleted inserted replaced
8942:0f60f1061a2e 8943:58b3b2d9c965
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   214         rebuildinfered = self.session.data.get('rebuild-infered', True)
   214         rebuildinfered = self.session.data.get('rebuild-infered', True)
   215         repo = self.session.repo
   215         repo = self.session.repo
   216         # commit event should not raise error, while set_schema has chances to
   216         # commit event should not raise error, while set_schema has chances to
   217         # do so because it triggers full vreg reloading
   217         # do so because it triggers full vreg reloading
   218         try:
   218         try:
   219             repo.set_schema(repo.schema, rebuildinfered=rebuildinfered)
   219             if rebuildinfered:
       
   220                 repo.schema.rebuild_infered_relations()
       
   221             # trigger vreg reload
       
   222             repo.set_schema(repo.schema)
   220             # CWUser class might have changed, update current session users
   223             # CWUser class might have changed, update current session users
   221             cwuser_cls = self.session.vreg['etypes'].etype_class('CWUser')
   224             cwuser_cls = self.session.vreg['etypes'].etype_class('CWUser')
   222             for session in repo._sessions.itervalues():
   225             for session in repo._sessions.itervalues():
   223                 session.user.__class__ = cwuser_cls
   226                 session.user.__class__ = cwuser_cls
   224         except Exception:
   227         except Exception: