Opened 11 years ago

Last modified 8 years ago

#10775 closed defect

KeyError: 'utc' — at Version 4

Reported by: falkb Owned by: asic_druide
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]

Change History (4)

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
Last edited 9 years ago by Ryan J Ollos (previous) (diff)

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 9 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 9 years ago by Ryan J Ollos (previous) (diff)

comment:4 Changed 9 years ago by Ryan J Ollos

Description: modified (diff)
Note: See TracTickets for help on using tickets.