1)
def mycopy(table,id):
records=table._db(table.id==id).select()
if not records: return False
table.insert(**dict([(x,records[0][x]) for x in table.fields if
not x=='id']))
return True
use it as in mycopy(db.puppy,3)
2) this is very much open ended. For example you can do in a view
<button onclick="popup('{{=URL(r=request,f='edit',args=
['table','field','id'])}})">click me</button>
replace table, field, id with values.
and a controller like:
@t2.requires_login()
def edit():
table,field,id=request.args[0],request.args[1],request.args[2]
form=SQLFORM(db[table],db(db[table].id==id).select()[0],fields=
[field])
if form.accept(request.vars,session): return HTML(BODY(SCRIPT
('window.close()')))
return HTML(BODY(form))
Massimo
On Dec 28, 6:36 am, notabene <[email protected]> wrote:
> I need 2 patterns - and I believe they would be usefull in general:
> - t2.copy to supplement insert, update, delete.
> - a popup page - attached by an edit or search button to a field -
> which can be customized to supply the field-content.
>
> I am not that experienced in web2py and python, and would appreciate
> help from the community (/massimo?)
>
> Regards
>
> Niels Bjerre
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---