Skip to content

Commit 1bb3c21

Browse files
committed
Enable overriding valid_schemes for file:/// based StorageFileField
1 parent 14e1634 commit 1bb3c21

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

appyter/profiles/default/fields/FileField.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class FileField(Field):
3232
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
3333
:param \**kwargs: Remaining arguments passed down to :class:`appyter.fields.Field`'s constructor.
3434
'''
35-
def __init__(self, default=None, constraint=r'.*', **kwargs):
35+
def __init__(self, default=None, constraint=r'.*', valid_schemes={'drs', 's3', 'gs', 'ftp', 'http', 'https', 'storage', 'user'}, **kwargs):
3636
super().__init__(
3737
constraint=constraint,
3838
default=default,
39+
valid_schemes=valid_schemes,
3940
**kwargs,
4041
)
4142

@@ -90,7 +91,7 @@ def constraint(self):
9091
return not self.args.get('required')
9192
else:
9293
if self._env.globals['_config']['SAFE_MODE']:
93-
if self.uri.scheme not in {'drs', 's3', 'gs', 'ftp', 'http', 'https', 'storage', 'user'}:
94+
if self.uri.scheme not in self.args['valid_schemes']:
9495
return False
9596
return re.match(re_full(self.args['constraint']), self.uri.fragment_path)
9697

0 commit comments

Comments
 (0)