API¶
This part of the documentation documents all the public classes and functions in Flask-PonyWhoosh.
PonyWhoosh Class¶
PonyWhoosh Package¶
| copyright: |
|
|---|---|
| license: | BSD (see LICENSE.md) |
-
class
flask_ponywhoosh.ponywhoosh.PonyWhoosh(app=None)¶ A top level class that allows to register indexes.
- Attributes:
- DEBUG (bool): Description
- indexes_path (str): this is the name where the folder of the indexes are going to be stored.
- route (TYPE): This config let you set the route for the url to run the html template.
- search_string_min_len (int): This item let you config the minimun string value possible to perform search.
- template_path (TYPE): Is the path where the folder of templates will be store.
- writer_timeout (int): Is the time when the writer should stop the searching.
-
create_index(index)¶ Creates and opens index folder for given index.
If the index already exists, it just opens it, otherwise it creates it first.
- Args:
- wh (TYPE): All the indexes stored.
-
delete_indexes()¶ This set to empty all the indixes registered.
- Returns:
- TYPE: This empty all the indexes.
-
indexes()¶ Summary
- Returns:
- TYPE: This returns all the indexes items stored.
-
init_app(app)¶ Initializes the App.
- Args:
- app (TYPE): Description
- Returns:
- TYPE: Description
-
register_index(index)¶ Registers a given index:
- Creates and opens an index for it (if it doesn’t exist yet)
- Sets some default values on it (unless they’re already set)
- Replaces query class of every index’s model by PonyWhoosheeQuery
- Args:
- wh (TYPE): Description
-
register_model(*fields, **kw)¶ Registers a single model for fulltext search. This basically creates a simple PonyWhooshIndex for the model and calls self.register_index on it.
-
search(*arg, **kw)¶ Search function. This allows you to search using the following arguments.
PonyWhooshIndex Class¶
PonyWhooshIndex Class¶
| copyright: |
|
|---|---|
| license: | BSD (see LICENSE.md) |
Utils Methods¶
-
flask_ponywhoosh.utils.delete_field(model, *arg)¶ Delete_field
- Args:
- model (TYPE): Is the model from where you want to delete an specific field. *arg: Fiedls.
- Returns:
- TYPE: model without the desired field.
-
flask_ponywhoosh.utils.full_search(pw, *arg, **kw)¶ This function search in every model registered. And portrays the result in a dictionary where the keys are the models.
View method¶
-
class
flask_ponywhoosh.views.IndexView(pw)¶ This is all the setting for the template index.html in the templates folder.
methods (list): POST and GET
-
dispatch_request()¶ This form is plugeable. That means that all what you need to do is to install the package and run the url :: /ponywhoosh/ (You may change it in the config) and get the results.
- Returns:
- Results: The results are sent to the template using bootstrap. They are renderized using whether a grid or a table, depending on what models did you register. By default the first field registered is considered the one that will be contained in the tittle of each searh result.
-