I think you need something like this... db.define_table('project',SQLField('name'),...other fields...) db.define_table('projectfile',SQLField ('project_id',db.project),....other fields...) db.projectfile.project_id.requires=IS_IN_DB(db,'project.id','%(name) s') db.projectfile.project_id.represent=lambda id: db.project[id].name
when you create a projectfile use form=crud.create(db.projectfile) or db.projectfile.project_id.writable=False db.projectfile.project_id.default=... the id of the project you are in ... form=crud.create(db.projectfile) and when you delete a project by id: db(db.projectfile.project.id==id).delete() # delete files db(db.project.id==id).delete() # and delete the project Hope this makes sense. Massimo On Jun 15, 5:24 am, pk <peter.kirch...@youngdesigners.de> wrote: > i think i have an idea massimo which can possible solve my problem > but you have to help me. > > how can i save the project.id in the projectfile table. > > the user can choose a self created project over a form and i like > to save automaticly the project.id in the table projectfile. > > how can i do this? > > peter > > On 15 Jun., 11:49, pk <peter.kirch...@youngdesigners.de> wrote: > > > the reference should be the name of the project, projectname > > thanks > > peter > > > On 15 Jun., 02:40, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > That is what I thought but I do not see in "projectfile" any reference > > > field to "project". > > > > On Jun 14, 4:47 pm, pk <peter.kirch...@youngdesigners.de> wrote: > > > > > a projectfile should reference a project, but a project can have many > > > > projectfiles > > > > > On 14 Jun., 23:37, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > shouldn't there be a file in projectfile that references a project? Or > > > > > can a projectfile belong to multiple projects? > > > > > > On Jun 14, 4:13 pm, pk <peter.kirch...@youngdesigners.de> wrote: > > > > > > > yeah, > > > > > > sorry i think i pressed my self not good enough, when youser delete > > > > > > a > > > > > > project from the table project > > > > > > then i need a command to delete the accordant file record from the > > > > > > table file > > > > > > > thanks > > > > > > > On 14 Jun., 23:02, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > this has been default behavior for some time. Have you checked it? > > > > > > > Does it not work? > > > > > > > > Massimo > > > > > > > > On Jun 14, 11:50 am, pk <peter.kirch...@youngdesigners.de> wrote: > > > > > > > > > Hi together, > > > > > > > > > i have a question. i have a talbe project and there i can delete > > > > > > > > without any problems. > > > > > > > > i have another table calls projectfile. here is my model: > > > > > > > > > ######################################################################### > > > > > > > > ## Tabelle File > > > > > > > > ######################################################################### > > > > > > > > db.define_table('projectfile', > > > > > > > > SQLField('userid', default=auth.user.id if > > > > > > > > auth.user > > > > > > > > else 0, writable=False, readable=False), > > > > > > > > SQLField('procreator', > > > > > > > > default=auth.user.last_name if > > > > > > > > auth.user else 0, writable=False, readable=False), > > > > > > > > SQLField('projectname'), > > > > > > > > SQLField('filename'), > > > > > > > > SQLField('format'), > > > > > > > > SQLField('cdate', 'date', default=now), > > > > > > > > SQLField('datei','upload'), > > > > > > > > SQLField('description','text')) > > > > > > > > > if auth.is_logged_in(): > > > > > > > > db.projectfile.projectname.requires=IS_IN_DB(db > > > > > > > > (db.project.userid==auth.user.id),'project.pname','%(pname)s') > > > > > > > > db.projectfile.procreator.requires=IS_IN_DB(db,'auth_user.last_name') > > > > > > > > db.projectfile.userid.requires=IS_IN_DB(db,'auth_user.id') > > > > > > > > db.projectfile.filename.requires=[IS_NOT_EMPTY()] > > > > > > > > db.projectfile.format.requires=[IS_NOT_EMPTY()] > > > > > > > > db.projectfile.cdate.requires=[IS_NOT_EMPTY(), IS_DATE()] > > > > > > > > db.projectfile.datei.requires=IS_NOT_EMPTY() > > > > > > > > > how can i now delete automaticly the file which belong to the > > > > > > > > project. > > > > > > > > > here my def: > > > > > > > > > def deletepro(): > > > > > > > > if auth.is_logged_in(): > > > > > > > > db(db.project.id==request.args[0]).delete() > > > > > > > > redirect(URL(r=request, f='project')) > > > > > > > > redirect(URL(r=request,c='default/user',f='login')) > > > > > > > > > thanks for your help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@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 -~----------~----~----~----~------~----~------~--~---