Show More
@@ -436,13 +436,23 b' def _sanitize_vcs_settings(settings):' | |||
|
436 | 436 | |
|
437 | 437 | |
|
438 | 438 | def _sanitize_cache_settings(settings): |
|
439 | _string_setting(settings, 'cache_dir', | |
|
440 | os.path.join(tempfile.gettempdir(), 'rc_cache')) | |
|
439 | default_cache_dir = os.path.join(tempfile.gettempdir(), 'rc_cache') | |
|
440 | ||
|
441 | # save default, cache dir, and use it for all backends later. | |
|
442 | default_cache_dir = _string_setting( | |
|
443 | settings, | |
|
444 | 'cache_dir', | |
|
445 | default_cache_dir, lower=False, default_when_empty=True) | |
|
446 | ||
|
447 | # ensure we have our dir created | |
|
448 | if not os.path.isdir(default_cache_dir): | |
|
449 | os.makedirs(default_cache_dir, mode=0755) | |
|
450 | ||
|
441 | 451 | # cache_perms |
|
442 | 452 | _string_setting( |
|
443 | 453 | settings, |
|
444 | 454 | 'rc_cache.cache_perms.backend', |
|
445 | 'dogpile.cache.rc.file_namespace') | |
|
455 | 'dogpile.cache.rc.file_namespace', lower=False) | |
|
446 | 456 | _int_setting( |
|
447 | 457 | settings, |
|
448 | 458 | 'rc_cache.cache_perms.expiration_time', |
@@ -450,13 +460,13 b' def _sanitize_cache_settings(settings):' | |||
|
450 | 460 | _string_setting( |
|
451 | 461 | settings, |
|
452 | 462 | 'rc_cache.cache_perms.arguments.filename', |
|
453 |
os.path.join( |
|
|
463 | os.path.join(default_cache_dir, 'rc_cache_1'), lower=False) | |
|
454 | 464 | |
|
455 | 465 | # cache_repo |
|
456 | 466 | _string_setting( |
|
457 | 467 | settings, |
|
458 | 468 | 'rc_cache.cache_repo.backend', |
|
459 | 'dogpile.cache.rc.file_namespace') | |
|
469 | 'dogpile.cache.rc.file_namespace', lower=False) | |
|
460 | 470 | _int_setting( |
|
461 | 471 | settings, |
|
462 | 472 | 'rc_cache.cache_repo.expiration_time', |
@@ -464,13 +474,13 b' def _sanitize_cache_settings(settings):' | |||
|
464 | 474 | _string_setting( |
|
465 | 475 | settings, |
|
466 | 476 | 'rc_cache.cache_repo.arguments.filename', |
|
467 |
os.path.join( |
|
|
477 | os.path.join(default_cache_dir, 'rc_cache_2'), lower=False) | |
|
468 | 478 | |
|
469 | 479 | # cache_license |
|
470 | 480 | _string_setting( |
|
471 | 481 | settings, |
|
472 | 482 | 'rc_cache.cache_license.backend', |
|
473 | 'dogpile.cache.rc.file_namespace') | |
|
483 | 'dogpile.cache.rc.file_namespace', lower=False) | |
|
474 | 484 | _int_setting( |
|
475 | 485 | settings, |
|
476 | 486 | 'rc_cache.cache_license.expiration_time', |
@@ -478,13 +488,13 b' def _sanitize_cache_settings(settings):' | |||
|
478 | 488 | _string_setting( |
|
479 | 489 | settings, |
|
480 | 490 | 'rc_cache.cache_license.arguments.filename', |
|
481 |
os.path.join( |
|
|
491 | os.path.join(default_cache_dir, 'rc_cache_3'), lower=False) | |
|
482 | 492 | |
|
483 | 493 | # cache_repo_longterm memory, 96H |
|
484 | 494 | _string_setting( |
|
485 | 495 | settings, |
|
486 | 496 | 'rc_cache.cache_repo_longterm.backend', |
|
487 | 'dogpile.cache.rc.memory_lru') | |
|
497 | 'dogpile.cache.rc.memory_lru', lower=False) | |
|
488 | 498 | _int_setting( |
|
489 | 499 | settings, |
|
490 | 500 | 'rc_cache.cache_repo_longterm.expiration_time', |
@@ -498,7 +508,7 b' def _sanitize_cache_settings(settings):' | |||
|
498 | 508 | _string_setting( |
|
499 | 509 | settings, |
|
500 | 510 | 'rc_cache.sql_cache_short.backend', |
|
501 | 'dogpile.cache.rc.memory_lru') | |
|
511 | 'dogpile.cache.rc.memory_lru', lower=False) | |
|
502 | 512 | _int_setting( |
|
503 | 513 | settings, |
|
504 | 514 | 'rc_cache.sql_cache_short.expiration_time', |
@@ -511,6 +521,7 b' def _sanitize_cache_settings(settings):' | |||
|
511 | 521 | |
|
512 | 522 | def _int_setting(settings, name, default): |
|
513 | 523 | settings[name] = int(settings.get(name, default)) |
|
524 | return settings[name] | |
|
514 | 525 | |
|
515 | 526 | |
|
516 | 527 | def _bool_setting(settings, name, default): |
@@ -518,6 +529,7 b' def _bool_setting(settings, name, defaul' | |||
|
518 | 529 | if isinstance(input_val, unicode): |
|
519 | 530 | input_val = input_val.encode('utf8') |
|
520 | 531 | settings[name] = asbool(input_val) |
|
532 | return settings[name] | |
|
521 | 533 | |
|
522 | 534 | |
|
523 | 535 | def _list_setting(settings, name, default): |
@@ -530,13 +542,20 b' def _list_setting(settings, name, defaul' | |||
|
530 | 542 | else: |
|
531 | 543 | # Otherwise we assume it uses pyramids space/newline separation. |
|
532 | 544 | settings[name] = aslist(raw_value) |
|
545 | return settings[name] | |
|
533 | 546 | |
|
534 | 547 | |
|
535 | def _string_setting(settings, name, default, lower=True): | |
|
548 | def _string_setting(settings, name, default, lower=True, default_when_empty=False): | |
|
536 | 549 | value = settings.get(name, default) |
|
550 | ||
|
551 | if default_when_empty and not value: | |
|
552 | # use default value when value is empty | |
|
553 | value = default | |
|
554 | ||
|
537 | 555 | if lower: |
|
538 | 556 | value = value.lower() |
|
539 | 557 | settings[name] = value |
|
558 | return settings[name] | |
|
540 | 559 | |
|
541 | 560 | |
|
542 | 561 | def _substitute_values(mapping, substitutions): |
General Comments 0
You need to be logged in to leave comments.
Login now