1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 class DataSource(object):
8 Defines an abstraction for all DataSources.
10 DataSources must have two public methods, get and Refresh. A DataSource is
11 initialized with a ServerInstance and a Request (defined in servlet.py).
12 Anything in the ServerInstance can be used by the DataSource. Request is None
13 when DataSources are created for Refresh.
15 DataSources are used to provide templates with access to data. DataSources may
16 not access other DataSources and any logic or data that is useful to other
17 DataSources must be moved to a different class.
19 def __init__(self
, server_instance
, request
):
23 '''Refreshes the cache of data this source provides. Should return a Future
24 which resolves to a boolean indicating the success or failure of the
27 raise NotImplementedError(self
.__class
__)
30 '''Returns a dictionary or list that can be consumed by a template. Called
31 on an offline file system and can only access files in the cache.
33 raise NotImplementedError(self
.__class
__)