def generateZoneFile(directory): for c in Category.select(): z = dns.zone.Zone(dns.name.from_text('')) if c.GeoDNSDomain is None: continue for cc in Country.select(): hosts = cc.hosts generateOneCountry(c, z, hosts) z.to_file(os.path.join(directory, u'zone-' + c.GeoDNSDomain))
def setup_category_topdir_cache(): cache = {} for c in list(Category.select()): cache[c.id] = len(c.topdir.name)+1 # include trailing / return cache