|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +from zope.interface import implementer |
| 14 | + |
| 15 | +from warehouse.search import interfaces, tasks |
| 16 | + |
| 17 | + |
| 18 | +@implementer(interfaces.ISearchService) |
| 19 | +class SearchService: |
| 20 | + def __init__(self, **kwargs): |
| 21 | + pass |
| 22 | + |
| 23 | + @classmethod |
| 24 | + def create_service(cls, context, request): |
| 25 | + return cls() |
| 26 | + |
| 27 | + def reindex(self, config, projects_to_update): |
| 28 | + for project in projects_to_update: |
| 29 | + config.task(tasks.reindex_project).delay(project.normalized_name) |
| 30 | + |
| 31 | + def unindex(self, config, projects_to_delete): |
| 32 | + for project in projects_to_delete: |
| 33 | + config.task(tasks.unindex_project).delay(project.normalized_name) |
| 34 | + |
| 35 | + |
| 36 | +@implementer(interfaces.ISearchService) |
| 37 | +class NullSearchService: |
| 38 | + def __init__(self, **kwargs): |
| 39 | + pass |
| 40 | + |
| 41 | + @classmethod |
| 42 | + def create_service(cls, context, request): |
| 43 | + return cls() |
| 44 | + |
| 45 | + def reindex(self, config, projects_to_update): |
| 46 | + pass |
| 47 | + |
| 48 | + def unindex(self, config, projects_to_delete): |
| 49 | + pass |
0 commit comments