/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-10 19:37:20 UTC
  • mfrom: (4222.3.15 username)
  • Revision ID: pqm@pqm.ubuntu.com-20090410193720-nyej7ft1k2yoyhui
(Jelmer) Prompt for user names for http if they are not in the
        configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1127
1127
        if user is None:
1128
1128
            user = auth_conf.get_user(auth['protocol'], auth['host'],
1129
1129
                                      port=auth['port'], path=auth['path'],
1130
 
                                      realm=realm)
 
1130
                                      realm=realm, ask=True,
 
1131
                                      prompt=self.build_username_prompt(auth))
1131
1132
        if user is not None and password is None:
1132
1133
            password = auth_conf.get_password(
1133
1134
                auth['protocol'], auth['host'], user, port=auth['port'],
1154
1155
        prompt += ' password'
1155
1156
        return prompt
1156
1157
 
 
1158
    def _build_username_prompt(self, auth):
 
1159
        """Build a prompt taking the protocol used into account.
 
1160
 
 
1161
        The AuthHandler is used by http and https, we want that information in
 
1162
        the prompt, so we build the prompt from the authentication dict which
 
1163
        contains all the needed parts.
 
1164
 
 
1165
        Also, http and proxy AuthHandlers present different prompts to the
 
1166
        user. The daughter classes should implements a public
 
1167
        build_username_prompt using this method.
 
1168
        """
 
1169
        prompt = '%s' % auth['protocol'].upper() + ' %(host)s'
 
1170
        realm = auth['realm']
 
1171
        if realm is not None:
 
1172
            prompt += ", Realm: '%s'" % realm
 
1173
        prompt += ' username'
 
1174
        return prompt
 
1175
 
1157
1176
    def http_request(self, request):
1158
1177
        """Insert an authentication header if information is available"""
1159
1178
        auth = self.get_auth(request)
1385
1404
    def build_password_prompt(self, auth):
1386
1405
        return self._build_password_prompt(auth)
1387
1406
 
 
1407
    def build_username_prompt(self, auth):
 
1408
        return self._build_username_prompt(auth)
 
1409
 
1388
1410
    def http_error_401(self, req, fp, code, msg, headers):
1389
1411
        return self.auth_required(req, headers)
1390
1412
 
1416
1438
        prompt = 'Proxy ' + prompt
1417
1439
        return prompt
1418
1440
 
 
1441
    def build_username_prompt(self, auth):
 
1442
        prompt = self._build_username_prompt(auth)
 
1443
        prompt = 'Proxy ' + prompt
 
1444
        return prompt
 
1445
 
1419
1446
    def http_error_407(self, req, fp, code, msg, headers):
1420
1447
        return self.auth_required(req, headers)
1421
1448