equal
deleted
inserted
replaced
1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 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 |
24 from yams.schema import role_name |
24 from yams.schema import role_name |
25 |
25 |
26 from cubicweb import ValidationError |
26 from cubicweb import ValidationError |
27 from cubicweb.server import Service |
27 from cubicweb.server import Service |
28 from cubicweb.predicates import match_user_groups, match_kwargs |
28 from cubicweb.predicates import match_user_groups, match_kwargs |
|
29 |
29 |
30 |
30 class StatsService(Service): |
31 class StatsService(Service): |
31 """Return a dictionary containing some statistics about the repository |
32 """Return a dictionary containing some statistics about the repository |
32 resources usage. |
33 resources usage. |
33 """ |
34 """ |
159 |
160 |
160 return user |
161 return user |
161 |
162 |
162 |
163 |
163 class SourceSynchronizationService(Service): |
164 class SourceSynchronizationService(Service): |
164 """Force synchronization of a datafeed source""" |
165 """Force synchronization of a datafeed source. Actual synchronization is done |
|
166 asynchronously, this will simply create and return the entity which will hold the import |
|
167 log. |
|
168 """ |
165 __regid__ = 'source-sync' |
169 __regid__ = 'source-sync' |
166 __select__ = Service.__select__ & match_user_groups('managers') |
170 __select__ = Service.__select__ & match_user_groups('managers') |
167 |
171 |
168 def call(self, source_eid): |
172 def call(self, source_eid): |
169 source_entity = self._cw.entity_from_eid(source_eid) |
173 source = self._cw.repo.sources_by_eid[source_eid] |
170 repo = self._cw.repo # Service are repo side only. |
174 result = source.pull_data(self._cw, force=True, async=True) |
171 with repo.internal_cnx() as cnx: |
175 return result['import_log_eid'] |
172 source = repo.sources_by_uri[source_entity.name] |
|
173 source.pull_data(cnx) |
|
174 |
|