core.skeleton.adapter ===================== .. py:module:: core.skeleton.adapter Classes ------- .. autoapisummary:: core.skeleton.adapter.DatabaseAdapter core.skeleton.adapter.ViurTagsSearchAdapter Module Contents --------------- .. py:class:: DatabaseAdapter Adapter class used to bind or use other databases and hook operations when working with a Skeleton. .. py:attribute:: providesFulltextSearch :type: bool :value: False Set to True if we can run a fulltext search using this database. .. py:attribute:: fulltextSearchGuaranteesQueryConstrains :value: False Are results returned by `meth:fulltextSearch` guaranteed to also match the databaseQuery .. py:attribute:: providesCustomQueries :type: bool :value: False Indicate that we can run more types of queries than originally supported by datastore .. py:method:: 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`. :param action: Either contains "add", "edit" or "delete", depending on the operation. :param skel: is the skeleton that is being read before written. :param change_list: is a list of bone names which are being changed within the write. .. py:method:: 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`. :param action: Either contains "add" or "edit", depending on the operation. :param skel: is the skeleton that is being read before written. :param change_list: is a list of bone names which are being changed within the write. .. py:method:: delete(skel) Hook being called on a delete operation after the skeleton is deleted. .. py:method:: fulltextSearch(queryString, databaseQuery) :abstractmethod: 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: .. py:class:: ViurTagsSearchAdapter(min_length = 2, max_length = 50, substring_matching = False) Bases: :py:obj:`DatabaseAdapter` This 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. .. py:attribute:: providesFulltextSearch :value: True Set to True if we can run a fulltext search using this database. .. py:attribute:: fulltextSearchGuaranteesQueryConstrains :value: True Are results returned by `meth:fulltextSearch` guaranteed to also match the databaseQuery .. py:attribute:: min_length :value: 2 .. py:attribute:: max_length :value: 50 .. py:attribute:: substring_matching :value: False .. py:method:: _tags_from_str(value) Extract all words including all min_length postfixes from given string .. py:method:: prewrite(skel, *args, **kwargs) Collect searchTags from skeleton and build viurTags .. py:method:: fulltextSearch(queryString, databaseQuery) Run a fulltext search