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


Python helpers.slugify函数代码示例

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


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


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