pylons.decorators.util
Covered: 15 lines
Missed: 0 lines
Skipped 3 lines
Percent: 100 %

     1

    """Decorator internal utilities"""

     2

    import pylons

     3

    from pylons.controllers import WSGIController

     4

     5

    def get_pylons(decorator_args):

     6

        """Return the `pylons` object: either the :mod`~pylons` module or

     7

        the :attr:`~WSGIController._py_object` equivalent, searching a

     8

        decorator's *args for the latter

     9

    10

        :attr:`~WSGIController._py_object` is more efficient as it provides

    11

        direct access to the Pylons global variables.

    12

        """

    13

        if decorator_args:

    14

            controller = decorator_args[0]

    15

            if isinstance(controller, WSGIController):

    16

                return controller._py_object

    17

        return pylons

    18