server/sources/pyrorql.py
changeset 6632 78878f5a8166
parent 6626 5c20a005bddc
child 6652 592c88c8f018
equal deleted inserted replaced
6631:26c303c3f1aa 6632:78878f5a8166
   137         ('pyro-ns-group',
   137         ('pyro-ns-group',
   138          {'type' : 'string',
   138          {'type' : 'string',
   139           'default': None,
   139           'default': None,
   140           'help': 'Pyro name server\'s group where the repository will be \
   140           'help': 'Pyro name server\'s group where the repository will be \
   141 registered. If not set, default to the value from all_in_one.conf.',
   141 registered. If not set, default to the value from all_in_one.conf.',
   142           'group': 'pyro-source', 'level': 1,
   142           'group': 'pyro-source', 'level': 2,
   143           }),
   143           }),
   144         ('synchronization-interval',
   144         ('synchronization-interval',
   145          {'type' : 'int',
   145          {'type' : 'int',
   146           'default': 5*60,
   146           'default': 5*60,
   147           'help': 'interval between synchronization with the external \
   147           'help': 'interval between synchronization with the external \
   193         """method called during test to reset potential source caches"""
   193         """method called during test to reset potential source caches"""
   194         self._query_cache = TimedCache(1800)
   194         self._query_cache = TimedCache(1800)
   195 
   195 
   196     def last_update_time(self):
   196     def last_update_time(self):
   197         pkey = u'sources.%s.latest-update-time' % self.uri
   197         pkey = u'sources.%s.latest-update-time' % self.uri
   198         rql = 'Any V WHERE X is CWProperty, X value V, X pkey %(k)s'
       
   199         session = self.repo.internal_session()
   198         session = self.repo.internal_session()
   200         try:
   199         try:
   201             rset = session.execute(rql, {'k': pkey})
   200             rset = session.execute('Any V WHERE X is CWProperty, X value V, X pkey %(k)s',
       
   201                                    {'k': pkey})
   202             if not rset:
   202             if not rset:
   203                 # insert it
   203                 # insert it
   204                 session.execute('INSERT CWProperty X: X pkey %(k)s, X value %(v)s',
   204                 session.execute('INSERT CWProperty X: X pkey %(k)s, X value %(v)s',
   205                                 {'k': pkey, 'v': u'0'})
   205                                 {'k': pkey, 'v': u'0'})
   206                 session.commit()
   206                 session.commit()