API

This part of the documentation documents all the public classes and functions in Flask-PonyWhoosh.

PonyWhoosh Class

PonyWhoosh Package

copyright:
  1. 2015-2016 by Jonathan S. Prieto & Ivan Felipe Rodriguez.
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.

Args:
*fields: all the fields indexed from the model. **kw: The options for each field, sortedby, stored ...
search(*arg, **kw)

Search function. This allows you to search using the following arguments.

Args:
*arg: The search string. **kw: The options available for searching: include_entity, add_wildcards, something, fields, except_fields, etc. These options were described previously.
Returns:
TYPE: Description

PonyWhooshIndex Class

PonyWhooshIndex Class

copyright:
  1. 2015-2016 by Jonathan S. Prieto & Ivan Felipe Rodriguez.
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.

This function search in every model registered. And portrays the result in a dictionary where the keys are the models.

Args:
pw (PonyWhoosh): This is where all the indexes are stored. *arg: The search string. **kw: The options available for a single search wildcards, something, fields, models, etc.
Returns:
TYPE: Dictionary with all the the results for the models.
flask_ponywhoosh.utils.search(model, *arg, **kw)

Summary

Args:
model (TYPE): Description *arg: Description **kw: Description
Returns:
TYPE: Description

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.