Modify

Opened 4 years ago

Closed 14 months ago

Last modified 4 months ago

#10775 closed defect (fixed)

KeyError: 'utc'

Reported by: falkb Owned by: rjollos
Priority: normal Component: WikiFormsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by rjollos)

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 4 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 14 months ago by rjollos (previous) (diff)

comment:2 Changed 4 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 14 months ago by rjollos (previous) (diff)

comment:3 Changed 4 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 14 months ago by rjollos (previous) (diff)

comment:4 Changed 14 months ago by rjollos

  • Description modified (diff)

comment:5 Changed 14 months ago by rjollos

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 14 months ago by rjollos

  • Owner changed from asic_druide to rjollos
  • Status changed from new to accepted

comment:7 Changed 14 months ago by rjollos

  • Resolution set to fixed
  • Status changed from accepted to closed

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 14 months ago by rjollos

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 4 months ago by rjollos

In 15696:

0.3dev: Fix indentation

This is a follow-on to r14958.

Patch by endre.gabriel@….

Refs #10775, Fixes #12841.

Add Comment

Modify Ticket

Action
as closed The owner will remain rjollos.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.