• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.slugify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: on_change_with_uri

 def on_change_with_uri(self, vals):
     if vals.get('name'):
         if not vals.get('uri'):
             vals['uri'] = slugify(vals['name'])
         return vals['uri']
     else:
         return {}
开发者ID:shalabhaggarwal,项目名称:nereid-catalog,代码行数:7,代码来源:product.py


示例2: on_change_with_uri

 def on_change_with_uri(self):
     """
     If the URI is empty, slugify template name into URI
     """
     if not self.uri and self.template:
         return slugify(self.template.name)
     return self.uri
开发者ID:gautampanday,项目名称:nereid-catalog,代码行数:7,代码来源:product.py


示例3: on_change_with_uri

 def on_change_with_uri(self):
     """
     If the URI is empty and the name is there, slugify name into URI
     """
     if self.name and not self.uri:
         return slugify(self.name)
     return self.uri
开发者ID:simmianand,项目名称:nereid-catalog,代码行数:7,代码来源:product.py


示例4: on_change_with_slug

 def on_change_with_slug(self):
     """
     On change the name and slug, ensure that the slug field is auto
     filled with a generated slug, if the field is empty
     """
     if not self.slug:
         self.slug = slugify(self.get_rec_name('rec_name'))
     return self.slug
开发者ID:aroraumang,项目名称:nereid-catalog-tree,代码行数:8,代码来源:tree.py


示例5: make_uri

 def make_uri(self, name, parent):
     """Construct a URI and return it."""
     full_name = u''
     if parent:
         full_name += "%s-" % self.get_rec_name([parent.id], None)[parent.id]
     full_name += name
     full_name.replace('/', '-')
     return slugify(full_name)
开发者ID:shalabhaggarwal,项目名称:nereid-catalog,代码行数:8,代码来源:product.py


示例6: on_change_with_folder_name

 def on_change_with_folder_name(self):
     """
     Fills the name field with a slugified name
     """
     if self.get('name'):
         if not self.get('folder_name'):
             self['folder_name'] = slugify(self['name'])
         return self['folder_name']
开发者ID:Abhisar,项目名称:nereid,代码行数:8,代码来源:static_file.py


示例7: on_change_with_folder_name

 def on_change_with_folder_name(self, vals):
     """
     Fills the name field with a slugified name
     """
     if vals.get('name'):
         if not vals.get('folder_name'):
             vals['folder_name'] = slugify(vals['name'])
         return vals['folder_name']
开发者ID:shalabhaggarwal,项目名称:nereid,代码行数:8,代码来源:static_file.py


示例8: on_change_with_uri

 def on_change_with_uri(self):
     """Slugifies the full name of a category to
     make the uri on change of product name.
     Slugification will occur only if there is no uri filled from before.
     """
     if self.name and not self.uri:
         full_name = (self.parent and self.parent.rec_name or '') \
             + self.name
         return slugify(full_name)
     return self.uri
开发者ID:GauravButola,项目名称:nereid-catalog,代码行数:10,代码来源:product.py


示例9: _get_or_create_icecat_if_not_exists

    def _get_or_create_icecat_if_not_exists(cls, icecat_id):
        """
        Build TreeNode hierarchy for given category

        :param icecat_id: ICECAT category ID

        :returns: Node activerecord for icecat_id
        """
        data = cls._get_icecat_categorieslist_data()
        node = cls.search([('icecat_id', '=', icecat_id)])
        if node:
            # node already exists, simply return
            node, = node
        elif icecat_id == 1:
            # Create root node as it does not exist
            node, = cls.create([{
                'name': 'ICECAT Categories',  # since no name set in XML file
                'type_': 'catalog',
                'slug': slugify('ICECAT Categories'),
                'icecat_id': icecat_id
            }])
        else:
            category, = data.xpath(
                'Category[@ID="%d"]' % icecat_id
            )
            name, = category.xpath('Name[@langid="1"]')
            name = name.get('Value')
            node, = cls.create([{
                'name': name,
                'type_': 'catalog',
                'slug': slugify(name),
                'icecat_id': icecat_id
            }])
            node._save_icecat_category_alternate_lang(data)

            # get parent object and recursively create the tree
            parent, = category.xpath('ParentCategory')
            parent_node = cls._get_or_create_icecat_if_not_exists(
                int(parent.attrib.get('ID'))
            )
            cls.write([node], {'parent': parent_node})
        return node
开发者ID:aroraumang,项目名称:nereid-catalog-icecat,代码行数:42,代码来源:tree.py


示例10: validate_uri

    def validate_uri(self, field):
        BlogPost = Pool().get('blog.post')

        if not field.data and not self.data['title']:
            return
        field.process_data(slugify(field.data or self.data['title']))
        domain = [('uri', '=', field.data)]
        if Transaction().context.get('blog_id'):
            # blog_id in context means editing form
            domain.append(('id', '!=', Transaction().context['blog_id']))
        if BlogPost.search(domain):
            raise ValidationError(
                'Blog with the same URL exists. Please change title or modify'
            )
开发者ID:openlabs,项目名称:nereid-blog,代码行数:14,代码来源:blog.py


示例11: on_change_name

 def on_change_name(self):
     res = {}
     if self.name and not self.unique_identifier:
         res['unique_identifier'] = slugify(self.name)
     return res
开发者ID:shalabhaggarwal,项目名称:nereid-cms,代码行数:5,代码来源:cms.py


示例12: update_uri

 def update_uri(cls, categories):
     """Update the uri of the category from the complete name.
     """
     for category in categories:
         cls.write([category], {'uri': slugify(category.rec_name)})
开发者ID:GauravButola,项目名称:nereid-catalog,代码行数:5,代码来源:product.py


示例13: on_change_title

 def on_change_title(self):
     res = {}
     if self.title and not self.uri:
         res['uri'] = slugify(self.title)
     return res
开发者ID:priyankarani,项目名称:nereid-cms,代码行数:5,代码来源:cms.py


示例14: on_change_title

 def on_change_title(self):
     if self.title and not self.unique_name:
         self.unique_name = slugify(self.title)
开发者ID:2cadz,项目名称:nereid-cms,代码行数:3,代码来源:cms.py


示例15: on_change_with_uri

 def on_change_with_uri(self):
     if self.title and not self.uri:
         return slugify(self.title)
     return self.uri
开发者ID:openlabs,项目名称:nereid-blog,代码行数:4,代码来源:blog.py


示例16: on_change_title

 def on_change_title(self):
     if self.title and not self.uri:
         self.uri = slugify(self.title)
开发者ID:fulfilio,项目名称:nereid-cms,代码行数:3,代码来源:cms.py


示例17: update_uri

 def update_uri(cls, browse_nodes):
     """
     Update the uri of the browse node from the rec_name.
     """
     for browse_node in browse_nodes:
         cls.write([browse_node], {'uri': slugify(browse_node.rec_name)})
开发者ID:simmianand,项目名称:nereid-catalog,代码行数:6,代码来源:product.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.url_for函数代码示例发布时间:2022-05-27
下一篇:
Python ctx.has_request_context函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap