@@ -34,6 +34,10 @@ class FileUpload(DescriptionWidget, ValueWidget, CoreWidget):
34
34
_model_name = Unicode ('FileUploadModel' ).tag (sync = True )
35
35
_view_name = Unicode ('FileUploadView' ).tag (sync = True )
36
36
_counter = Int (read_only = True ).tag (sync = True )
37
+ _metadata = List (Dict (), read_only = True , help = 'List of file metadata' ).tag (sync = True )
38
+ _data = List (Bytes (), read_only = True , help = 'List of file content (bytes)' ).tag (
39
+ sync = True , from_json = content_from_json
40
+ )
37
41
38
42
accept = Unicode (help = 'File types to accept, empty string for all' ).tag (sync = True )
39
43
multiple = Bool (help = 'If True, allow for multiple files upload' ).tag (sync = True )
@@ -43,19 +47,15 @@ class FileUpload(DescriptionWidget, ValueWidget, CoreWidget):
43
47
values = ['primary' , 'success' , 'info' , 'warning' , 'danger' , '' ], default_value = '' ,
44
48
help = """Use a predefined styling for the button.""" ).tag (sync = True )
45
49
style = InstanceDict (ButtonStyle ).tag (sync = True , ** widget_serialization )
46
- metadata = List (Dict (), read_only = True , help = 'List of file metadata' ).tag (sync = True )
47
- data = List (Bytes (), read_only = True , help = 'List of file content (bytes)' ).tag (
48
- sync = True , from_json = content_from_json
49
- )
50
50
error = Unicode (help = 'Error message' ).tag (sync = True )
51
51
value = Dict (read_only = True )
52
52
53
53
@observe ('_counter' )
54
54
def on_incr_counter (self , change ):
55
55
res = {}
56
56
msg = 'Error: length of metadata and data must be equal'
57
- assert len (self .metadata ) == len (self .data ), msg
58
- for metadata , content in zip (self .metadata , self .data ):
57
+ assert len (self ._metadata ) == len (self ._data ), msg
58
+ for metadata , content in zip (self ._metadata , self ._data ):
59
59
name = metadata ['name' ]
60
60
res [name ] = {'metadata' : metadata , 'content' : content }
61
61
self .set_trait ('value' , res )
0 commit comments