How to use the guillotina.schema.TextLine function in guillotina

To help you get started, we’ve selected a few guillotina examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plone / guillotina / guillotina / test_package.py View on Github external
class IExample(IResource):

    metadata("categories")

    index_field("boolean_field", type="boolean")
    boolean_field = schema.Bool(required=False)

    index_field("categories", field_mapping=CATEGORIES_MAPPING)
    categories = schema.List(
        title="categories", default=[], value_type=schema.JSONField(title="term", schema=TERM_SCHEMA)
    )

    textline_field = schema.TextLine(title="kk", widget="testing", required=False)
    text_field = schema.Text(required=False)
    dict_value = schema.Dict(key_type=schema.TextLine(), value_type=schema.TextLine(), required=False)
    datetime = schema.Datetime(required=False)

    write_permission(write_protected="example.MyPermission")
    write_protected = schema.TextLine(title="Write protected field", required=False)

    default_factory_test = schema.Text(defaultFactory=lambda: "foobar")

    context_default_factory_test = schema.Text(defaultFactory=ContextDefaultFactory())


@index_field.with_accessor(IExample, "categories_accessor", field="categories")
def categories_index_accessor(ob):
    if not ob.categories:
        raise NoIndexField
    else:
        return [c["label"] for c in ob.categories]
github plone / guillotina / guillotina / test_package.py View on Github external
bucket_len=10, required=False, default=None, key_type=schema.Text(), value_type=schema.Text()
    )

    read_permission(no_read_field="example.MyPermission")
    no_read_field = schema.TextLine(required=False, default="")


@configure.behavior(
    title="", provides=ITestBehavior, marker=IMarkerBehavior, for_="guillotina.interfaces.IResource"
)
class GTestBehavior(AnnotationBehavior):
    foobar_context = ContextProperty("foobar_context")


class ITestContextBehavior(Interface):
    foobar = schema.TextLine()


class IMarkerTestContextBehavior(Interface):
    pass


@configure.behavior(
    title="",
    provides=ITestContextBehavior,
    marker=IMarkerTestContextBehavior,
    for_="guillotina.interfaces.IResource",
)
class GContextTestBehavior(ContextBehavior):
    pass
github plone / guillotina / guillotina / behaviors / dublincore.py View on Github external
# never expires
CEILING_DATE = datetime(*datetime.max.timetuple()[:-2], tzutc())  # type: ignore
# always effective
FLOOR_DATE = datetime(*datetime.min.timetuple()[:-2], tzutc())  # type: ignore


class IMarkerDublinCore(Interface):
    """Marker interface for content with dublin core."""


class IDublinCore(Interface):
    index_field("creators", type="keyword")
    index_field("tags", type="keyword")
    index_field("contributors", type="keyword")

    title = schema.TextLine(
        title="Title", description="The first unqualified Dublin Core 'Title' element value.", required=False
    )

    description = schema.Text(
        title="Description",
        description="The first unqualified Dublin Core 'Description' element value.",
        required=False,
    )

    creation_date = schema.Datetime(
        title="Creation Date",
        description="The date and time that an object is created. " "\nThis is normally set automatically.",
        required=False,
    )

    modification_date = schema.Datetime(
github plone / guillotina / guillotina / interfaces / files.py View on Github external
def should_clean(**kwargs):
        """
        whether or not old file should be cleaned
        """


class IFile(Interface):

    content_type = schema.TextLine(
        title="Content Type",
        description="The content type identifies the type of data.",
        default="",
        required=False,
    )

    filename = schema.TextLine(title="Filename", required=False, default=None)

    extension = schema.TextLine(title="Extension of the file", default="", required=False)

    md5 = schema.TextLine(title="MD5", default="", required=False)

    size = schema.Int(title="Size", default=0)


# File Field


class IFileField(IObject):
    """Field for storing IFile objects."""


class ICloudFileField(IObject):
github plone / guillotina / measures / configuration.py View on Github external
@configure.behavior(
    title="", provides=ITestBehavior2, marker=IMarkerBehavior2, for_="guillotina.interfaces.IResource"
)
class TestBehavior2(AnnotationBehavior):
    pass


@configure.behavior(
    title="", provides=ITestBehavior3, marker=IMarkerBehavior3, for_="guillotina.interfaces.IResource"
)
class TestBehavior3(AnnotationBehavior):
    pass


class ITestContent1(IItem):
    foobar1 = schema.TextLine()


class ITestContent2(ITestContent1):
    foobar2 = schema.TextLine()


class ITestContent3(ITestContent2):
    foobar3 = schema.TextLine()


class ITestContent4(ITestContent3):
    foobar4 = schema.TextLine()


class ITestContent5(ITestContent4):
    foobar5 = schema.TextLine()
github plone / guillotina / guillotina / contrib / dbusers / content / users.py View on Github external
import typing


class IUserManager(IFolder):
    pass


class IUser(IFolder, IPrincipal):

    username = schema.TextLine(title=_("Username"), required=False)

    index_field("email", index_name="user_email", type="keyword")
    email = schema.TextLine(title=_("Email"), required=False)

    index_field("name", index_name="user_name", type="textkeyword")
    name = schema.TextLine(title=_("Name"), required=False)

    read_permission(password="guillotina.Nobody")
    password = schema.TextLine(title=_("Password"), required=False)

    write_permission(user_groups="guillotina.ManageUsers")
    user_groups = schema.List(title=_("Groups"), value_type=schema.TextLine(), required=False)

    write_permission(user_roles="guillotina.ManageUsers")
    index_field("user_roles", type="textkeyword")
    user_roles = schema.List(title=_("Roles"), value_type=schema.TextLine(), required=False)

    write_permission(user_permissions="guillotina.ManageUsers")
    user_permissions = schema.List(
        title=_("Permissions"), value_type=schema.TextLine(), required=False, default=[]
    )
github plone / guillotina / measures / configuration.py View on Github external
title="", provides=ITestBehavior3, marker=IMarkerBehavior3, for_="guillotina.interfaces.IResource"
)
class TestBehavior3(AnnotationBehavior):
    pass


class ITestContent1(IItem):
    foobar1 = schema.TextLine()


class ITestContent2(ITestContent1):
    foobar2 = schema.TextLine()


class ITestContent3(ITestContent2):
    foobar3 = schema.TextLine()


class ITestContent4(ITestContent3):
    foobar4 = schema.TextLine()


class ITestContent5(ITestContent4):
    foobar5 = schema.TextLine()


class ITestContent6(ITestContent5):
    foobar6 = schema.TextLine()


@configure.contenttype(
    type_name="TestContent1",
github plone / guillotina / guillotina / interfaces / content.py View on Github external
class IResource(IBaseObject, ILocation):

    __acl__ = Attribute("")
    __gannotations__ = Attribute("")
    __uuid__ = Attribute("database object unique id")

    id = Attribute("")
    creators = Attribute("")
    contributors = Attribute("")
    type_name = guillotina.schema.TextLine(readonly=True)

    title = guillotina.schema.TextLine(
        title="Title", required=False, description="Title of the Resource", default=""
    )

    uuid = guillotina.schema.TextLine(title="UUID", required=True, readonly=True)

    modification_date = guillotina.schema.Datetime(title="Modification date", required=False)

    creation_date = guillotina.schema.Datetime(title="Creation date", required=False)

    __behaviors__ = guillotina.schema.FrozenSet(
        title="Enabled behaviors",
        required=False,
        description="Dynamic behaviors for the content type",
        default=frozenset({}),
        readonly=True,
    )

    def register():
        """
        Register object
github plone / guillotina / measures / configuration.py View on Github external
class IMarkerBehavior1(Interface):
    pass


class IMarkerBehavior2(Interface):
    pass


class IMarkerBehavior3(Interface):
    pass


class ITestBehavior1(Interface):
    foobar = schema.TextLine()


class ITestBehavior2(Interface):
    foobar = schema.TextLine()


class ITestBehavior3(Interface):
    foobar = schema.TextLine()


@configure.behavior(
    title="", provides=ITestBehavior1, marker=IMarkerBehavior1, for_="guillotina.interfaces.IResource"
)
class TestBehavior1(AnnotationBehavior):
    pass