doc/book/annexes/rql/debugging.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 12 Feb 2016 10:09:13 +0100
changeset 11108 c14087d08698
parent 10491 c67bcee93248
child 12716 f5300acd8f4f
permissions -rw-r--r--
[migration] don't ask confirm for those sql queries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     2
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     3
.. _DEBUGGING:
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     4
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     5
Debugging RQL
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     6
-------------
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     7
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     8
Available levels
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     9
~~~~~~~~~~~~~~~~
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    10
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    11
Server debugging flags. They may be combined using binary operators.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    12
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    13
.. autodata:: cubicweb.server.DBG_NONE
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    14
.. autodata:: cubicweb.server.DBG_RQL
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    15
.. autodata:: cubicweb.server.DBG_SQL
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    16
.. autodata:: cubicweb.server.DBG_REPO
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    17
.. autodata:: cubicweb.server.DBG_MS
8626
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    18
.. autodata:: cubicweb.server.DBG_HOOKS
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    19
.. autodata:: cubicweb.server.DBG_OPS
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    20
.. autodata:: cubicweb.server.DBG_MORE
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    21
.. autodata:: cubicweb.server.DBG_ALL
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    22
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    23
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    24
Enable verbose output
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    25
~~~~~~~~~~~~~~~~~~~~~
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    26
7079
6024de6094f6 [doc] fix rql/debugging.rst and server.__init__ docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5924
diff changeset
    27
To debug your RQL statements, it can be useful to enable a verbose output:
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    28
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    29
.. sourcecode:: python
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    30
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    31
    from cubicweb import server
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    32
    server.set_debug(server.DBG_RQL|server.DBG_SQL|server.DBG_ALL)
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    33
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    34
.. autofunction:: cubicweb.server.set_debug
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7079
diff changeset
    35
8626
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    36
Another example showing how to debug hooks at a specific code site:
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    37
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    38
.. sourcecode:: python
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    39
9558
1a719ca9c585 [doc/book] Fix typo in import
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8626
diff changeset
    40
    from cubicweb.server import debugged, DBG_HOOKS
8626
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    41
    with debugged(DBG_HOOKS):
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    42
        person.cw_set(works_for=company)
e2ba137b2bf9 [server] add debugging for Hooks & Operations (closes #2470048)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7529
diff changeset
    43
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    44
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    45
Detect largest RQL queries
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    46
~~~~~~~~~~~~~~~~~~~~~~~~~~~
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    47
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    48
See `Profiling and performance` chapter (see :ref:`PROFILING`).
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    49
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    50
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    51
API
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    52
~~~
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    53
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    54
.. autoclass:: cubicweb.server.debugged
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    55