2.3. Debugging RQL¶
2.3.1. Available levels¶
Server debugging flags. They may be combined using binary operators.
- cubicweb.server.DBG_NONE = 0¶
no debug information
- cubicweb.server.DBG_RQL = 1¶
rql execution information
- cubicweb.server.DBG_SQL = 2¶
executed sql
- cubicweb.server.DBG_REPO = 4¶
repository events
- cubicweb.server.DBG_HOOKS = 16¶
hooks
- cubicweb.server.DBG_OPS = 32¶
operations
- cubicweb.server.DBG_MORE = 128¶
more verbosity
- cubicweb.server.DBG_ALL = 247¶
all level enabled
2.3.2. Enable verbose output¶
To debug your RQL statements, it can be useful to enable a verbose output:
from cubicweb import server
server.set_debug(server.DBG_RQL|server.DBG_SQL|server.DBG_ALL)
Another example showing how to debug hooks at a specific code site:
from cubicweb.server import debugged, DBG_HOOKS
with debugged(DBG_HOOKS):
person.cw_set(works_for=company)
2.3.3. Detect largest RQL queries¶
See Profiling and performance chapter (see Profiling).
2.3.4. API¶
- class cubicweb.server.debugged(debugmode)[source]¶
Context manager and decorator to help debug the repository.
It can be used either as a context manager:
>>> with debugged('DBG_RQL | DBG_REPO'): ... # some code in which you want to debug repository activity, ... # seing information about RQL being executed an repository events.
or as a function decorator:
>>> @debugged('DBG_RQL | DBG_REPO') ... def some_function(): ... # some code in which you want to debug repository activity, ... # seing information about RQL being executed an repository events
The debug mode will be reset to its original value when leaving the “with” block or the decorated function.