本文整理汇总了Python中wagtail.contrib.settings.models.BaseSetting方法的典型用法代码示例。如果您正苦于以下问题:Python models.BaseSetting方法的具体用法?Python models.BaseSetting怎么用?Python models.BaseSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.contrib.settings.models
的用法示例。
在下文中一共展示了models.BaseSetting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_setting
# 需要导入模块: from wagtail.contrib.settings import models [as 别名]
# 或者: from wagtail.contrib.settings.models import BaseSetting [as 别名]
def _add_setting(cls: Type[BaseSetting], node: str, dict_params: dict) -> Type[DjangoObjectType]:
if not hasattr(cls, 'name'): # we always need a name field
cls.name = cls.__name__
dict_params['Meta'].interfaces += (Settings,)
tp = type(node, (DjangoObjectType,), dict_params) # type: Type[DjangoObjectType]
registry.settings[node] = (tp, cls)
return tp
示例2: _register_model
# 需要导入模块: from wagtail.contrib.settings import models [as 别名]
# 或者: from wagtail.contrib.settings.models import BaseSetting [as 别名]
def _register_model(registered: Set[type], cls: type, snippet: bool,
app: str, prefix: str, override_name=None) -> None:
if cls in registered:
return
prefix = prefix.format(app=string.capwords(app),
cls=cls.__name__)
node = override_name or prefix + cls.__name__
# dict parameters to create GraphQL type
class Meta:
model = cls
interfaces = (graphene.relay.Node, ) if RELAY else tuple()
dict_params = {'Meta': Meta}
# add streamfield handlers
_add_streamfields(cls, node, dict_params, app, prefix)
if snippet:
_add_snippet(cls, node, dict_params)
elif issubclass(cls, AbstractForm):
_add_form(cls, node, dict_params)
elif issubclass(cls, wagtailPage):
_add_page(cls, node, dict_params)
elif issubclass(cls, BaseSetting):
_add_setting(cls, node, dict_params)
else: # Django Model
_add_django_model(cls, node, dict_params)
registered.add(cls)