Last active
August 29, 2015 14:01
-
-
Save valdergallo/df0d56c7bb935ca4022e to your computer and use it in GitHub Desktop.
Design Patterns Catalog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchCatalog(object): | |
""" | |
- Design Patterns Catalog | |
- https://github.com/faif/python-patterns/blob/master/catalog.py | |
""" | |
def __new__(self, request, application, keywords): | |
search_function = getattr(self, '%s_search' % application, False) | |
if keywords == 'Search...': | |
keywords = '' | |
if search_function: | |
try: | |
results = search_function(request, keywords) | |
except (UnicodeError, ValueError, TypeError): | |
raise ValueError("Invalid value") | |
else: | |
results = {} | |
return results | |
@staticmethod | |
def proposal_search(request, keywords): | |
pass | |
@staticmethod | |
def cpo_search(request, keywords): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment