• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / z3c.form / 16248976312

02 Jul 2025 05:53AM UTC coverage: 95.275%. Remained the same
16248976312

push

github

icemac
Back to development: 6.1

717 of 800 branches covered (89.63%)

Branch coverage included in aggregate %.

3699 of 3835 relevant lines covered (96.45%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/z3c/form/browser/file.py
1
##############################################################################
2
#
3
# Copyright (c) 2007 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""File Widget Implementation
15

16
$Id$
17
"""
18
__docformat__ = "reStructuredText"
1✔
19
import zope.component
1✔
20
import zope.interface
1✔
21
import zope.schema.interfaces
1✔
22

23
from z3c.form import interfaces
1✔
24
from z3c.form import widget
1✔
25
from z3c.form.browser import text
1✔
26

27

28
@zope.interface.implementer_only(interfaces.IFileWidget)
1✔
29
class FileWidget(text.TextWidget):
1✔
30
    """Input type text widget implementation."""
31

32
    klass = 'file-widget'
1✔
33
    css = 'file'
1✔
34

35
    # Filename and headers attribute get set by ``IDataConverter`` to the
36
    # widget provided by the FileUpload object of the form.
37
    headers = None
1✔
38
    filename = None
1✔
39

40
    def json_data(self):
1✔
41
        data = super().json_data()
×
42
        data['type'] = 'file'
×
43
        return data
×
44

45

46
@zope.component.adapter(zope.schema.interfaces.IBytes, interfaces.IFormLayer)
1✔
47
@zope.interface.implementer(interfaces.IFieldWidget)
1✔
48
def FileFieldWidget(field, request):
1✔
49
    """IFieldWidget factory for FileWidget."""
50
    return widget.FieldWidget(field, FileWidget(request))
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc