|
1 # copyright 2010-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """hooks for repository sources synchronization""" |
|
19 |
1 from yams.schema import role_name |
20 from yams.schema import role_name |
|
21 |
2 from cubicweb import ValidationError |
22 from cubicweb import ValidationError |
3 from cubicweb.selectors import is_instance |
23 from cubicweb.selectors import is_instance |
4 from cubicweb.server import SOURCE_TYPES, hook |
24 from cubicweb.server import SOURCE_TYPES, hook |
5 |
25 |
6 class SourceHook(hook.Hook): |
26 class SourceHook(hook.Hook): |
99 data = self.__data |
119 data = self.__data |
100 except AttributeError: |
120 except AttributeError: |
101 data = self.__data = self.get_data() |
121 data = self.__data = self.get_data() |
102 for schemacfg, source in data: |
122 for schemacfg, source in data: |
103 if source is None: |
123 if source is None: |
104 source = schemacfg.source |
124 source = schemacfg.cwsource.repo_source |
105 if session.added_in_transaction(schemacfg.eid): |
125 if session.added_in_transaction(schemacfg.eid): |
106 if not session.deleted_in_transaction(schemacfg.eid): |
126 if not session.deleted_in_transaction(schemacfg.eid): |
107 source.add_schema_config(schemacfg, checkonly=checkonly) |
127 source.add_schema_config(schemacfg, checkonly=checkonly) |
108 elif session.deleted_in_transaction(schemacfg.eid): |
128 elif session.deleted_in_transaction(schemacfg.eid): |
109 source.delete_schema_config(schemacfg, checkonly=checkonly) |
129 source.delete_schema_config(schemacfg, checkonly=checkonly) |