Modify

Opened 9 years ago

Last modified 7 years ago

#12133 new defect

WikiCalendarMacros uses undefined function format_datetime if babel library is not importable

Reported by: nick.piper@… Owned by:
Priority: normal Component: WikiCalendarMacro
Severity: normal Keywords: patch
Cc: Trac Release:

Description

There is some fallback code in source:wikicalendarmacro/trunk/wikicalendar/macros.py@13798

has_babel = True
try:
    from babel import Locale, UnknownLocaleError
    from babel.core import LOCALE_ALIASES
    from babel.dates import format_datetime, get_day_names
except ImportError:
    has_babel = False
    def get_day_names(*args):
        """Cheap replacement for the identically named Babel function."""
        names = dict()
        for day in range(0, 7):
            dt = datetime(2001, 1, day + 1)
            names[day] = dt.strftime('%a')[:2]
        return names

but this is incomplete, as no alternative for format_datetime() is provided, and format_datetime() is called in the implementation.

I'll attach a patch which shows how we resolved this for our own project.

Attachments (1)

changeset_24890.diff (3.3 KB) - added by nick.piper@… 9 years ago.
Candidate patch for #12133, against revision 13798

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by nick.piper@…

Attachment: changeset_24890.diff added

Candidate patch for #12133, against revision 13798

comment:1 Changed 9 years ago by Steffen Hoffmann

In 14364:

WikiCalendarMacro: Add missing import-fallback for format_datetime, refs #12133.

This issue on Trac installations without Babel as well as the patch have been
kindly contributed by Nick Piper, thank you.

comment:2 Changed 7 years ago by Ryan J Ollos

Owner: Steffen Hoffmann deleted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


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

 
Note: See TracTickets for help on using tickets.