code: def create_jinja_environment(self):
          
          options = dict(self.jinja_options)
          if 'autoescape' not in options:
              options['autoescape'] = self.select_jinja_autoescape
          rv = SandboxedEnvironment(self, **options)
          rv.globals.update(
              url_for=url_for,
              get_flashed_messages=get_flashed_messages,
              config=self.config,  # FIXME: Sandboxed templates shouldn't access full config
              # request, session and g are normally added with the
              # context processor for efficiency reasons but for imported
              # templates we also want the proxies in there.
              request=request,
              session=session,
              g=g  # FIXME: Similarly with g: no access for sandboxed templates
          )
          rv.filters['tojson'] = _tojson_filter
          return rv
docs: Creates the Jinja2 environment based on :attr:`jinja_options`
          and :meth:`select_jinja_autoescape`.  Since 0.7 this also adds
          the Jinja2 globals and filters after initialization.  Override
          this function to customize the behavior.