def save_engine_params(self, engine, **kwargs): """Map validated field values to engine data. Since form widgets may be nested or named differently than the keys in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is necessary to manually map field values to the data dictionary. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass :param engine: An instance of the storage engine implementation. :param \*\*kwargs: Validated and filtered form values. :raises formencode.Invalid: If some post-validation error is detected in the user input. This will trigger the same error handling behaviour as with the @validate decorator. """ StorageForm.save_engine_params(self, engine, **kwargs) ftp = kwargs['ftp'] engine._data[FTP_SERVER] = ftp['server'] engine._data[FTP_USERNAME] = ftp['user'] engine._data[FTP_PASSWORD] = ftp['password'] engine._data[FTP_UPLOAD_DIR] = ftp['upload_dir'] engine._data[FTP_MAX_INTEGRITY_RETRIES] = ftp[ 'upload_integrity_retries'] engine._data[HTTP_DOWNLOAD_URI] = ftp['http_download_uri'] engine._data[RTMP_SERVER_URI] = ftp['rtmp_server_uri']
def save_engine_params(self, engine, **kwargs): """Map validated field values to engine data. Since form widgets may be nested or named differently than the keys in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is necessary to manually map field values to the data dictionary. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass :param engine: An instance of the storage engine implementation. :param \*\*kwargs: Validated and filtered form values. :raises formencode.Invalid: If some post-validation error is detected in the user input. This will trigger the same error handling behaviour as with the @validate decorator. """ StorageForm.save_engine_params(self, engine, **kwargs) rtmp = kwargs.get('rtmp', {}) rtmp_servers = rtmp.get('known_servers', ()) engine._data['rtmp_server_uris'] = [x for x in rtmp_servers if x]
def save_engine_params(self, engine, **kwargs): """Map validated field values to engine data. Since form widgets may be nested or named differently than the keys in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is necessary to manually map field values to the data dictionary. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass :param engine: An instance of the storage engine implementation. :param \*\*kwargs: Validated and filtered form values. :raises formencode.Invalid: If some post-validation error is detected in the user input. This will trigger the same error handling behaviour as with the @validate decorator. """ StorageForm.save_engine_params(self, engine, **kwargs) ftp = kwargs["ftp"] engine._data[FTP_SERVER] = ftp["server"] engine._data[FTP_USERNAME] = ftp["user"] engine._data[FTP_PASSWORD] = ftp["password"] engine._data[FTP_UPLOAD_DIR] = ftp["upload_dir"] engine._data[FTP_MAX_INTEGRITY_RETRIES] = ftp["upload_integrity_retries"] engine._data[HTTP_DOWNLOAD_URI] = ftp["http_download_uri"] engine._data[RTMP_SERVER_URI] = ftp["rtmp_server_uri"]
def display(self, value, engine, **kwargs): """Display the form with default values from the given StorageEngine. If the value dict is not fully populated, populate any missing entries with the values from the given StorageEngine's :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict. :param value: A (sparse) dict of values to populate the form with. :type value: dict :param engine: An instance of the storage engine implementation. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass """ rtmp = value.setdefault('rtmp', {}) rtmp.setdefault('known_servers', engine._data.get('rtmp_server_uris', ())) return StorageForm.display(self, value, engine, **kwargs)
def display(self, value, engine, **kwargs): """Display the form with default values from the given StorageEngine. If the value dict is not fully populated, populate any missing entries with the values from the given StorageEngine's :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict. :param value: A (sparse) dict of values to populate the form with. :type value: dict :param engine: An instance of the storage engine implementation. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass """ data = engine._data ftp = value.setdefault("ftp", {}) ftp.setdefault("server", data.get(FTP_SERVER, None)) ftp.setdefault("user", data.get(FTP_USERNAME, None)) ftp.setdefault("password", data.get(FTP_PASSWORD, None)) ftp.setdefault("upload_dir", data.get(FTP_UPLOAD_DIR, None)) ftp.setdefault("upload_integrity_retries", data.get(FTP_MAX_INTEGRITY_RETRIES, None)) ftp.setdefault("http_download_uri", data.get(HTTP_DOWNLOAD_URI, None)) ftp.setdefault("rtmp_server_uri", data.get(RTMP_SERVER_URI, None)) return StorageForm.display(self, value, engine, **kwargs)
def display(self, value, engine, **kwargs): """Display the form with default values from the given StorageEngine. If the value dict is not fully populated, populate any missing entries with the values from the given StorageEngine's :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict. :param value: A (sparse) dict of values to populate the form with. :type value: dict :param engine: An instance of the storage engine implementation. :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass """ data = engine._data ftp = value.setdefault('ftp', {}) ftp.setdefault('server', data.get(FTP_SERVER, None)) ftp.setdefault('user', data.get(FTP_USERNAME, None)) ftp.setdefault('password', data.get(FTP_PASSWORD, None)) ftp.setdefault('upload_dir', data.get(FTP_UPLOAD_DIR, None)) ftp.setdefault('upload_integrity_retries', data.get(FTP_MAX_INTEGRITY_RETRIES, None)) ftp.setdefault('http_download_uri', data.get(HTTP_DOWNLOAD_URI, None)) ftp.setdefault('rtmp_server_uri', data.get(RTMP_SERVER_URI, None)) return StorageForm.display(self, value, engine, **kwargs)