:param config: A configuration dictionary to pass as kwargs to the class corresponding to config['type']
(config, create=True)
| 252 | |
| 253 | |
| 254 | def storage_instance_from_config(config, create=True): |
| 255 | ''' |
| 256 | :param config: A configuration dictionary to pass as kwargs to the class |
| 257 | corresponding to config['type'] |
| 258 | ''' |
| 259 | |
| 260 | cls, new_config = storage_class_from_config(config) |
| 261 | |
| 262 | try: |
| 263 | return cls(**new_config) |
| 264 | except exceptions.CollectionNotFound as e: |
| 265 | if create: |
| 266 | config = handle_collection_not_found( |
| 267 | config, config.get('collection', None), e=str(e)) |
| 268 | return storage_instance_from_config(config, create=False) |
| 269 | else: |
| 270 | raise |
| 271 | except Exception: |
| 272 | return handle_storage_init_error(cls, new_config) |
| 273 | |
| 274 | |
| 275 | def handle_storage_init_error(cls, config): |