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 #1326 (closed enhancement: fixed)

Opened 12 years ago

Last modified 12 years ago

[PATCH] Some minor updates to twForms and twGrids

Reported by: wavy Owned by: alberto
Priority: normal Milestone: 1.0.2
Component: ToscaWidgets Version: 1.0
Severity: minor Keywords:
Cc:

Description

First patch adds the (strangely missing) option to provide a callable as the 'options' parameter for a SelectedField?, which is the behaviour in TG's original widgets, and a pretty useful one at that.

Second is to grab the label_text (if any) of any widgets passed as twGrid columns as the label for that columns, as opposed to making the widget name look pretty.

Both fairly trivial, but useful, at least to me :)

Attachments

twForms.callableoptions.patch Download (408 bytes) - added by wavy 12 years ago.
toscawidgets.calllable_wo_args.patch Download (555 bytes) - added by wavy 12 years ago.
twGrids.labeltitle.patch Download (565 bytes) - added by wavy 12 years ago.

Change History

Changed 12 years ago by wavy

comment:1 Changed 12 years ago by wavy

  • Type changed from defect to enhancement

comment:2 follow-ups: ↓ 4 ↓ 5 Changed 12 years ago by alberto

  • Status changed from new to assigned

Hi Wavy,

Thanks for the pacthes. The one to twGrids looks fine (I'll commit it asap), however, the one to twForms shouldn't be needed because callable params should be automatically called at update_params:

>>> from toscawidgets.widgets.forms import SingleSelectField
>>> print SingleSelectField(options=lambda: range(3))
<select xmlns="http://www.w3.org/1999/xhtml" class="singleselectfield">
        <option value="0">0</option><option value="1">1</option><option value="2">2</option>
</select>

There's probably a bug somewhere, can you please send a TestCase? that reproduces the problem so I can fix the root cause?

Thanks

Alberto

comment:3 Changed 12 years ago by wavy

Have updated twGrid patch as I hadn't tested it properly, and it was bailing because if label_text is not set, its not defined until update_params()

comment:4 in reply to: ↑ 2 Changed 12 years ago by wavy

Replying to alberto:

Hi Wavy,

Thanks for the pacthes. The one to twGrids looks fine (I'll commit it asap),

[snip]

There's probably a bug somewhere, can you please send a TestCase? that reproduces the problem so I can fix the root cause?

Ok, will do, but it will have to wait a little as I have deadlines. Some time next week hopefully. I wasn't doing any thing fancy just a lambda.

comment:5 in reply to: ↑ 2 ; follow-up: ↓ 7 Changed 12 years ago by wavy

Replying to alberto:

There's probably a bug somewhere, can you please send a TestCase? that reproduces the problem so I can fix the root cause?

There was bug, maybe in my code, anyway :) I was passing a method in as options (not a function), and in Widget.update_params uses util.callable_wo_args to filter any callables, which doesn't handle the fact that a method always has one bound parameter. Will attach another patch with trivial fix, but there may be a better way to do it. But I think passing in methods is a reasonable behaviour? I've wrapped mine in a lambda for now, but its worth supporting them directly, IMO.

Changed 12 years ago by wavy

Changed 12 years ago by wavy

comment:6 Changed 12 years ago by wavy

Just updated the twGrids patch, a better way to do it, I think

comment:7 in reply to: ↑ 5 Changed 12 years ago by alberto

Replying to wavy:

Replying to alberto:

There's probably a bug somewhere, can you please send a TestCase? that reproduces the problem so I can fix the root cause?

There was bug, maybe in my code, anyway :) I was passing a method in as options (not a function), and in Widget.update_params uses util.callable_wo_args to filter any callables, which doesn't handle the fact that a method always has one bound parameter. Will attach another patch with trivial fix, but there may be a better way to do it. But I think passing in methods is a reasonable behaviour? I've wrapped mine in a lambda for now, but its worth supporting them directly, IMO.

Committed the "callables" patch at [2773] with a short test. Would you mind sending a short one for the grid labels one?

Thanks :)

Alberto

comment:8 Changed 12 years ago by alberto

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

Applied at #2831 with some unittests.

Thanks :)

Alberto

Note: See TracTickets for help on using tickets.