@@ -1377,9 +1377,9 @@ def buffer_size(self, size):
1377
1377
def cache_dir_base (self , new_base ):
1378
1378
"""Base directory to use for caching content.
1379
1379
1380
- Changing this to a different value will clear the `cache_dir` path
1380
+ Changing this to a different value will clear the :attr: `cache_dir` path
1381
1381
stored in TLS since a new path will need to be generated to respect the
1382
- new `cache_dir_base` value.
1382
+ new :attr: `cache_dir_base` value.
1383
1383
"""
1384
1384
1385
1385
if new_base != self .cache_dir_base :
@@ -1394,19 +1394,28 @@ def cache_dir(self):
1394
1394
1395
1395
Note:
1396
1396
May be either a path string, or :const:`None`.
1397
+ Set to :const:`None` to disable caching.
1398
+ Set to :const:`True` to generate the default cache directory path
1399
+ based on :attr:`cache_dir_base` again.
1397
1400
1398
1401
Example:
1399
1402
1400
1403
>>> cache_dir = context.cache_dir
1401
1404
>>> cache_dir is not None
1402
1405
True
1403
1406
>>> os.chmod(cache_dir, 0o000)
1404
- >>> del context._tls[' cache_dir']
1407
+ >>> context.cache_dir = True
1405
1408
>>> context.cache_dir is None
1406
1409
True
1407
1410
>>> os.chmod(cache_dir, 0o755)
1408
1411
>>> cache_dir == context.cache_dir
1409
1412
True
1413
+ >>> context.cache_dir = None
1414
+ >>> context.cache_dir is None
1415
+ True
1416
+ >>> context.cache_dir = True
1417
+ >>> context.cache_dir is not None
1418
+ True
1410
1419
"""
1411
1420
try :
1412
1421
# If the TLS already has a cache directory path, we return it
@@ -1451,7 +1460,9 @@ def cache_dir(self):
1451
1460
1452
1461
@cache_dir .setter
1453
1462
def cache_dir (self , v ):
1454
- if os .access (v , os .W_OK ):
1463
+ if v is True :
1464
+ del self ._tls ["cache_dir" ]
1465
+ elif v is None or os .access (v , os .W_OK ):
1455
1466
# Stash this in TLS for later reuse
1456
1467
self ._tls ["cache_dir" ] = v
1457
1468
0 commit comments