def twitter_request(self, path, callback, access_token=None,
                      post_args=None, **args):
    if path.startswith('http:') or path.startswith('https:'):
      # Raw urls are useful for e.g. search which doesn't follow the
      # usual pattern: http://search.twitter.com/search.json
      url = path
    else:
      url = "http://api.twitter.com/1" + path + ".json"
    # Add the OAuth resource request signature if we have credentials
    if access_token:
      all_args = {}
      all_args.update(args)
      if path != self.UPDATE_WITH_MEDIA_URL:
        all_args.update(post_args or {})
      method = "POST" if post_args is not None else "GET"
      oauth = self._oauth_request_parameters(
          url, access_token, all_args, method=method)
      args.update(oauth)
      if post_args and path != self.UPDATE_WITH_MEDIA_URL:
        args.update(post_args)
    if args:
      url += "?" + urllib.urlencode(args)

    body = None
    if path == self.UPDATE_WITH_MEDIA_URL:
      msg = MIMEMultipart("form-data")
      for arg in post_args:
        if arg == 'media[]':
          mime_image = MIMEImage(post_args[arg],
              _encoder = email.encoders.encode_noop)
          mime_image.add_header("Content-Disposition", "form-data",
              name="media[]", filename="media[]")
          mime_image.add_header("Content-Length", str(len(post_args[arg])))
          msg.attach(mime_image)
        else:
          mime_text = MIMEText(post_args[arg])
          mime_text.add_header("Content-Disposition", "form-data", name=arg)
          mime_text.set_charset("utf-8")
          msg.attach(mime_text)
      body = msg.as_string()

    response = content_remote.get_url(url, post=(post_args is not None),
        body=body)
    self._on_twitter_request(callback, response)
Common code for git_pillar/winrepo to handle locking and checking out
dataset/ETHPy150Open mimecuvalo/helloworld/controllers/twitter.py/TwitterHandler.twitter_request--crossover with--dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/GitBase.do_checkout