#858: [PATCH] so_to_dict function to support joins
----------------------------------+-----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 0.9a5
Severity: normal | Keywords: so_to_dict, joins
----------------------------------+-----------------------------------------
TextField automatically fills itself when form is to be displayed. The
data to fill the form is given by dictionary created from SQLObject class
using function so_to_dict(). When we need to automatically select items
within MultipleSelectField according data from join, we need to patch
function so_to_dict() to return dictionary containing also joins (not
columns only).
Example:
{{{
MODEL:
class Genre(SQLObject):
titles = RelatedJoin('Title')
class Title(SQLObject):
genres = RelatedJoin('Genre')
FORM:
def get_all_genres():
return [(int(a.id), "%s" % a.name) for a in Genre.select()]
class TitleFields(WidgetsList):
genres = MultipleSelectField(name='genres',
options=get_all_genres, validator=Int())
class TitleForm(TableForm):
fields = TitleFields()
TEMPLATE:
${form.display(obj, action=action)}
HANDLER:
class TitleCont(BaseDataController):
form_widget = TitleForm()
@expose(template="plend.templates.form")
def edit(self, obj):
value = so_to_dict(obj)
return dict(form=self.form_widget, obj=value, action="save")
}}}
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/858>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---