#!/usr/bin/env python
# encoding: utf-8
"""
utils.py

Created by QingFeng on 2007-12-02.
Copyright (c) 2007 yanxu. All rights reserved.
"""
import logging.config
from xbaydnsweb.web.models import *
from xbaydns.tools.namedconf import *

log = logging.getLogger('xbaydnsweb.web.utils')
logging.basicConfig(level=logging.DEBUG)

def saveAllConf(path):
    nc = NamedConf()
    for acl in Acl.objects.all():
        matchs=map(lambda x:x.aclMatch,
                AclMatch.objects.filter(acl=acl))
        nc.addAcl(acl.aclName,matchs)
    for view in View.objects.all():
        view_matchs=map(lambda x:x.viewMatch,
                ViewMatchClient.objects.filter(view=view))
        nc.addView(view.viewName,view_matchs)
    domain_matchs = map(lambda x:x.zone,Domain.objects.all())
    nc.addDomain(domain_matchs)
    nc.save(path)

#!/usr/bin/env python
# encoding: utf-8
"""
utils.py

Created by QingFeng on 2007-12-02.
Copyright (c) 2007 yanxu. All rights reserved.
"""
import logging.config
from xbaydnsweb.web.models import *
from xbaydns.tools.namedconf import *

log = logging.getLogger('xbaydnsweb.web.utils')
logging.basicConfig(level=logging.DEBUG)

def saveAllConf(path):
    nc = NamedConf()
    for acl in Acl.objects.all():
        matchs=map(lambda x:x.aclMatch,
                AclMatch.objects.filter(acl=acl))
        nc.addAcl(acl.aclName,matchs)
    for view in View.objects.all():
        for vmc in ViewMatchClient.objects.filter(view=view):
            view_matchs=map(lambda x:x.aclName,vmc.acl.all())
            nc.addView(view.viewName,view_matchs)
    domain_matchs = map(lambda x:x.zone,Domain.objects.all())
    nc.addDomain(domain_matchs)
    nc.save(path)

修正了由于view和acl关联,导致测试错误的问题