当前位置: 首页>>代码示例>>Python>>正文


Python base.render函数代码示例

本文整理汇总了Python中nodetraq.lib.base.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: publish

    def publish(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Publish"
        c.selected_page = "dns"
        c.subpage = "publish"
        c.domain = domain

        prod = NodetraqCotendo()
        prod.GrabDNS(domain, 1)
        staging = NodetraqCotendo()
        staging.GrabDNS(domain, 1)

        results = ch.get_view('dns', 'configs')
        for r in results.rows:
            if r.value['environment'] == 'staging':
                staging.ImportDNS(r.value["config"], r.value["token"])
                break

        staging_config = staging.dns.config.splitlines(1)
        prod_config = prod.dns.config.splitlines(1)

        diff = ''.join(difflib.unified_diff(
                prod_config, staging_config, 'production', 'staging'))

        c.diff = diff
        return render('/dns/publish.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:25,代码来源:dns.py

示例2: index

    def index(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS"
        c.selected_page = "dns"
        c.subpage = "list"
        c.domain = domain

        cotendo = NodetraqCotendo()
        cotendo.GrabDNS(domain, 1)
        ch.select("nodetraq")

        # Sync views
        ch.sync_view('nodetraq/model/views')

        # Update CouchDB to have a copy of the latest dns entries.
        results = ch.get_view('dns', 'configs')
        doc = None
        for r in results.rows:
            if r.value['environment'] == 'staging':
                doc = couchdb.Document(r.value)
                cotendo.ImportDNS(r.value["config"], r.value['token'])
            if doc:
                if doc["config"] != cotendo.dns.config:
                    doc["config"] = cotendo.dns.config
                    doc["token"] = cotendo.dns.token
                    ch.save(doc)
        if not doc:
            doc = couchdb.Document({"doc_type": "dns",
                     "domain": domain,
                     "environment": "staging",
                     "token": cotendo.dns.token,
                     "config": cotendo.dns.config })
            ch.save(doc)

        c.records = cotendo.dns._entries
        return render('dns/list.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:35,代码来源:dns.py

示例3: index

    def index(self):
        c.title = 'Nodetraq -- Graphs'
        c.selected_page = 'graphs'
        c.subpage = 'index'

        c.graphs = Session.query(Graph).all()
        return render('/graphs/index.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:graphs.py

示例4: index

    def index(self):
        c.page = int(request.params['page'])\
                if 'page' in request.params else 1
        c.title = 'Nodetraq - Groups'
        c.selected_page = 'groups'
        c.subpage = 'list'
        c.heading = "Groups"
        c.filters = [
                { 'name': 'group', 'label': 'Group', 'type': 'text' }
            ]
        query, c.search_fields = get_fields_and_query(Session,
                Group, request.params)
        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url += '?' + request.environ['QUERY_STRING']
        c.group_count = query.count()

        c.link_append = '&' + urlencode(\
                [p for p in request.params.items()\
                    if p[0] != 'page'])
        if c.link_append == '&':
            c.link_append = None

        if 'show_all' in request.params:
            c.total_pages = 1
            c.current_page_count = 1
            c.groups = query.order_by('name').all()
        else:
            c.total_pages = (c.group_count+25-1)/25
            c.current_page_count = (c.page-1)*25
            c.groups = query.order_by('name')\
                    [c.current_page_count: c.current_page_count+25]

        c.all_groups, c.tag_sizes = self.get_tag_info()
        return render('/groups/list.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:35,代码来源:groups.py

示例5: index

    def index(self):
        c.title = 'Nodetraq - LoadBalancer'
        c.selected_page = 'loadbalancer'
        c.subpage = 'index'
        lb = LoadBalancer(ip='lb_iphere')
        pools = lb.get_pools()
        pools.sort()
        c.pool_count = len(pools)

        c.link_append = '&' + urlencode(
            [p for p in request.params.items()\
                 if p[0] != 'page'])
        if c.link_append == '&':
            c.link_append = None

        if 'show_all' in request.params:
            c.page = 1
            c.total_pages = 1
            c.current_page_count = 1
            c.members = self.get_members_status(Session, pools)
        else:
            c.page = int(request.params['page'])\
                    if 'page' in request.params else 1
            c.total_pages = (c.pool_count+25-1)/25
            c.current_page_count = (c.page-1)*25
            c.members = self.get_members_status(Session,
                    pools[c.current_page_count:c.current_page_count+25])

        return render('/loadbalancer/index.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:29,代码来源:loadbalancer.py

示例6: edit_studio

 def edit_studio(self, id):
     c.studio = Session.query(Studio).filter(Studio.id == id).first()
     c.title = "Nodetraq -- Edit Studio"
     c.header = c.studio.name
     c.selected_page = "nodes"
     c.subpage = "edit_studio"
     return render('/nodes/studios/edit.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:nodes.py

示例7: show_dbbackups

    def show_dbbackups(self):
        c.title = "Nodetraq -- Show Database Backups"
        c.selected_page = "nodes"
        c.subpage = "database"
        sort = None

        c.dbbackups = Session.query(NodeDatabaseBackup).all()
        if not 'sort' in request.params:
            sort = 'server'
        else:
            sort = request.params['sort']

        if sort == 'server':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.server.hostname)
        elif sort == 'storage':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.storage.hostname)
        elif sort == 'directory':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.directory)
        elif sort == 'enabled':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.enabled)

        c.sort = sort

        return render('/nodes/show_dbbackups.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:28,代码来源:nodes.py

示例8: show_game

    def show_game(self, id):
        c.game = Session.query(Game).filter(Game.id == id).first()
        c.title = "Nodetraq -- Game: %s" % c.game.name
        c.header = c.game.name
        c.selected_page = "nodes"
        c.subpage = "show_game"

        c.groups = [
            {'name': 'PE-1950', 'nodes': []},
            {'name': 'PE-2950', 'nodes': []},
            {'name': 'PE-R410', 'nodes': []},
            {'name': 'PE-R610', 'nodes': []},
            {'name': 'PE-R710', 'nodes': []},
            {'name': 'vm', 'nodes': []},
            {'name': 'unknown', 'nodes': []}
            ]

        group_list = lambda groups: [g.name for g in groups]
        for node in c.game.nodes:
            grouped = False
            for group in c.groups:
                if group['name'] in group_list(node.groups):
                    group['nodes'].append(node)
                    grouped = True

            if not grouped:
                c.groups[len(c.groups)-1]['nodes'].append(node)

        return render('/nodes/games/show.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:29,代码来源:nodes.py

示例9: rrd_file

    def rrd_file(self, id):
        response.content_type = 'text/plain'

        if id.isdigit():
            graph_data = Session.query(Graph)\
                .filter(Graph.id == int(id)).first()
        else:
            graph_data = Session.query(Graph)\
                .filter(Graph.name == id).first()

        c.graph = graph_data.filename[1:]
        hostnames = [n.hostname for n in graph_data.get_hosts()]

        c.datasource = generate_rrd_sequence_map(
            hostnames, graph_data.get_rrds())

        c.title = graph_data.name

        if len(c.datasource) == 2:
            c.colors = ['Lime', 'Red']
            c.brmod = 2
        else:
            c.colors = ['Lime', 'Teal', 'Maroon']
            c.brmod = 3

        return render('/graphs/graph.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:26,代码来源:graphs.py

示例10: add_record

    def add_record(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Add Record"
        c.selected_page = "dns"
        c.subpage = "add_record"
        c.domain = domain

        return render('dns/add_record.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:dns.py

示例11: add

    def add(self):
        c.group = Session.query(Group).filter(Group.id == id).first()
        c.title = 'Nodetraq - Group - Add'
        c.selected_page = 'groups'
        c.subpage = 'add'

        return render('/groups/add.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:groups.py

示例12: show

 def show(self, pool):
     c.title = 'Nodetraq - Loadbalancer - Show'
     c.selected_page = 'loadbalancer'
     c.subpage = 'show'
     lb = LoadBalancer(ip='your_lb_ip')
     c.members = self.get_members_status(Session, [pool])[0]
     return render('/loadbalancer/show.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:loadbalancer.py

示例13: index

    def index(self):
        c.title = 'Nodetraq - Network'
        c.selected_page = 'network'
        c.subpage = 'index'

        c.network_devices = Session.query(NetworkDevice).all()
        return render('/network/index.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:network.py

示例14: edit_record

    def edit_record(self, domain='yourdomainhere', type=None, host=''):
        c.title = "Nodetraq -- DNS - Edit Record"
        c.selected_page = "dns"
        c.subpage = "edit_record"
        c.domain = domain

        cotendo = NodetraqCotendo()
        cotendo.GrabDNS(domain, 1)
        # check if record exists, if it does, update it otherwise
        results = ch.get_view('dns', 'configs')
        doc = None
        for r in results.rows:
            if r.value['environment'] == 'staging':
                cotendo.ImportDNS(r.value["config"], r.value['token'])
                doc = couchdb.Document(r.value)
                break

        c.record = cotendo.dns.get_record(type, host)
        if not c.record:
            session['flash'] = "Not a valid record"
            session.save()
            return redirect(url(controller="dns",
                                action="index", domain=domain))

        return render('/dns/edit_record.mako')
开发者ID:seryl,项目名称:Nodetraq,代码行数:25,代码来源:dns.py

示例15: namelist

 def namelist(self, format='mako'):
     c.nodes = Session.query(Node.hostname).all()
     if format == 'json':
         response.content_type = 'application/json'
     elif format == 'xml':
         response.content_type = 'application/xml'
     return render('/nodes/namelist/list.' + format)
开发者ID:seryl,项目名称:Nodetraq,代码行数:7,代码来源:nodes.py


注:本文中的nodetraq.lib.base.render函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。