code: def safe_service(attr, default_value=None):
      '''A **method** decorator for creating safe services.
  
      Given an attribute name, this returns a decorator for creating
      safe services. Namely, if a service that is not yet available is
      requested (like a database connection), then ``safe_service`` will
      log any errors and set the given attribute to ``default_value``.
  
      :param str attr: attribute name
      :param object default_value: default value to set
      :rtype: decorator
      '''
      def _(fun):
          @functools.wraps(fun)
          def run(self):
              try:
                  return fun(self)
              except:
                  logger.error(traceback.format_exc())
                  setattr(self, attr, default_value)
          return run
      return f safe_service(attr, default_value=None):
      '''A **method** decorator for creating safe services.
  
      Given an attribute name, this returns a decorator for creating
      safe services. Namely, if a service that is not yet available is
      requested (like a database connection), then ``safe_service`` will
      log any errors and set the given attribute to ``default_value``.
  
      :param str attr: attribute name
      :param object default_value: default value to set
      :rtype: decorator
      '''
      def _(fun):
          @functools.wraps(fun)
          def run(self):
              try:
                  return fun(self)
              except:
                  logger.error(traceback.format_exc())
                  setattr(self, attr, default_value)
          return run
      return _
docs: A **method** decorator for creating safe services.
  
      Given an attribute name, this returns a decorator for creating
      safe services. Namely, if a service that is not yet available is
      requested (like a database connection), then ``safe_service`` will
      log any errors and set the given attribute to ``default_value``.
  
      :param str attr: attribute name
      :param object default_value: default value to set
      :rtype: decorator