Mercurial > p > roundup > code
comparison roundup/configuration.py @ 5754:178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
timezone database not installed
Create property TimezoneOption.defaulttz properly and use it to
initialize the entry in the SETTINGS data structure for the timezone
option.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 01 Jun 2019 17:59:20 -0400 |
| parents | 943e61bc26d5 |
| children | f91da208f26b |
comparison
equal
deleted
inserted
replaced
| 5753:486824f4455a | 5754:178ca608ddb9 |
|---|---|
| 542 "If pytz module is installed, value may be any valid\n" \ | 542 "If pytz module is installed, value may be any valid\n" \ |
| 543 "timezone specification (e.g. EET or Europe/Warsaw).\n" \ | 543 "timezone specification (e.g. EET or Europe/Warsaw).\n" \ |
| 544 "If pytz is not installed, value must be integer number\n" \ | 544 "If pytz is not installed, value must be integer number\n" \ |
| 545 "giving local timezone offset from UTC in hours." | 545 "giving local timezone offset from UTC in hours." |
| 546 | 546 |
| 547 # fix issue2551030, default value for timezone | |
| 548 # Must be 0 if no pytz can be UTC if pytz. | |
| 549 try: | |
| 550 import pytz | |
| 551 defaulttz = "UTC" | |
| 552 except ImportError: | |
| 553 defaulttz = "0" | |
| 554 | |
| 547 def str2value(self, value): | 555 def str2value(self, value): |
| 548 try: | 556 try: |
| 549 roundup.date.get_timezone(value) | 557 roundup.date.get_timezone(value) |
| 550 except KeyError: | 558 except KeyError: |
| 551 raise OptionValueError(self, value, | 559 raise OptionValueError(self, value, |
| 552 "Timezone name or numeric hour offset required") | 560 "Timezone name or numeric hour offset required") |
| 553 return value | 561 return value |
| 554 | 562 |
| 563 | |
| 555 class RegExpOption(Option): | 564 class RegExpOption(Option): |
| 556 | 565 |
| 557 """Regular Expression option (value is Regular Expression Object)""" | 566 """Regular Expression option (value is Regular Expression Object)""" |
| 558 | 567 |
| 559 class_description = "Value is Python Regular Expression (UTF8-encoded)." | 568 class_description = "Value is Python Regular Expression (UTF8-encoded)." |
| 656 (Option, "html_version", "html4", | 665 (Option, "html_version", "html4", |
| 657 "HTML version to generate. The templates are html4 by default.\n" | 666 "HTML version to generate. The templates are html4 by default.\n" |
| 658 "If you wish to make them xhtml, then you'll need to change this\n" | 667 "If you wish to make them xhtml, then you'll need to change this\n" |
| 659 "var to 'xhtml' too so all auto-generated HTML is compliant.\n" | 668 "var to 'xhtml' too so all auto-generated HTML is compliant.\n" |
| 660 "Allowed values: html4, xhtml"), | 669 "Allowed values: html4, xhtml"), |
| 661 (TimezoneOption, "timezone", "UTC", "Default timezone offset," | 670 (TimezoneOption, "timezone", TimezoneOption.defaulttz, |
| 671 "Default timezone offset," | |
| 662 " applied when user's timezone is not set.", | 672 " applied when user's timezone is not set.", |
| 663 ["DEFAULT_TIMEZONE"]), | 673 ["DEFAULT_TIMEZONE"]), |
| 664 (BooleanOption, "instant_registration", "no", | 674 (BooleanOption, "instant_registration", "no", |
| 665 "Register new users instantly, or require confirmation via\n" | 675 "Register new users instantly, or require confirmation via\n" |
| 666 "email?"), | 676 "email?"), |
