#9581 closed enhancement (fixed)
Documentation page for TracIni should list or have reference to allowed values for default_timezone
| Reported by: | ryano@… | Owned by: | Ryan J Ollos <ryano@…> |
|---|---|---|---|
| Priority: | high | Milestone: | 1.0 |
| Component: | general | Version: | 0.12dev |
| Severity: | normal | Keywords: | bitesized, patch |
| Cc: | |||
| Release Notes: |
admin: the default timezone and default language can be set in the "Basic Settings" panel |
||
| API Changes: | |||
Description
I had a bit of a difficult time figuring out what are the valid values for the default_timezone option in the [trac] section of trac.ini. It seems like the allowed values should be documented at TracIni#trac-section, or an external reference pointed to.
Another option might be to add it to Basic Settings section of the WebAdmin panel and allow a drop down list of allowed values.
Attachments (5)
Change History (22)
comment:1 follow-up: ↓ 2 Changed 3 years ago by rblank
- Keywords bitesized added
- Milestone set to unscheduled
comment:2 in reply to: ↑ 1 Changed 3 years ago by Ryan Ollos <ryano@…>
Replying to rblank:
Except for the "GMT +xx:xx" zones, the names are defined in pytz, so we can't just list them in the documentation. We could list the GMT+offset zones, and provide a link to the pytz documentation.
I searched around but couldn't find a list of names in the pytz documentation. There is described a way to generate them, which could be pointed to in the Trac docs, or perhaps there is some way to use this pytz function to generate output for the Trac docs.
Then again, an entry in the "Basic Settings" sounds nice, too, and we already have the necessary code in the user preferences, so it shouldn't be too difficult.
I'll have a first cut at a patch for this ready by this evening.
Changed 3 years ago by Ryan J Ollos <ryano@…>
comment:3 Changed 3 years ago by Ryan J Ollos <ryano@…>
Is default_timezone a property of some object, like project_name can be accessed in self.env.project_name? I've spent some time looking at localtz in trac.utils.datefmt, and also calling self.config.get('trac', 'default_timezone') within render_admin_panel. It doesn't seem to be behaving well, so I thinking I'm doing this wrong.
I added the select list to the Basic Settings panel at the following position:
comment:4 follow-up: ↓ 5 Changed 3 years ago by rblank
The default_timezone option is defined in RequestDispatcher. You can get and set the value via this property, or go through self.config if it's easier. What do you mean with "doesn't seem to be behaving well"? Don't hesitate to post a patch (even incomplete).
The place where you put the selector looks fine.
comment:5 in reply to: ↑ 4 Changed 3 years ago by Ryan J Ollos <ryano@…>
Replying to rblank:
What do you mean with "doesn't seem to be behaving well"? Don't hesitate to post a patch (even incomplete).
I'm struggling a bit with passing data between the template and render_admin_panel. I'll spend a little bit of time with it tomorrow morning, and then post what I have so far (and also spend some time testing your revised patch in #9582 at that time). Thanks!
comment:6 Changed 3 years ago by Ryan J Ollos <ryano@…>
Here is my first cut at a patch. The main question I have is over the use of pytz objects vs strings. Since all_timezones is a list of strings, I've coded it so that the template does a string comparison and returns a string. However, default_timezone is a pytz object. It seemed safer to pass the string value to get_timezone since it seems to handle the error checking.
I looked at the code in prefs_datetime.html, but did things a bit differently. It seems like the following code is overly complicated. For example, I'm not sure why settings.session.get('tz') would be called from the template rather than passing a value for session_tzname from PreferencesModule.render_preference_panel.
<div class="field" py:with="session_tzname = settings.session.get('tz'); selected_tz = timezone(session_tzname) or utc"> <label>Time zone: <select name="tz"> <option value="None">Default time zone</option> <option py:for="tzname in timezones" value="${tzname}" selected="${session_tzname != None and session_tzname.startswith('Etc/') and selected_tz == timezone(tzname) or session_tzname == tzname or None}">${tzname}</option> </select></label>
Changed 3 years ago by Ryan J Ollos <ryano@…>
Changed 3 years ago by Ryan J Ollos <ryano@…>
Changed 3 years ago by Ryan J Ollos <ryano@…>
comment:7 Changed 3 years ago by Ryan J Ollos <ryano@…>
comment:8 follow-up: ↓ 9 Changed 3 years ago by rblank
- Milestone changed from unscheduled to 0.13
- Owner set to rblank
Looks good at first sight. One comment, though: placing the content of <textarea> fields on a new line is intentional, as it fixes an issue with IE (I can't find the relevant ticket ATM, but I'm sure Christian will chime in). Please don't change those.
comment:9 in reply to: ↑ 8 Changed 3 years ago by cboos
comment:10 Changed 3 years ago by rblank
- Priority changed from normal to high
comment:11 Changed 3 years ago by cboos
- Keywords needfixup added
comment:12 Changed 3 years ago by rblank
9581-default-tz-lang-r10162.patch is a reworked version of your patch, and (while I was at it) also adds a select box for the default language. Testing welcome.
About comment:7, I can't reproduce that with current trunk, but it may have been fixed in [10160]. If this is still happening for you, please provide the value of [trac] default_timezone on your system, as well as your version of pytz (if installed).
comment:13 Changed 3 years ago by rblank
- Keywords patch added; needfixup removed
comment:14 Changed 3 years ago by rblank
- Resolution set to fixed
- Status changed from new to closed
Patch applied in [10178]. Thanks Ryan for your excellent patch!
comment:15 Changed 3 years ago by rblank
- Owner changed from rblank to Ryan J Ollos <ryano@…>
comment:16 Changed 3 years ago by Ryan Ollos <ryano@…>
Thanks for revising and applying the patch! Normally I'd be able to help test it out in the few days you made available, but have been exceptionally busy lately. On to the next ticket soon I hope …
comment:17 Changed 3 years ago by cboos
- Release Notes modified (diff)





Except for the "GMT +xx:xx" zones, the names are defined in pytz, so we can't just list them in the documentation. We could list the GMT+offset zones, and provide a link to the pytz documentation.
Then again, an entry in the "Basic Settings" sounds nice, too, and we already have the necessary code in the user preferences, so it shouldn't be too difficult.