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


Python utils.camelcase_to_underscore函数代码示例

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


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

示例1: widgettype

def widgettype(bound_field):
    try:
        return camelcase_to_underscore(bound_field.field.widget.__class__.__name__)
    except AttributeError:
        try:
            return camelcase_to_underscore(bound_field.widget.__class__.__name__)
        except AttributeError:
            return ""
开发者ID:niceguydave,项目名称:wagtail,代码行数:8,代码来源:wagtailadmin_tags.py

示例2: __init__

    def __init__(cls, name, bases, dct):
        super(PageBase, cls).__init__(name, bases, dct)

        if cls._deferred:
            # this is an internal class built for Django's deferred-attribute mechanism;
            # don't proceed with all this page type registration stuff
            return

        # Add page manager
        PageManager().contribute_to_class(cls, 'objects')

        if 'template' not in dct:
            # Define a default template path derived from the app name and model name
            cls.template = "%s/%s.html" % (cls._meta.app_label, camelcase_to_underscore(name))

        if 'ajax_template' not in dct:
            cls.ajax_template = None

        cls._clean_subpage_types = None  # to be filled in on first call to cls.clean_subpage_types

        if not dct.get('is_abstract'):
            # subclasses are only abstract if the subclass itself defines itself so
            cls.is_abstract = False

        if not cls.is_abstract:
            # register this type in the list of page content types
            PAGE_MODEL_CLASSES.append(cls)
开发者ID:jaap,项目名称:wagtail,代码行数:27,代码来源:models.py

示例3: get_template_name

    def get_template_name(cl):
        if not cl.template_name:
            cl.snake_name = camelcase_to_underscore(cl.__name__)
            cl.template_name = '{}/sections/{}.html'.format(
                cl._meta.app_label, cl.snake_name
            )

            if cl.snake_name != 'section_item':
                from django.template import TemplateDoesNotExist
                try:
                    from django.template.loader import get_template
                    get_template(cl.template_name)
                except TemplateDoesNotExist:
                    cl.template_name = 'aircox_cms/sections/section_item.html'
        return cl.template_name
开发者ID:bkfox,项目名称:aircox,代码行数:15,代码来源:template.py

示例4: get_template

    def get_template(self, request, mode='', **kwargs):
        try:
            return self._path_overrideable_template
        except AttributeError:

            if not self.url:
                return get_template(self.template)

            path = self.url.strip('/')
            model_name = camelcase_to_underscore(self.specific_class.__name__)

            if mode:
                mode = ':'+mode

            model_template = model_name + mode + '.html'

            full_path = os.path.join('default', path+mode+'.html')
            templates = [full_path]
            logger.debug("Adding candidate template based on URL: %s", full_path)

            previous_index = len(path)
            while True:
                previous_index = path.rfind('/', 0, previous_index)
                if previous_index == -1:
                    break

                candidate = os.path.join('default', path[0:previous_index+1], model_template)
                templates.append(candidate)
                logger.debug("Adding candidate template for path-based model override: %s", candidate)

            #templates.append("%s/%s" % (self.specific_class._meta.app_label, model_name))
            templates.append(self.template)  # add the default template as the last one to seek

            logger.debug("Adding candidate template based on model name only: %s", self.template)
            selected_template = select_template(templates)
            try:
                logger.debug("Selected template: %s", selected_template.name)
            except AttributeError:  # Django 1.8 template refactoring...
                logger.debug("Selected template: %s", selected_template.template.name)


            self._path_overrideable_template = selected_template
            return self._path_overrideable_template
开发者ID:bgrace,项目名称:wagtail-commons,代码行数:43,代码来源:models.py

示例5: field_type

 def field_type(self):
     return camelcase_to_underscore(self.bound_field.field.__class__.__name__)
开发者ID:Eraldo,项目名称:wagtail,代码行数:2,代码来源:edit_handlers.py

示例6: snake_name

 def snake_name(cl):
     if not hasattr(cl, '_snake_name'):
         cl._snake_name = camelcase_to_underscore(cl.__name__)
     return cl._snake_name
开发者ID:bkfox,项目名称:aircox,代码行数:4,代码来源:components.py

示例7: fieldtype

def fieldtype(bound_field):
    return camelcase_to_underscore(bound_field.field.__class__.__name__)
开发者ID:asselapathirana,项目名称:verdant-rca,代码行数:2,代码来源:rca_tags.py


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