pylons
Covered: 1 lines
Missed: 25 lines
Skipped 13 lines
Percent: 3 %

     1

    """Base objects to be exported for use in Controllers"""

     2

    # Import pkg_resources first so namespace handling is properly done so the

     3

    # paste imports work

     4

    import pkg_resources

     5

     6

    from paste.registry import StackedObjectProxy

     7

     8

    from pylons.configuration import config

     9

    10

    __all__ = ['app_globals', 'cache', 'config', 'request', 'response',

    11

               'session', 'tmpl_context', 'url']

    12

    13

    def __figure_version():

    14

        try:

    15

            from pkg_resources import require

    16

            import os

    17

            # NOTE: this only works when the package is either installed,

    18

            # or has an .egg-info directory present (i.e. wont work with raw

    19

            # SVN checkout)

    20

            info = require('pylons')[0]

    21

            if os.path.dirname(os.path.dirname(__file__)) == info.location:

    22

                return info.version

    23

            else:

    24

                return '(not installed)'

    25

        except:

    26

            return '(not installed)'

    27

    28

    __version__ = __figure_version()

    29

    30

    app_globals = StackedObjectProxy(name="app_globals")

    31

    cache = StackedObjectProxy(name="cache")

    32

    request = StackedObjectProxy(name="request")

    33

    response = StackedObjectProxy(name="response")

    34

    session = StackedObjectProxy(name="session")

    35

    tmpl_context = StackedObjectProxy(name="tmpl_context or C")

    36

    url = StackedObjectProxy(name="url")

    37

    38

    translator = StackedObjectProxy(name="translator")

    39