Mercurial > p > roundup > code
comparison roundup/configuration.py @ 3620:17124caa2491
added timezone option (based on patch [SF#1465296])
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sat, 06 May 2006 17:15:11 +0000 |
| parents | f2fda3e6fc8b |
| children | 65badf6ab7ad |
comparison
equal
deleted
inserted
replaced
| 3619:df7bff6f8a2f | 3620:17124caa2491 |
|---|---|
| 1 # Roundup Issue Tracker configuration support | 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 __docformat__ = "restructuredtext" | 5 __docformat__ = "restructuredtext" |
| 6 | 6 |
| 7 import getopt | 7 import getopt |
| 8 import imp | 8 import imp |
| 9 import os | 9 import os |
| 10 import time | 10 import time |
| 11 import ConfigParser | 11 import ConfigParser |
| 12 import logging, logging.config | 12 import logging, logging.config |
| 13 import sys | 13 import sys |
| 14 | |
| 15 import roundup.date | |
| 14 | 16 |
| 15 # XXX i don't think this module needs string translation, does it? | 17 # XXX i don't think this module needs string translation, does it? |
| 16 | 18 |
| 17 ### Exceptions | 19 ### Exceptions |
| 18 | 20 |
| 404 | 406 |
| 405 # .get() and class_description are from FilePathOption, | 407 # .get() and class_description are from FilePathOption, |
| 406 get = FilePathOption.get | 408 get = FilePathOption.get |
| 407 class_description = FilePathOption.class_description | 409 class_description = FilePathOption.class_description |
| 408 # everything else taken from NullableOption (inheritance order) | 410 # everything else taken from NullableOption (inheritance order) |
| 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 | |
| 409 | 427 |
| 410 ### Main configuration layout. | 428 ### Main configuration layout. |
| 411 # Config is described as a sequence of sections, | 429 # Config is described as a sequence of sections, |
| 412 # where each section name is followed by a sequence | 430 # where each section name is followed by a sequence |
| 413 # of Option definitions. Each Option definition | 431 # of Option definitions. Each Option definition |
| 461 (Option, "html_version", "html4", | 479 (Option, "html_version", "html4", |
| 462 "HTML version to generate. The templates are html4 by default.\n" | 480 "HTML version to generate. The templates are html4 by default.\n" |
| 463 "If you wish to make them xhtml, then you'll need to change this\n" | 481 "If you wish to make them xhtml, then you'll need to change this\n" |
| 464 "var to 'xhtml' too so all auto-generated HTML is compliant.\n" | 482 "var to 'xhtml' too so all auto-generated HTML is compliant.\n" |
| 465 "Allowed values: html4, xhtml"), | 483 "Allowed values: html4, xhtml"), |
| 466 # It seems to me that all timezone offsets in the modern world | 484 (TimezoneOption, "timezone", "UTC", "Default timezone offset," |
| 467 # are integral hours. However, there were fractional hour offsets | 485 " applied when user's timezone is not set.", |
| 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.", | |
| 472 ["DEFAULT_TIMEZONE"]), | 486 ["DEFAULT_TIMEZONE"]), |
| 473 (BooleanOption, "instant_registration", "no", | 487 (BooleanOption, "instant_registration", "no", |
| 474 "Register new users instantly, or require confirmation via\n" | 488 "Register new users instantly, or require confirmation via\n" |
| 475 "email?"), | 489 "email?"), |
| 476 (BooleanOption, "email_registration_confirmation", "yes", | 490 (BooleanOption, "email_registration_confirmation", "yes", |
