Thanks :)
>
> As deeper i digg in the Source far more Questions i get. I'm not a
> fulltime Python Developer because of that some parts are hard to
> understand for me...
>
> I'm working with TW on Turbogears 1.0.5 on Windows and Macosx.
>
> Ok, here are my Question:
>
> I have to make a Users edit form with checkboxtable selection for
> Groups (Turbogears Identity). For that Form i have a field groups =
> CheckBoxTable(label_text='Gruppen:', options = getGroupOptions,
> template="myproject.admin.templates.checkboxtable", validator=Int(),
> num_cols=3, css_class="checkbox_table")
>
> The getGroupOptions look like this.
>
> def getGroupOptions():
> options = []
> gps = [g for g in session.query(Group)]
> return gps
>
> Now i adaptet in the checkboxtable value="${value}" to
> value="${value.group_id}" and py:content="desc" to
> py:content="desc.display_name". That works great for me.
> But is there a way to say outside from template what value from the
> groups object should displayed? I don't like to create custom
> templates if its not realy necessary.
>
> I thougth there whould be a way with lambda but i can't find the solution.
The RelatedFetcher validator in this recipe should do it:
http://toscawidgets.org/trac/tw.forms/wiki/FAQ#how-can-i-populate-a-singleselectfield-with-an-sqlalchemy-mapped-instance
Alberto
RelatedFetcher is a custom validator. You had the source right beneath
your eyes in the recipe I pointed you at ;)
Alberto
Oops, sorry, I spoke too fast. Ignore my previous tongue-in-cheek reply
please... :-ł
The problem I think is due to the _ translation function which FE
doens't like to be a lazystring. Do this before declaring the validator
(or remove the _ completely):
_ = lambda s: s
Translation should still work since FE filters all messages through a
translation function if it is provided to it.
Alberto