Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 3
0
class IFile(IItem):

    fieldset_field("file", "default")
    file = CloudFileField(title="File", required=False, widget="file")
Exemplo n.º 4
0
class IFileContent(IItem):
    file = CloudFileField(required=False)
Exemplo n.º 5
0
class IMultiAttachment(Interface):
    files = Dict(
        key_type=TextLine(),
        value_type=CloudFileField(),
        missing_value={}
    )
Exemplo n.º 6
0
class IAttachment(Interface):
    file = CloudFileField()
Exemplo n.º 7
0
class IImageAttachment(Interface):

    image = CloudFileField()

    caption = schema.TextLine()
Exemplo n.º 8
0
class ILeadImage(Interface):

    lead = CloudFileField()
Exemplo n.º 9
0
class IMultiAttachment(Interface):
    files = Dict(key_type=TextLine(),
                 value_type=CloudFileField(),
                 default={},
                 missing_value={},
                 max_length=1000)
Exemplo n.º 10
0
class IFile(IItem):

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