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


Python ProductEnvironment.lookup_env方法代码示例

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


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

示例1: product_admincmd_mgr

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import lookup_env [as 别名]
 def product_admincmd_mgr(self, prefix):
     try:
         product_env = ProductEnvironment.lookup_env(self.env, prefix)
     except LookupError:
         raise AdminCommandError('Unknown product %s' % (prefix,))
     else:
         return AdminCommandManager(product_env)
开发者ID:mohsadki,项目名称:dargest,代码行数:9,代码来源:product_admin.py

示例2: post_process_request

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import lookup_env [as 别名]
    def post_process_request(self, req, template, data, content_type):
        """Append necessary ticket data
        """
        try:
            tm = self._get_ticket_module()
        except TracError:
            # no ticket module so no create ticket button
            return template, data, content_type

        if (template, data, content_type) != (None,) * 3:  # TODO: Check !
            if data is None:
                data = {}
            dum_req = dummy_request(self.env)
            dum_req.perm = req.perm
            ticket = Ticket(self.env)
            tm._populate(dum_req, ticket, False)
            all_fields = dict([f['name'], f]
                              for f in tm._prepare_fields(dum_req, ticket)
                              if f['type'] == 'select')

            product_field = all_fields.get('product')
            if product_field:
                # When at product scope, set the default selection to the
                # product at current scope. When at global scope the default
                # selection is determined by [ticket] default_product
                if self.env.product and \
                        self.env.product.prefix in product_field['options']:
                    product_field['value'] = self.env.product.prefix
                # Transform the options field to dictionary of product
                # attributes and filter out products for which user doesn't
                #  have TICKET_CREATE permission
                product_field['options'] = [
                    dict(value=p,
                         new_ticket_url=dum_req.href.products(p, 'newticket'),
                         description=ProductEnvironment.lookup_env(self.env, p)
                                                       .product.name
                    )
                for p in product_field['options']
                    if req.perm.has_permission('TICKET_CREATE',
                                               Neighborhood('product', p)
                                               .child(None, None))]
            else:
                msg = _("Missing ticket field '%(field)s'.", field='product')
                if ProductTicketModule is not None and \
                        self.env[ProductTicketModule] is not None:
                    # Display warning alert to users
                    add_warning(req, msg)
                else:
                    # Include message in logs since this might be a failure
                    self.log.warning(msg)
            data['qct'] = {
                'fields': [all_fields[k] for k in self.qct_fields
                           if k in all_fields],
                'hidden_fields': [all_fields[k] for k in all_fields.keys()
                                  if k not in self.qct_fields] }
        return template, data, content_type
开发者ID:mohsadki,项目名称:dargest,代码行数:58,代码来源:theme.py

示例3: post_process_request

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import lookup_env [as 别名]
    def post_process_request(self, req, template, data, content_type):
        """Append necessary ticket data
        """
        try:
            tm = self._get_ticket_module()
        except TracError:
            # no ticket module so no create ticket button
            return template, data, content_type

        if (template, data, content_type) != (None,) * 3:  # TODO: Check !
            if data is None:
                data = {}
            req = dummy_request(self.env)
            ticket = Ticket(self.env)
            tm._populate(req, ticket, False)
            all_fields = dict([f['name'], f]
                              for f in tm._prepare_fields(req, ticket)
                              if f['type'] == 'select')

            product_field = all_fields['product']
            if product_field:
                if self.env.product:
                    product_field['value'] = self.env.product.prefix
                else:
                    # Global scope, now check default_product_prefix is valid
                    default_prefix = self.config.get('multiproduct',
                                                     'default_product_prefix')
                    try:
                        ProductEnvironment.lookup_env(self.env, default_prefix)
                    except LookupError:
                        product_field['value'] = product_field['options'][0]
                    else:
                        product_field['value'] = default_prefix

            data['qct'] = {
                'fields': [all_fields[k] for k in self.qct_fields
                           if k in all_fields],
                'hidden_fields': [all_fields[k] for k in all_fields.keys()
                                  if k not in self.qct_fields]
            }
        return template, data, content_type
开发者ID:devenderbindal,项目名称:bloodhound,代码行数:43,代码来源:theme.py

示例4: admin_url

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import lookup_env [as 别名]
 def admin_url(prefix):
     env = ProductEnvironment.lookup_env(self.env, prefix)
     href = ProductEnvironment.resolve_href(env, self.env)
     return href.admin()
开发者ID:mohsadki,项目名称:dargest,代码行数:6,代码来源:theme.py


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