Hi Jim.

I've tried your advice in using ",".join(i.groups) and it fits fine my
needs.
I also consider using a database field per group entry, as you said. But I
need to see the cost (to me) of using this approach.
So, thanks a lot for sharing your knowledge.


--
Tomás Schertel
----------------------------------------------
Linux Registered User #304838
Arch Linux User
http://www.archlinux-br.org/
----------------------------------------------


On Mon, Oct 24, 2011 at 14:10, Tomás Acauan Schertel <[email protected]>wrote:

> Thanks for your reply Jim. I'l play with these option you gave.
>
>
>
> --
> Tomás Schertel
> ----------------------------------------------
> Linux Registered User #304838
> Arch Linux User
> http://www.archlinux-br.org/
> ----------------------------------------------
>
>
> On Mon, Oct 24, 2011 at 08:09, Bikes At Work Inc <[email protected]>wrote:
>
>> In the example you cite, the values for the field are joined together
>> in a string because it is a list.
>>
>> Try this:
>>
>> GET(self):
>>        return '''
>>        <form method="post" action="">
>>        <input name=name type=text value=''>
>>        <input name=email type=text value=>
>>         <input type="checkbox" name="groups"
>> value="administradores"/>Administradores<br />
>>        <input type="checkbox" name="groups" value="operadores"
>> />Operadores<br />
>>        <input type="checkbox" name="groups"
>> value="usuarios"/>Usu&aacute;rios<br />
>>         <input type=submit value=submit>
>>        </form>
>>        '''
>>
>> POST(self):
>>    def POST(self):
>>        i = web.input(groups=[])
>>        return "name = " + i.name + ";  email = " +  i. email + ";
>> groups = " + ",".join(i.groups)
>>
>> Play with it and see what values your form returns.  You will find it
>> returns a list.  How will you store that list in your database?  What
>> is the schema for your table?  You haveI think  three options: 1)
>> concatenate the list values and store the result in one field
>> (probably not what you want to do)  2) have a field for each checkbox
>> and store "true" or "false" for each one, or 3) store the value of the
>> checkbox in a single field, and store one record for every checkbox
>> that is checked.
>>
>> -Jim
>>
>> On Sun, Oct 23, 2011 at 8:30 AM, Tomás Acauan Schertel
>> <[email protected]> wrote:
>> > Hi Jim. Thanks for your reply.
>> > I understand when you say about saving a list to just one field.
>> > But documentation don't say anything about iterating data from
>> multi-values
>> > fields.
>> > Take a look at http://webpy.org/cookbook/input and tell me what you
>> > understand about this.
>> >
>> > My database schema for this field is char(100).
>> >
>> >
>> > --
>> > Tomás Schertel
>> > ----------------------------------------------
>> > Linux Registered User #304838
>> > Arch Linux User
>> > http://www.archlinux-br.org/
>> > ----------------------------------------------
>> >
>> >
>> > On Sun, Oct 23, 2011 at 10:04, Bikes At Work Inc <[email protected]
>> >
>> > wrote:
>> >>
>> >> Google didn't preserve my tabs as spaces, so the indents were off :(
>> >> Let.s try that again:
>> >>
>> >> def POST(self):
>> >>    i = web.input(groups = [])
>> >>    for checkbox in i.groups:
>> >>        db.insert("users", email = i.email, name = i.name, groups =
>> >> checkbox)
>> >>
>> >> or
>> >>
>> >> def POST(self):
>> >>    i = web.input(groups = [])
>> >>    for checkbox in i.groups:
>> >>        if checkbox:
>> >>        db.insert("users", email = i.email, name = i.name,
>> >>                                        groups = checkbox)
>> >> -Jim
>> >> :x
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "web.py" 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/webpy?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "web.py" 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/webpy?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "web.py" 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/webpy?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to