Now I made some changes, and the creation form of "people" model can
display successfully, plus showing up "group" model opetions normally

def getGroups():
    groups=[]
    for group in session.query(Group):
        groups.append([group.name, group.id])


group = widgets.SingleSelectField(name="group_id", options=getGroups,
label="Group")


now the "save" method in "people" model looks like this:

def save(self, id=None, **kw):
            agroup =
session.query(Group).filter_by(name=kw['group_id'])
           kw['group_id'] = agroup.id
            session.save(People(**kw))
           session.flush()
            raise redirect("list")

How can I bind the group.id with kw['group_id'] correctly?

Thanks in advance

On Nov 3, 6:58 pm, PigletWatcher <[EMAIL PROTECTED]> wrote:
> In the "people" controller(people.py), i defined a field named
> "group", which is used to display the options of "groups".
>
> My idea is this field would display all "name" field of group with the
> value of "id". It picks up "id" value when i'm attempting to create a
> new "people" model in its creation form.
>
> But it failed, anybody can give me guidelines how to implement this ?
>
> def getGroups():
>     groups=[]
>     for group in session.query(Group):
>         groups.append([group.id,group.name])
>
> group = widgets.SingleSelectField(name="group_id", options=getGroups,
> label="Group")
>
> Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to