Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1260 (closed enhancement: fixed)

Opened 12 years ago

Last modified 12 years ago

Cannot provide callable default to CalendarDatePicker

Reported by: simonk Owned by: alberto
Priority: normal Milestone:
Component: ToscaWidgets Version:
Severity: minor Keywords:
Cc:

Description (last modified by jorge.vargas) (diff)

The CalendarDatePicker? does not allow for callable default values. This makes it awkward to display a widget that defaults to '1 week ago' for example. The current _get_default method looks like this:

    def _get_default(self):
        if self._default is None and self.not_empty:
            return datetime.now()
        return self._default

I've subclassed the widget to do this:

    def _get_default(self):
        if self._default is None and self.not_empty:
            return datetime.now()
        if callable(self._default):
            return self._default()
        return self._default

but I don't know if there is a better way, perhaps using the ParamDescriptor? magic. From a quick look at the ToscaWidgets? source, I think the same issue exists there.


Change History

comment:1 Changed 12 years ago by alberto

  • Priority changed from low to normal
  • Owner changed from anonymous to alberto
  • Version 1.0 deleted
  • Component changed from Widgets to toscaWidgets
  • Milestone 1.0.2 deleted

Take a look at #1192.

Regarding ToscaWidgets? I'll take a look at it soon... this functionallity would be nice for every widget, not just calendars, Moving this ticket to the TW component.

Alberto

comment:2 Changed 12 years ago by simonk

Ah yes - I should have searched harder. Thanks for that,

Simon

comment:3 Changed 12 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to invalid
  • Description modified (diff)

hi simonk please close the tickets if the issue is solved, it will also be a good idea to post to the mailing list first :)

comment:4 Changed 12 years ago by simonk

Hi Jorge,

From Alberto's response, I understood that he wanted this ticket to stay open as a feature request for ToscaWidgets?. However, I'll leave it up to you guys, since you are the ones that do all the hard work round here!

Cheers,

Simon

comment:5 Changed 12 years ago by jorge.vargas

  • Status changed from closed to reopened
  • Resolution invalid deleted

ahh sorry set back to TW

comment:6 Changed 12 years ago by alberto

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

default can be a callable in TW since [2832]

Alberto

Note: See TracTickets for help on using tickets.