Changeset 1492 for trunk


Ignore:
Timestamp:
Nov 1, 2008, 4:21:49 AM (16 years ago)
Author:
broder
Message:

Display a helpful error on the website if a name has specifically been
reserved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web/code/validation.py

    r1473 r1492  
    273273        return None
    274274    try:
    275         f = open('/tmp/log', 'a')
    276         dns.resolver.query('%s.%s.' % (name, config.dns.domains[0]), 'A')
     275        hostname = '%s.%s.' % (name, config.dns.domains[0])
     276        try:
     277            dns.resolver.query(hostname, 'A')
     278        except dns.resolver.NoAnswer, e:
     279            # If we can get the TXT record, then we can verify it's
     280            # reserved. If this lookup fails, let it bubble up and be
     281            # dealt with
     282            answer = dns.resolver.query(hostname, 'TXT')
     283            txt = answer[0].strings[0]
     284            if txt.startswith('Reserved'):
     285                raise InvalidInput('name', name, 'The name you have requested has been %s. For more information, contact us at %s' % (txt, config.dns.contact))
     286
    277287        # If the hostname didn't exist, it would have thrown an
    278288        # exception by now - error out
Note: See TracChangeset for help on using the changeset viewer.