OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 class DataSource(object): | 6 class DataSource(object): |
7 ''' | 7 ''' |
8 Defines an abstraction for all DataSources. | 8 Defines an abstraction for all DataSources. |
9 | 9 |
10 DataSources must have two public methods, get and Refresh. A DataSource is | 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). | 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 | 12 Anything in the ServerInstance can be used by the DataSource. Request is None |
13 when DataSources are created for Refresh. | 13 when DataSources are created for Refresh. |
14 | 14 |
15 DataSources are used to provide templates with access to data. DataSources may | 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 | 16 not access other DataSources and any logic or data that is useful to other |
17 DataSources must be moved to a different class. | 17 DataSources must be moved to a different class. |
18 ''' | 18 ''' |
19 def __init__(self, server_instance, request): | 19 def __init__(self, server_instance, request): |
20 pass | 20 pass |
21 | 21 |
22 def GetRefreshPaths(self): | 22 def Refresh(self): |
23 '''Returns a list of paths to query | 23 '''Refreshes the cache of data this source provides. Should return a Future |
24 (relative to _refresh/<data_source_name>/) with the task queue in order | |
25 to refresh this DataSource's data set. Any paths listed here will be | |
26 routed to the DataSource Refresh method in a taskqueue task request. | |
27 ''' | |
28 return [''] | |
29 | |
30 def Refresh(self, path=None): | |
31 '''Handles _refresh requests to this DataSource. Should return a Future | |
32 indicating the success or failure of the refresh.''' | 24 indicating the success or failure of the refresh.''' |
not at google - send to devlin
2015/06/04 22:40:45
should probably be "which resolves to" not "indica
Ken Rockot(use gerrit already)
2015/06/05 00:21:50
Done.
| |
33 raise NotImplementedError(self.__class__) | 25 raise NotImplementedError(self.__class__) |
34 | 26 |
35 def get(self, key): | 27 def get(self, key): |
36 '''Returns a dictionary or list that can be consumed by a template. Called | 28 '''Returns a dictionary or list that can be consumed by a template. Called |
37 on an offline file system and can only access files in the cache. | 29 on an offline file system and can only access files in the cache. |
38 ''' | 30 ''' |
39 raise NotImplementedError(self.__class__) | 31 raise NotImplementedError(self.__class__) |
OLD | NEW |