So if I wanted to copy tables over, but set unique=False....

I ended up with the following

audit_table = [copy.copy(f) for f in table]
        for i in range(len(audit_table)):
            audit_table[i].unique = False

db.define_table(table.table_name + '_auditlog', Audit.audit_template,
*audit_table)

-Thadeus





On Thu, Jan 28, 2010 at 5:52 PM, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Sometimes I think to myself and say, "Why didn't I just try that!"
>
> Thank you, both of you!
>
> -Thadeus
>
>
>
>
>
> On Thu, Jan 28, 2010 at 4:27 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> Or
>>
>> db.define_table('newname',db.othertable)
>>
>> On Jan 28, 4:19 pm, DenesL <denes1...@yahoo.ca> wrote:
>>> db.define_table('newname',*[f for f in db.table])
>>>
>>> On Jan 28, 2:20 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>>>
>>> > Is there a way to iterate through the Field() elements of a table and
>>> > use them to create another similar table ?
>>>
>>> > I'm looking for something like
>>>
>>> > db.define_table('hi', Field('hello'), Field('world'))
>>>
>>> > class Foo()
>>> >    def init(atable):
>>> >       for field in atable:
>>> >          db.define_table(tablename + '_mod', field, field, field,
>>> > Field('bar', 'datetime'))
>>>
>>> > So I would end up with
>>>
>>> > db.hi and db.hi_mod.
>>>
>>> > -Thadeus
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To post to this group, send email to web...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/web2py?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to