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


Python Component.select方法代码示例

本文整理汇总了Python中trac.ticket.model.Component.select方法的典型用法代码示例。如果您正苦于以下问题:Python Component.select方法的具体用法?Python Component.select怎么用?Python Component.select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.model.Component的用法示例。


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

示例1: post_process_request

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket'):
            ticket = data['ticket']

            # add custom fields to the ticket template context data
            data['milestones'] = self._sorted_milestones()
            data['components'] = [c.name for c in Component.select(self.env)]
            data['split_options'] = self._ticket_split_options(ticket)
            data['split_history'] = self._ticket_split_history(ticket)

        return template, data, content_type
开发者ID:trac-hacks,项目名称:trac-split-ticket,代码行数:13,代码来源:web_ui.py

示例2: process_admin_request

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
 def process_admin_request(self, req, cat, page, path_info):
     envs = DatamoverSystem(self.env).all_environments()
     components = [c.name for c in TicketComponent.select(self.env)]
     
     if req.method == 'POST':
         source_type = req.args.get('source')
         if not source_type or source_type not in ('component', 'all'):
             raise TracError, "Source type not specified or invalid"
         source = req.args.get(source_type)
         dest = req.args.get('destination')
         action = None
         if 'copy' in req.args.keys():
             action = 'copy'
         elif 'move' in req.args.keys():
             action = 'move'
         else:
             raise TracError, 'Action not specified or invalid'
             
         action_verb = {'copy':'Copied', 'move':'Moved'}[action]
         
         comp_filter = None
         if source_type == 'component':
             in_components = req.args.getlist('component')
             comp_filter = lambda c: c in in_components
         elif source_type == 'all':
             comp_filter = lambda c: True
         
         try:
             sel_components = [c for c in components if comp_filter(c)]
             dest_db = _open_environment(dest).get_db_cnx()
             for comp in sel_components:
                 copy_component(self.env, dest, comp, dest_db)
             dest_db.commit()
                 
             if action == 'move':
                 for comp in sel_components:
                     TicketComponent(self.env, comp).delete()
                 
             req.hdf['datamover.message'] = '%s components %s'%(action_verb, ', '.join(sel_components))
         except TracError, e:
             req.hdf['datamover.message'] = "An error has occured: \n"+str(e)
             self.log.warn(req.hdf['datamover.message'], exc_info=True)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:44,代码来源:component.py

示例3: test_exists

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
 def test_exists(self):
     """
     http://trac.edgewall.org/ticket/4247
     """
     for c in Component.select(self.env):
         self.assertEqual(c.exists, True)
开发者ID:zjj,项目名称:trac_hack,代码行数:8,代码来源:model.py

示例4: process_admin_request

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
 def process_admin_request(self, req, cat, page, path_info):
     components = [c.name for c in TicketComponent.select(self.env)]
     envs = DatamoverSystem(self.env).all_environments()
     
     if req.method == 'POST':
         source_type = req.args.get('source')
         if not source_type or source_type not in ('component', 'ticket', 'all', 'query'):
             raise TracError, "Source type not specified or invalid"
         source = req.args.get(source_type)
         dest = req.args.get('destination')
         action = None
         if 'copy' in req.args.keys():
             action = 'copy'
         elif 'move' in req.args.keys():
             action = 'move'
         else:
             raise TracError, 'Action not specified or invalid'
             
         action_verb = {'copy':'Copied', 'move':'Moved'}[action]
         
         # Double check the ticket number is actually a number
         if source_type == 'id':
             try:
                 int(source)
             except ValueError:
                 raise TracError('Value %r is not numeric'%source)
         
         self.log.debug('DatamoverTicketModule: Source is %s (%s)', source, source_type)
         
         query_string = {
             'ticket': 'id=%s'%source,
             'component': 'component=%s'%source,
             'all': 'id!=0',
             'query': source,
         }[source_type]
             
         try:
             # Find the ids we want
             ids = None
             if source_type == 'ticket': # Special case this pending #T4119
                 ids = [int(source)]
             else:
                 self.log.debug('DatamoverTicketModule: Running query %r', query_string)
                 ids = [x['id'] for x in Query.from_string(self.env, query_string).execute(req)]
                 self.log.debug('DatamoverTicketModule: Results: %r', ids)
                 
             dest_db = _open_environment(dest).get_db_cnx()
             for id in ids:
                 copy_ticket(self.env, dest, id, dest_db)
             dest_db.commit()
                 
             if action == 'move':
                 for id in ids:
                     Ticket(self.env, id).delete()
                 
             if ids:
                 req.hdf['datamover.message'] = '%s tickets %s'%(action_verb, ', '.join([str(n) for n in ids]))
             else:
                 req.hdf['datamover.message'] = 'No tickets %s'%(action_verb.lower())
         except TracError, e:
             req.hdf['datamover.message'] = "An error has occured: \n"+str(e)
             self.log.warn(req.hdf['datamover.message'], exc_info=True)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:64,代码来源:ticket.py

示例5: list_component_in_json

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
 def list_component_in_json(self):
     # stolen from trac.ticket.admin.py format: [(component,owner)]
     #components = [(c.name, c.owner) for c in TicketComponent.select(self.env)], [_('Name'), _('Owner')]
     components = [{'name':c.name,'owner':c.owner} for c in TicketComponent.select(self.env)]
     printout(json.dumps(components))
开发者ID:russellballestrini,项目名称:TicketFieldConfigPlugin,代码行数:7,代码来源:jsontracadmin.py

示例6: process_request

# 需要导入模块: from trac.ticket.model import Component [as 别名]
# 或者: from trac.ticket.model.Component import select [as 别名]
    def process_request(self, req):
        name = req.args.get('name')


        if not (name == 'query'):
            id = req.args.get('id')

        if name == 'ticket':
            ticket = Ticket(self.env, id)
            comm_num = 0
            attachment_num = len(self.get_attachments('ticket', id))
            ticket_log = self.changeLog(id)

            for log in ticket_log:
                if log[2] == 'comment' and log[4]:
                    comm_num += 1

            data = {'ticket': ticket,
                    'comm_num': comm_num,
                    'attachment_num': attachment_num}
            return 'bh_emb_ticket.html', data, None

        elif name == 'milestone':
            ticket_num = len(get_tickets_for_milestone(self.env, milestone=id))
            attachment_num = len(self.get_attachments('milestone', id))

            data = {'milestone': Milestone(self.env, id),
                    'product': self.env.product,
                    'ticket_number': ticket_num,
                    'attachment_number': attachment_num }
            return 'bh_emb_milestone.html', data, None

        elif name == 'products':
            product = Product(self.env, {'prefix': id})
            ticket_num = len(self.get_tickets_for_product(self.env, id))
            product_env = ProductEnvironment(self.env, product.prefix)
            milestone_num = len(Milestone.select(product_env))
            version_num = len(Version.select(product_env))
            components = component.select(product_env)
            component_num = 0

            for c in components:
                component_num += 1

            data = {'product': product,
                    'ticket_num': ticket_num,
                    'owner': product.owner,
                    'milestone_num': milestone_num,
                    'version_num': version_num,
                    'component_num': component_num}
            return 'bh_emb_product.html', data, None
        elif name == 'query':
            qstr = req.query_string
            qstr = urllib.unquote(qstr).decode('utf8')

            if qstr=='':
                qstr = 'status!=closed'

            qresults = self.query(req, qstr)
            filters = qresults[0]
            tickets = qresults[1]

            data={'tickets': tickets,
                  'query': qstr,
                  'filters': filters}
            return 'bh_emb_query.html', data, None
        else:
            msg = "It is not possible to embed this resource."
            raise ResourceNotFound((msg), ("Invalid resource"))
开发者ID:ahorincar,项目名称:bloodhound_embedding_plugin,代码行数:71,代码来源:api.py


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