Warning
Starting from CubicWeb version 4.0 all code related to generating html views has been moved to the Cube cubicweb_web.
If you want to migrate a project from 3.38 to 4.* while still using all the
html views you need to both install the cubicweb_web cube AND add it to
your dependencies and run add_cube('web')
.
cubicweb_web can be installed from pypi this way:
pip install cubicweb_web
We donât plan to maintain the features in cubicweb_web in the long run; we are moving to a full javascript frontend using both cubicweb_api (which exposes a HTTP API) and @cubicweb/client as a frontend javascript toolkit.
In the long run cubicweb_api will be merged inside of CubicWeb.
RQL search bar#
The RQL search bar is a visual component, hidden by default, the tiny search input being enough for common use cases.
An autocompletion helper is provided to help you type valid queries, both in terms of syntax and in terms of schema validity.
- class cubicweb_web.views.magicsearch.RQLSuggestionsBuilder(*args, **kwargs)[source]#
This component was previously used by the rql_suggest ajax function to provide completion to the search bar. It is now deprecated in favor of the cubicweb.rqlsuggestions.RQLSuggestionsBuilder class.
How search is performed#
You can use the rql search bar to either type RQL queries, plain text queries or standard shortcuts such as <EntityType> or <EntityType> <attrname> <value>.
Ultimately, all queries are translated to rql since itâs the only
language understood on the server (data) side. To transform the user
query into RQL, CubicWeb uses the so-called magicsearch component,
defined in cubicweb_web.views.magicsearch
, which in turn
delegates to a number of query preprocessor that are responsible of
interpreting the user query and generating corresponding RQL.
The code of the main processor loop is easy to understand:
for proc in self.processors:
try:
return proc.process_query(uquery, req)
except (RQLSyntaxError, BadRQLQuery):
pass
The idea is simple: for each query processor, try to translate the query. If it fails, try with the next processor, if it succeeds, weâre done and the RQL query will be executed.