Modify

Opened 11 years ago

Closed 8 years ago

Last modified 8 years ago

#10775 closed defect (fixed)

KeyError: 'utc'

Reported by: falkb Owned by: Ryan J Ollos
Priority: normal Component: WikiFormsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by Ryan J Ollos)

I installed it, used your example, changed a form value, pressed the "Send" button and "KeyError: 'utc'" appears:

File ".../Trac-1.0-py2.7.egg-tmp/trac/ticket/templates/ticket_box.html", line 109, in <Expression u'wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)'>
  ${wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)}
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1546, in format_to_html
  return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1501, in generate
  escape_newlines)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1244, in format
  self.handle_code_block(line, block_start_match)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1134, in handle_code_block
  processed = self.code_processor.process(code_text)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 356, in process
  text = self.processor(text)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 343, in _macro_processor
  text)
File "build/bdist.win32/egg/wikiforms/wikiforms.py", line 520, in expand_macro
  time_string   = format_datetime(last_modified,'%a %b %d %T %Y %Z',timezone(timezone_name))                                   
File "build/bdist.win32/egg/trac/util/datefmt.py", line 874, in timezone
  return _tzmap[tzname]

Attachments (0)

Change History (9)

comment:1 Changed 11 years ago by anonymous

...seems that 'utc' is not a valid timezone (you might try 'UTC' instead) or set a timezone (e.g. CET) in trac.ini.

[trac]
default_timezone = CET
Version 0, edited 11 years ago by anonymous (next)

comment:2 Changed 11 years ago by falkb

I changed the code from 'utc' to 'UTC' and it seems I get one step further, though stopped on the next error which is "ValueError: Invalid format string":

File ".../Trac-1.0-py2.7.egg-tmp/trac/ticket/templates/ticket_box.html", line 109, in <Expression u'wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)'>
  ${wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)}
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1546, in format_to_html
  return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1501, in generate
  escape_newlines)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1244, in format
  self.handle_code_block(line, block_start_match)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 1134, in handle_code_block
  processed = self.code_processor.process(code_text)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 356, in process
  text = self.processor(text)
File "build/bdist.win32/egg/trac/wiki/formatter.py", line 343, in _macro_processor
  text)
File "build/bdist.win32/egg/wikiforms/wikiforms.py", line 520, in expand_macro
  time_string   = format_datetime(last_modified,'%a %b %d %T %Y %Z',timezone(timezone_name))                                   
File "build/bdist.win32/egg/trac/util/datefmt.py", line 219, in format_datetime
  return _format_datetime_without_babel(t, format, tzinfo)
File "build/bdist.win32/egg/trac/util/datefmt.py", line 184, in _format_datetime_without_babel
  text = t.strftime(str(format))
Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:3 Changed 11 years ago by falkb

changing line 520 to

time_string   = format_datetime(last_modified

let the plugin run without error. The output may not be as you indented. The form displays now: Last Modified: 1/9/2013 10:27:32 AM (77 minutes ago) by falkb

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:4 Changed 8 years ago by Ryan J Ollos

Description: modified (diff)

comment:5 Changed 8 years ago by Ryan J Ollos

In 14958:

0.3dev: Convert tabs to spaces and strip whitespace

Some PEP-0008 fixes were made, but more could be done.

Refs #10775.

comment:6 Changed 8 years ago by Ryan J Ollos

Owner: changed from asic_druide to Ryan J Ollos
Status: newaccepted

comment:7 Changed 8 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 14959:

0.3dev: Fix incorrect date formatting.

There are extensive problems with date and time handling in the codebase, but this changes fixes a traceback with KeyError: 'utc'.

Thanks to falkb for the report.

Fixes #10775.

comment:8 Changed 8 years ago by Ryan J Ollos

I should probably be more careful about handling of req.locale for Trac < 0.12, but those early versions of Trac are dead to me and I'll fix it if someone complains.

comment:9 Changed 8 years ago by Ryan J Ollos

In 15696:

0.3dev: Fix indentation

This is a follow-on to r14958.

Patch by endre.gabriel@….

Refs #10775, Fixes #12841.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.