Re: [web2py] setting db table for SQLFORM from an argument

2011-11-21 Thread monotasker
db[the_table] works! Thanks Bruno.


Re: [web2py] setting db table for SQLFORM from an argument

2011-11-21 Thread Bruno Rocha
try

db[the_table]

http://zerp.ly/rochacbruno
Em 22/11/2011 00:49, "monotasker"  escreveu:

> I'm trying to abstract several content creation controllers into one
> controller. I want to use request.args[0] to set the db table in which the
> new row will be created. So far I've got this:
>
> def add():
> the_table = request.args[0]
> tb = "db.%s" % the_table
> form = SQLFORM(tb)
>
> but I'm getting an error that "str object does not have the attribute
> 'writeable'". It seems like SQLFORM is treating 'tb' as a string object
> rather than taking the string's content as an argument. Am I missing
> something? Is there a better way to do this?
>
> Thanks,
>
> Ian
>


[web2py] setting db table for SQLFORM from an argument

2011-11-21 Thread monotasker
I'm trying to abstract several content creation controllers into one 
controller. I want to use request.args[0] to set the db table in which the 
new row will be created. So far I've got this:

def add():
the_table = request.args[0]
tb = "db.%s" % the_table
form = SQLFORM(tb)

but I'm getting an error that "str object does not have the attribute 
'writeable'". It seems like SQLFORM is treating 'tb' as a string object 
rather than taking the string's content as an argument. Am I missing 
something? Is there a better way to do this?

Thanks,

Ian