Ejemplo n.º 1
0
    def __init__(self, field, factory, name=None):

        if not IField.providedBy(field):
            raise ValueError("Provided field must be an IField object")

        if not IFile.implementedBy(factory):
            raise ValueError("Provided factory is not a valid IFile")

        self.__field = field
        self.__name = name or field.__name__
        self.__factory = factory
Ejemplo n.º 2
0
    def __init__(self, field, factory, name=None):

        if not IField.providedBy(field):
            raise ValueError("Provided field must be an IField object")

        if not IFile.implementedBy(factory):
            raise ValueError("Provided factory is not a valid IFile")

        self.__field = field
        self.__name = name or field.__name__
        self.__factory = factory
Ejemplo n.º 3
0
    def update(self):
        DisplayFieldWidget.update(self)
        content = self.form.getContentData().getContent()
        fileobj = self.component._field.get(content)

        if fileobj:
            if IFile.providedBy(fileobj):
                self.filename = fileobj.filename
                self.filesize = ISized(fileobj, None)

            self.url = get_absolute_url(content, self.request)
            self.download = "%s/++download++%s" % (
                self.url, self.component.identifier)
Ejemplo n.º 4
0
    def update(self):
        DisplayFieldWidget.update(self)
        content = self.form.getContentData().getContent()
        fileobj = self.component._field.get(content)

        if fileobj:
            if IFile.providedBy(fileobj):
                self.filename = fileobj.filename
                self.filesize = ISized(fileobj, None)

            self.url = get_absolute_url(content, self.request)
            self.download = "%s/++download++%s" % (
                self.url, self.component.identifier)
Ejemplo n.º 5
0
    def update(self):
        SchemaFieldWidget.update(self)

        if not self.form.ignoreContent:
            content = self.form.getContentData().getContent()
            fileobj = self.component._field.get(content)

            if fileobj:
                self.allow_action = True
                if IFile.providedBy(fileobj):
                    self.filename = fileobj.filename
                    self.filesize = ISized(fileobj, None)
                else:
                    self.filename = _(u'download', default=u"Download")

                if ILocation.providedBy(content):
                    self.url = get_absolute_url(content, self.request)
                    self.download = "%s/++download++%s" % (
                        self.url, self.component.identifier)
Ejemplo n.º 6
0
    def update(self):
        SchemaFieldWidget.update(self)

        if not self.form.ignoreContent:
            content = self.form.getContentData().getContent()
            fileobj = self.component._field.get(content)

            if fileobj:
                self.allow_action = True
                if IFile.providedBy(fileobj):
                    self.filename = fileobj.filename
                    self.filesize = ISized(fileobj, None)
                else:
                    self.filename = _(u'download', default=u"Download")

                if ILocation.providedBy(content):
                    self.url = get_absolute_url(content, self.request)
                    self.download = "%s/++download++%s" % (
                        self.url, self.component.identifier)