|
1 | 1 | # Roundup Issue Tracker configuration support |
2 | 2 | # |
3 | | -# $Id: configuration.py,v 1.34 2006-04-27 04:59:37 richard Exp $ |
| 3 | +# $Id: configuration.py,v 1.35 2006-05-06 17:15:11 a1s Exp $ |
4 | 4 | # |
5 | 5 | __docformat__ = "restructuredtext" |
6 | 6 |
|
|
12 | 12 | import logging, logging.config |
13 | 13 | import sys |
14 | 14 |
|
| 15 | +import roundup.date |
| 16 | + |
15 | 17 | # XXX i don't think this module needs string translation, does it? |
16 | 18 |
|
17 | 19 | ### Exceptions |
@@ -407,6 +409,22 @@ class NullableFilePathOption(NullableOption, FilePathOption): |
407 | 409 | class_description = FilePathOption.class_description |
408 | 410 | # everything else taken from NullableOption (inheritance order) |
409 | 411 |
|
| 412 | +class TimezoneOption(Option): |
| 413 | + |
| 414 | + class_description = \ |
| 415 | + "If pytz module is installed, value may be any valid\n" \ |
| 416 | + "timezone specification (e.g. EET or Europe/Warsaw).\n" \ |
| 417 | + "If pytz is not installed, value must be integer number\n" \ |
| 418 | + "giving local timezone offset from UTC in hours." |
| 419 | + |
| 420 | + def str2value(self, value): |
| 421 | + try: |
| 422 | + roundup.date.get_timezone(value) |
| 423 | + except KeyError: |
| 424 | + raise OptionValueError(self, value, |
| 425 | + "Timezone name or numeric hour offset required") |
| 426 | + return value |
| 427 | + |
410 | 428 | ### Main configuration layout. |
411 | 429 | # Config is described as a sequence of sections, |
412 | 430 | # where each section name is followed by a sequence |
@@ -463,12 +481,8 @@ class NullableFilePathOption(NullableOption, FilePathOption): |
463 | 481 | "If you wish to make them xhtml, then you'll need to change this\n" |
464 | 482 | "var to 'xhtml' too so all auto-generated HTML is compliant.\n" |
465 | 483 | "Allowed values: html4, xhtml"), |
466 | | - # It seems to me that all timezone offsets in the modern world |
467 | | - # are integral hours. However, there were fractional hour offsets |
468 | | - # in the past. Use float number for sure. |
469 | | - (FloatNumberOption, "timezone", "0", |
470 | | - "Numeric timezone offset used when users do not choose their own\n" |
471 | | - "in their settings.", |
| 484 | + (TimezoneOption, "timezone", "UTC", "Default timezone offset," |
| 485 | + " applied when user's timezone is not set.", |
472 | 486 | ["DEFAULT_TIMEZONE"]), |
473 | 487 | (BooleanOption, "instant_registration", "no", |
474 | 488 | "Register new users instantly, or require confirmation via\n" |
|
0 commit comments