Пример #1
0
class IModelFieldSchema(Interface):
    """Model field schema"""

    type_model = schema.ASCII(title="Type of model", default="tf")

    file = CloudFileField(title="Model binary file")

    version = schema.Int(title="Version of the model", default=1)
Пример #2
0
    async def prepare(self):
        # we want have the field
        name = self.request.matchdict["field_name"]
        fti = query_utility(IFactory, name=self.context.type_name)
        schema = fti.schema
        field = None
        self.behavior = None
        if name in schema:
            field = schema[name]

        else:
            # TODO : We need to optimize and move to content.py iterSchema
            for behavior_schema in fti.behaviors or ():
                if name in behavior_schema:
                    field = behavior_schema[name]
                    self.behavior = behavior_schema(self.context)
                    break
            for behavior_name in self.context.__behaviors__ or ():
                behavior_schema = BEHAVIOR_CACHE[behavior_name]
                if name in behavior_schema:
                    field = behavior_schema[name]
                    self.behavior = behavior_schema(self.context)
                    break

        # Check that its a File Field
        if field is None:
            raise HTTPNotFound(content={"reason": "No valid name"})

        if self.behavior is not None:
            ctx = self.behavior
        else:
            ctx = self.context

        if self.behavior is not None and IAsyncBehavior.implementedBy(
                self.behavior.__class__):
            # providedBy not working here?
            await self.behavior.load()

        if IDict.providedBy(field) and ICloudFileField.providedBy(
                field.value_type):
            key = self.request.matchdict.get("file_key")
            if key is not None:
                self.field = CloudFileField(__name__=name).bind(
                    DictFieldProxy(key, ctx, name))
        elif ICloudFileField.providedBy(field):
            self.field = field.bind(ctx)

        if self.field is None:
            raise HTTPNotFound(content={"reason": "No valid name"})

        return self
Пример #3
0
class IFile(IItem):

    fieldset_field("file", "default")
    file = CloudFileField(title="File", required=False, widget="file")
Пример #4
0
class IFileContent(IItem):
    file = CloudFileField(required=False)
Пример #5
0
class IMultiAttachment(Interface):
    files = Dict(
        key_type=TextLine(),
        value_type=CloudFileField(),
        missing_value={}
    )
Пример #6
0
class IAttachment(Interface):
    file = CloudFileField()
Пример #7
0
class IImageAttachment(Interface):

    image = CloudFileField()

    caption = schema.TextLine()
Пример #8
0
class ILeadImage(Interface):

    lead = CloudFileField()
Пример #9
0
class IMultiAttachment(Interface):
    files = Dict(key_type=TextLine(),
                 value_type=CloudFileField(),
                 default={},
                 missing_value={},
                 max_length=1000)
Пример #10
0
class IFile(IItem):

    fieldset_field('file', 'default')
    file = CloudFileField(title='File', required=False, widget='file')