--- a/sobjects/services.py Mon Nov 30 14:54:30 2015 +0100
+++ b/sobjects/services.py Wed Dec 09 16:15:00 2015 +0100
@@ -22,6 +22,7 @@
from six import text_type
from yams.schema import role_name
+
from cubicweb import ValidationError
from cubicweb.server import Service
from cubicweb.predicates import match_user_groups, match_kwargs
@@ -60,6 +61,7 @@
results['threads'] = [t.name for t in threading.enumerate()]
return results
+
class GcStatsService(Service):
"""Return a dictionary containing some statistics about the repository
resources usage.
@@ -156,3 +158,17 @@
'WHERE U login %(login)s', d, build_descr=False)
return user
+
+
+class SourceSynchronizationService(Service):
+ """Force synchronization of a datafeed source"""
+ __regid__ = 'source-sync'
+ __select__ = Service.__select__ & match_user_groups('managers')
+
+ def call(self, source_eid):
+ source_entity = self._cw.entity_from_eid(source_eid)
+ repo = self._cw.repo # Service are repo side only.
+ with repo.internal_cnx() as cnx:
+ source = repo.sources_by_uri[source_entity.name]
+ source.pull_data(cnx)
+