core.skeleton.adapter¶
Classes¶
Adapter class used to bind or use other databases and hook operations when working with a Skeleton. |
|
This Adapter implements a simple fulltext search on top of the datastore. |
Module Contents¶
- class core.skeleton.adapter.DatabaseAdapter¶
Adapter class used to bind or use other databases and hook operations when working with a Skeleton.
- providesFulltextSearch: bool = False¶
Set to True if we can run a fulltext search using this database.
- fulltextSearchGuaranteesQueryConstrains = False¶
Are results returned by meth:fulltextSearch guaranteed to also match the databaseQuery
- providesCustomQueries: bool = False¶
Indicate that we can run more types of queries than originally supported by datastore
- prewrite(skel, is_add, change_list=())¶
Hook being called on a add, edit or delete operation before the skeleton-specific action is performed.
The hook can be used to modifiy the skeleton before writing. The raw entity can be obainted using skel.dbEntity.
- Parameters:
action – Either contains “add”, “edit” or “delete”, depending on the operation.
skel (SkeletonInstance) – is the skeleton that is being read before written.
change_list (Iterable[str]) – is a list of bone names which are being changed within the write.
is_add (bool)
- write(skel, is_add, change_list=())¶
Hook being called on a write operations after the skeleton is written.
The raw entity can be obainted using skel.dbEntity.
- Parameters:
action – Either contains “add” or “edit”, depending on the operation.
skel (SkeletonInstance) – is the skeleton that is being read before written.
change_list (Iterable[str]) – is a list of bone names which are being changed within the write.
is_add (bool)
- delete(skel)¶
Hook being called on a delete operation after the skeleton is deleted.
- Parameters:
skel (SkeletonInstance)
- abstractmethod fulltextSearch(queryString, databaseQuery)¶
If this database supports fulltext searches, this method has to implement them. If it’s a plain fulltext search engine, leave ‘prop:fulltextSearchGuaranteesQueryConstrains’ set to False, then the server will post-process the list of entries returned from this function and drop any entry that cannot be returned due to other constrains set in ‘param:databaseQuery’. If you can obey every constrain set in that Query, we can skip this post-processing and save some CPU-cycles. :param queryString: the string as received from the user (no quotation or other safety checks applied!) :param databaseQuery: The query containing any constrains that returned entries must also match :return:
- Parameters:
queryString (str)
databaseQuery (core.db.Query)
- Return type:
list[core.db.Entity]
- class core.skeleton.adapter.ViurTagsSearchAdapter(min_length=2, max_length=50, substring_matching=False)¶
Bases:
DatabaseAdapterThis Adapter implements a simple fulltext search on top of the datastore.
On skel.write(), all words from String-/TextBones are collected with all min_length postfixes and dumped into the property viurTags. When queried, we’ll run a prefix-match against this property - thus returning entities with either an exact match or a match within a word.
- Example:
For the word “hello” we’ll write “hello”, “ello” and “llo” into viurTags. When queried with “hello” we’ll have an exact match. When queried with “hel” we’ll match the prefix for “hello” When queried with “ell” we’ll prefix-match “ello” - this is only enabled when substring_matching is True.
We’ll automatically add this adapter if a skeleton has no other database adapter defined.
- Parameters:
min_length (int)
max_length (int)
substring_matching (bool)
- providesFulltextSearch = True¶
Set to True if we can run a fulltext search using this database.
- fulltextSearchGuaranteesQueryConstrains = True¶
Are results returned by meth:fulltextSearch guaranteed to also match the databaseQuery
- min_length = 2¶
- max_length = 50¶
- substring_matching = False¶
- _tags_from_str(value)¶
Extract all words including all min_length postfixes from given string
- Parameters:
value (str)
- Return type:
set[str]
- prewrite(skel, *args, **kwargs)¶
Collect searchTags from skeleton and build viurTags
- Parameters:
skel (SkeletonInstance)
- fulltextSearch(queryString, databaseQuery)¶
Run a fulltext search
- Parameters:
queryString (str)
databaseQuery (core.db.Query)
- Return type:
list[core.db.Entity]