guillotina.configure

guillotina.configure.scan(path)

Load a module dotted name.

Parameters:

path (str) -- dotted name

guillotina.configure.json_schema_definition(name, schema)

Register a json schema definition

Parameters:
  • name (str) -- Name of schema

  • schema (dict) -- schema definition, must be json compatible

Return type:

None

guillotina.configure.service(**kwargs)

Configure a service

>>> from guillotina import configure
>>> @configure.service(name='@foobar')
    async def foobar_service(context, request): return {'foo': 'bar'}
Parameters:
  • context (Interface) -- Content type interface this service is registered against

  • method (str) -- HTTP method this service works against. Defaults to GET.

  • permission (str) -- Permission this service requires

  • layer (str) -- Layer this service is registered for. Default is IDefaultLayer

  • name -- This is used as part of the uri. Example @foobar -> /mycontent/@foobar.

  • summary -- Used for documentation and OpenAPI.

  • description -- Used for documentation and OpenAPI.

  • responses -- Used for documentation and OpenAPI.

  • parameters -- Used for documentation and OpenAPI.

  • requestBody -- Used for documentation and OpenAPI

  • validate -- Automatically validate request body with OpenAPI definition

guillotina.configure.contenttype(**kwargs)

Configure content type

>>> from guillotina import configure
>>> from guillotina.content import Item
>>> @configure.contenttype(type_name="Foobar")
    class Foobar(Item): pass
Parameters:
  • type_name (str) -- Name of the content type

  • schema (str) -- Schema to use for content type

  • add_permission (str) -- Permission required to add content. Defaults to guillotina.AddContent

  • allowed_types (list) -- List of types allowed to be added inside this content assuming it is a Folder type. Defaults to allowing all types.

  • behaviors (str) -- List of behaviors to enable for this type.

  • factory -- Dotted name to custom factory to use. See guillotina.content.ResourceFactory for default implementation

guillotina.configure.behavior(**kwargs)

Configure behavior

>>> from guillotina import configure
>>> from guillotina.behaviors.instance import ContextBehavior
>>> class IMyBehavior(Interface): pass
>>> @configure.behavior(
      title="Dublin Core fields",
      provides=IMyBehavior,
      for_="guillotina.interfaces.IResource")
    class MyBehavior(ContextBehavior): pass
Parameters:
  • title -- Title of behavior

  • provides -- Schema to use for behavior

  • behavior -- Marker interface to apply to utilized instance's behavior

  • for_ -- Content type this behavior is available for

guillotina.configure.vocabulary(**kwargs)

Configure vocabulary

>>> from guillotina import configure
>>> @configure.vocabulary(name="myvocab")
    class MyVocab:
      def __init__(self, context):
        self.context = context
        self.values = range(10)
      def __iter__(self):
        return iter([])
      def __contains__(self, value):
        return value in self.values
      def __len__(self):
        return len(self.values)
      def getTerm(self, value):
        return 'value'
Parameters:

name -- Reference of the vocabulary to get it

guillotina.configure.addon(**kwargs)

Configure addon

>>> from guillotina import configure
>>> @configure.addon(
      name="docaddon",
      title="Doc addon",
      dependencies=["cms"])
    class TestAddon(Addon): pass
Parameters:
  • name -- Unique name of addon

  • title -- Title of addon

  • dependencies -- List of names of dependency addons

guillotina.configure.adapter(**kwargs)

Configure adapter

Parameters:
  • for_ -- Type or list of types this subscriber is for: required

  • provides -- Interface this adapter provides

guillotina.configure.utility(**kwargs)

Configure utility

Parameters:
  • provides -- Interface this utility provides

  • name -- Optional to name the utility

guillotina.configure.permission(**kwargs)

Configure permission

Parameters:
  • id

  • title

  • description

guillotina.configure.role(**kwargs)

Configure role

Parameters:
  • id

  • title

  • description

  • local (bool) -- defaults to True

guillotina.configure.grant(**kwargs)

Configure granting permission to role

Parameters:
  • role

  • principal

  • permission

  • permissions

guillotina.configure.value_serializer(type)

Configure a value serializer

>>> @configure.value_serializer(bytes)
>>> def bytes_converter(value): return b64encode(value)
Parameters:

type -- type to serialize

guillotina.configure.value_deserializer(field_type)

Configure a value deserializer

>>> @configure.value_deserializer(IText)
>>> def field_converter(field, value, context): return value
Parameters:

field_type -- type of field to deserialize

guillotina.configure.renderer(**kwargs)

Configure a renderer

>>> @configure.renderer(name='text/plain')
>>> class RendererPlain(StringRenderer):
      content_type = 'text/plain'
Parameters:

name -- content type the renderer can be used for

guillotina.configure.language(name)

Configure a language

>>> @configure.language(name='en')
>>> class EN(DefaultLanguage): pass
Parameters:

name -- Name of language