This something I would definitely be interested in seeing, as well as input forms for many-to-many in general (not just admin).
Thanks Vincent On Dec 23, 12:50 pm, Anthony <abasta...@gmail.com> wrote: > web2py wraps each request in a single transaction by default, so if you > make multiple inserts during a request and the request ultimately fails due > to an error, the inserts should be rolled back automatically. > Seehttp://web2py.com/books/default/chapter/29/4#Workflow > andhttp://web2py.com/books/default/chapter/29/6#commit-and-rollback. > > Anthony > > > > > > > > On Friday, December 23, 2011 1:22:34 PM UTC-5, Detectedstealth wrote: > > > I have solved these kinds of concerns with pyramid based applications > > using sqlalchemy. However I need to look into the core of how Web2py > > handles things to figure out the best way. > > > Sqlachemy allows you to put everything in: > > 1) Transactions > > 2) Sessions > > > So on submit you first create the parent record: > > ad = Ad(....) > > session.add(ad) > > session.flush() > > > Now you have access to ad.id (parent id) > > > report = Report(...) > > report.ad_id = ad.id > > session.add(report) > > > Now if you used Sqlachemy relationships > > ad.reports.append(report) # use this instead of report.ad_id = ad.id > > session.flush() > > > Or in the case of having multiple children created before creating the > > parent on a web form. You just submit all the form data at once and loop > > through all reports. > > > ad = Ad(...) > > session.add(ad) > > session.flush() > > > get list of all reports in form submit > > for report in reports: > > session.add(report) > > ad.reports.append(report) > > session.flush() > > > If anything fails the transaction automatically roles everything back. > > > Or a easier solution is to only enable the children on edits. So you first > > create the parent, then you can view/edit/delete children on the parent > > edit page. > > > -- > > Regards, > > Bruce > > > On Fri, Dec 23, 2011 at 10:00 AM, Cliff <cjk...@gmail.com> wrote: > > >> Bruce, you are more brave than me ;) > > >> I always like to get the parent record committed in the database > >> before adding child records. > > >> that way you know the ID of the parent record and it has the minimal > >> required fieldset safely saved away. If there's a session > >> interruption you don't have some potential orphan child records > >> floating around somewhere. > > >> If you've solved those kinds of concerns, please share it with us. > > >> Thanks, > >> Cliff Kachinske > > >> On Dec 23, 10:34 am, DenesL <dene...@yahoo.ca> wrote: > >> > On Dec 23, 10:11 am, Bruce Wade <bruce...@gmail.com> wrote: > > >> > > Anyway which files should I start looking at to see how I can > >> implement > >> > > this functionality for myself and anyone else who wants it? > > >> > Look for controller appadmin under your or any other app folder. > > > -- > > -- > > Regards, > > Bruce Wade > >http://ca.linkedin.com/in/brucelwade > >http://www.wadecybertech.com > >http://www.warplydesigned.com > >http://www.fitnessfriendsfinder.com