code: def build_access_required(function_or_param_name):
      
      def get_wrapper(param_name, f):
          @functools.wraps(f)
          def wrapped(*args, **kwargs):
              g.build = can_user_access_build(param_name)
              if not utils.is_production():
                  # Insert a sleep to emulate page loading in production.
                  time.sleep(0.5)
              return f(*args, **kwargs)
          return wrapped
  
      if isinstance(function_or_param_name, basestring):
          return lambda f: get_wrapper(function_or_param_name, f)
      else:
          return get_wrapper('id', function_or_param_name)
docs: Decorator ensures user has access to the build ID in the request.
  
      May be used in two ways:
  
          @build_access_required
          def my_func(build):
              ...
  
          @build_access_required('custom_build_id_param')
          def my_func(build):
              ...
  
      Always calls the given function with the models.Build entity as the
      first positional argument.