kopia lustrzana https://github.com/simonw/datasette
				
				
				
			Also remove default_cache_ttl_hashed setting, refs #1661
							rodzic
							
								
									8658c66438
								
							
						
					
					
						commit
						9979dcd07f
					
				|  | @ -134,11 +134,6 @@ SETTINGS = ( | |||
|         5, | ||||
|         "Default HTTP cache TTL (used in Cache-Control: max-age= header)", | ||||
|     ), | ||||
|     Setting( | ||||
|         "default_cache_ttl_hashed", | ||||
|         365 * 24 * 60 * 60, | ||||
|         "Default HTTP cache TTL for hashed URL pages", | ||||
|     ), | ||||
|     Setting("cache_size_kb", 0, "SQLite cache size in KB (0 == use SQLite default)"), | ||||
|     Setting( | ||||
|         "allow_csv_stream", | ||||
|  | @ -172,17 +167,11 @@ SETTINGS = ( | |||
|     ), | ||||
|     Setting("base_url", "/", "Datasette URLs should use this base path"), | ||||
| ) | ||||
| _HASH_URLS_REMOVED = "The hash_urls setting has been removed, try the datasette-hashed-urls plugin instead" | ||||
| OBSOLETE_SETTINGS = { | ||||
|     option.name: option | ||||
|     for option in ( | ||||
|         Setting( | ||||
|             "hash_urls", | ||||
|             False, | ||||
|             "The hash_urls setting has been removed, try the datasette-hashed-urls plugin instead", | ||||
|         ), | ||||
|     ) | ||||
|     "hash_urls": _HASH_URLS_REMOVED, | ||||
|     "default_cache_ttl_hashed": _HASH_URLS_REMOVED, | ||||
| } | ||||
| 
 | ||||
| DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS} | ||||
| 
 | ||||
| FAVICON_PATH = app_root / "datasette" / "static" / "favicon.png" | ||||
|  |  | |||
|  | @ -57,10 +57,10 @@ class Config(click.ParamType): | |||
|             return | ||||
|         name, value = config.split(":", 1) | ||||
|         if name not in DEFAULT_SETTINGS: | ||||
|             if name in OBSOLETE_SETTINGS: | ||||
|                 msg = OBSOLETE_SETTINGS[name].help | ||||
|             else: | ||||
|                 msg = f"{name} is not a valid option (--help-settings to see all)" | ||||
|             msg = ( | ||||
|                 OBSOLETE_SETTINGS.get(name) | ||||
|                 or f"{name} is not a valid option (--help-settings to see all)" | ||||
|             ) | ||||
|             self.fail( | ||||
|                 msg, | ||||
|                 param, | ||||
|  | @ -94,10 +94,10 @@ class Setting(CompositeParamType): | |||
|     def convert(self, config, param, ctx): | ||||
|         name, value = config | ||||
|         if name not in DEFAULT_SETTINGS: | ||||
|             if name in OBSOLETE_SETTINGS: | ||||
|                 msg = OBSOLETE_SETTINGS[name].help | ||||
|             else: | ||||
|                 msg = f"{name} is not a valid option (--help-settings to see all)" | ||||
|             msg = ( | ||||
|                 OBSOLETE_SETTINGS.get(name) | ||||
|                 or f"{name} is not a valid option (--help-settings to see all)" | ||||
|             ) | ||||
|             self.fail( | ||||
|                 msg, | ||||
|                 param, | ||||
|  |  | |||
|  | @ -28,14 +28,7 @@ class Urls: | |||
|         return self.path("-/logout") | ||||
| 
 | ||||
|     def database(self, database, format=None): | ||||
|         db = self.ds.databases[database] | ||||
|         if self.ds.setting("hash_urls") and db.hash: | ||||
|             path = self.path( | ||||
|                 f"{tilde_encode(database)}-{db.hash[:HASH_LENGTH]}", format=format | ||||
|             ) | ||||
|         else: | ||||
|             path = self.path(tilde_encode(database), format=format) | ||||
|         return path | ||||
|         return self.path(tilde_encode(database), format=format) | ||||
| 
 | ||||
|     def table(self, database, table, format=None): | ||||
|         path = f"{self.database(database)}/{tilde_encode(table)}" | ||||
|  |  | |||
|  | @ -798,14 +798,12 @@ def test_settings_json(app_client): | |||
|         "allow_facet": True, | ||||
|         "suggest_facets": True, | ||||
|         "default_cache_ttl": 5, | ||||
|         "default_cache_ttl_hashed": 365 * 24 * 60 * 60, | ||||
|         "num_sql_threads": 1, | ||||
|         "cache_size_kb": 0, | ||||
|         "allow_csv_stream": True, | ||||
|         "max_csv_mb": 100, | ||||
|         "truncate_cells_html": 2048, | ||||
|         "force_https_urls": False, | ||||
|         "hash_urls": False, | ||||
|         "template_debug": False, | ||||
|         "trace_debug": False, | ||||
|         "base_url": "/", | ||||
|  |  | |||
|  | @ -312,8 +312,9 @@ def test_help_settings(): | |||
|         assert setting.name in result.output | ||||
| 
 | ||||
| 
 | ||||
| def test_help_error_on_hash_urls_setting(): | ||||
| @pytest.mark.parametrize("setting", ("hash_urls", "default_cache_ttl_hashed")) | ||||
| def test_help_error_on_hash_urls_setting(setting): | ||||
|     runner = CliRunner() | ||||
|     result = runner.invoke(cli, ["--setting", "hash_urls", 1]) | ||||
|     result = runner.invoke(cli, ["--setting", setting, 1]) | ||||
|     assert result.exit_code == 2 | ||||
|     assert 'The hash_urls setting has been removed' in result.output | ||||
|     assert "The hash_urls setting has been removed" in result.output | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Simon Willison
						Simon Willison