server/sources/pyrorql.py
changeset 6945 28bf94d062a9
parent 6944 0cf10429ad39
child 6946 e350771c23a3
equal deleted inserted replaced
6944:0cf10429ad39 6945:28bf94d062a9
   121     )
   121     )
   122 
   122 
   123     PUBLIC_KEYS = AbstractSource.PUBLIC_KEYS + ('base-url',)
   123     PUBLIC_KEYS = AbstractSource.PUBLIC_KEYS + ('base-url',)
   124     _conn = None
   124     _conn = None
   125 
   125 
   126     def __init__(self, repo, source_config, *args, **kwargs):
   126     def __init__(self, repo, source_config, eid=None):
   127         AbstractSource.__init__(self, repo, source_config, *args, **kwargs)
   127         AbstractSource.__init__(self, repo, source_config, eid)
   128         # XXX get it through pyro if unset
   128         self.update_config(None, self.check_conf_dict(eid, source_config,
   129         baseurl = source_config.get('base-url')
   129                                                       fail_if_unknown=False))
   130         if baseurl and not baseurl.endswith('/'):
       
   131             source_config['base-url'] += '/'
       
   132         self.config = source_config
       
   133         myoptions = (('%s.latest-update-time' % self.uri,
   130         myoptions = (('%s.latest-update-time' % self.uri,
   134                       {'type' : 'int', 'sitewide': True,
   131                       {'type' : 'int', 'sitewide': True,
   135                        'default': 0,
   132                        'default': 0,
   136                        'help': _('timestamp of the latest source synchronization.'),
   133                        'help': _('timestamp of the latest source synchronization.'),
   137                        'group': 'sources',
   134                        'group': 'sources',
   138                        }),)
   135                        }),)
   139         register_persistent_options(myoptions)
   136         register_persistent_options(myoptions)
   140         self._query_cache = TimedCache(1800)
   137         self._query_cache = TimedCache(1800)
   141         self._skip_externals = check_yn(None, 'skip-external-entities',
   138 
   142                                         source_config.get('skip-external-entities', False))
   139     def update_config(self, source_entity, processed_config):
       
   140         """update configuration from source entity"""
       
   141         # XXX get it through pyro if unset
       
   142         baseurl = processed_config.get('base-url')
       
   143         if baseurl and not baseurl.endswith('/'):
       
   144             processed_config['base-url'] += '/'
       
   145         self.config = processed_config
       
   146         self._skip_externals = processed_config['skip-external-entities']
   143 
   147 
   144     def reset_caches(self):
   148     def reset_caches(self):
   145         """method called during test to reset potential source caches"""
   149         """method called during test to reset potential source caches"""
   146         self._query_cache = TimedCache(1800)
   150         self._query_cache = TimedCache(1800)
   147 
   151