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


Python MapFeature.has_subclass方法代码示例

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


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

示例1: detail_link

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import has_subclass [as 别名]
def detail_link(thing):
    """
    Get a link to a detail view that can be shown for an
    object with this type

    For example, a 'treephoto' instance provides a link to
    the given tree.
    """
    name = thing.__class__.__name__
    nameLower = name.lower()
    if nameLower in MODEL_DETAILS:
        return MODEL_DETAILS[nameLower](thing)
    elif MapFeature.has_subclass(name):
        return MODEL_DETAILS['mapfeature'](thing)
    else:
        return None
开发者ID:grafuls,项目名称:OTM2,代码行数:18,代码来源:util.py

示例2: safe_get_model_class

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import has_subclass [as 别名]
def safe_get_model_class(model_string):
    """
    In a couple of cases we want to be able to convert a string
    into a valid django model class. For instance, if we have
    'Plot' we want to get the actual class for 'treemap.models.Plot'
    in a safe way.

    This function returns the class represented by the given model
    if it exists in 'treemap.models'
    """
    from treemap.models import MapFeature

    # All of our models live in 'treemap.models', so
    # we can start with that namespace
    models_module = __import__('treemap.models')

    if hasattr(models_module.models, model_string):
        return getattr(models_module.models, model_string)
    elif MapFeature.has_subclass(model_string):
        return MapFeature.get_subclass(model_string)
    else:
        raise ValidationError(trans('invalid model type'))
开发者ID:atogle,项目名称:OTM2,代码行数:24,代码来源:util.py


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