No need. It is a book issue. I will take care of it. On Monday, 25 February 2013 23:49:48 UTC-6, Toby Wilson wrote: > > Thanks Massimo. > > > > Is the second point regarding the shell I raise a known issue as well? > > > > > > > > > > *From:* [email protected] <javascript:> [mailto: > [email protected] <javascript:>] *On Behalf Of *Massimo Di Pierro > *Sent:* Tuesday, 26 February 2013 4:36 PM > *To:* [email protected] <javascript:> > *Subject:* [web2py] Re: Many to many relationships > > > > we need to che change the book. "owner" is a keyword in postgresql. When > we wrote the 4th edition of the book, web2py was not checking by default. > recent versions of web2py are checking. > > > > On Monday, 25 February 2013 17:02:09 UTC-6, Toby Wilson wrote: > > Thanks Cliff and Niphlod... appreciate your assistance. > > I'll go through the book a little slower and get clear on this. > > In the book it shows an example using the word "owner". When I copy and > paste this in, I can't access the database administration option as I get > an internal error with the message in the ticket stating: > <type 'exceptions.SyntaxError'> invalid table/column name "owner" is a > "ALL" reserved SQL keyword > > > Anyway, so I just changed it to "owne" instead and it all works. > > Another thing, while going through the steps outlined in the book, I've > been using the shell in Controllers. I type a line, for example: > > db.thing.insert(name='Chair', owne=1) > > > and press enter and nothing happens. Then I'll type it again and hit enter > and it outputs: > > In [11] : db.thing.insert(name='Chair', owne=1) > 4 > > Showing that it worked. As I keep doing this and even change what I type > in, it only works every second time. One time I hit enter and nothing > happens, then after typing I hit enter and it seems to work. > > Am I doing something wrong or is this a bug in web2py or in my > installation perhaps? > > Toby > > On Monday, 25 February 2013 18:24:48 UTC+11, Toby Wilson wrote: > > > > Hi all, > > New to web development and web2py. Know a bit of Python. > > As a learning experience I’ve written a food tracking program that works > really well in Python and it just runs on my local PC. It just reads and > writes values into text files. > > Now I’m trying to transfer that into web2py as a next step learning > experience. I’m trying to figure out the database side of it (models). > > It seems what I’m dealing with is many-to-many relationships. I have a > list of meals and each meal has a list of associated ingredients. So one > ingredient can be in many meal and each meal has many ingredients. > > So essentially, what the program I've written can do is add 3 x “Meal 1” > to the quantity existing in the database for “Meal 1” and then after doing > that prompt the user with: > > “Do you want this to impact the level of the ingredient ‘carrot’?” Y/N > > And then: > > “Do you want this to impact the level of the ingredient ‘steak’? Y/N > > etc. > > And the program knows that “Meal 1” needs 3 carrots, so upon entering “Y” > to the first question, 3 carrots are automatically subtracted from the > stock level of carrots in the database. > > So as meals are added, the user is prompted with associated ingredients > and can choose to update or not update the level of that associated > ingredient. > > In the local Python program I’ve written, all of this is just done through > listing things in dictionaries and using functions to manipulate the data > and then read and write to text files. Now I want to use database tables > and I’m not sure how much of the association should be in the model and how > much (if any) should be in the controller (for example in the form of a > dictionary). > > I’ve read through the documentation on many to many relationships but > haven’t got a full grasp of it yet. > > I’ve coded a few different database structures but haven’t managed to get > it right yet. > > The way I've been thinking about it is, a table for meals, a table for > ingredients, and perhaps a table for associations? I've used "reference" to > get the drop down box associated, but I can't select more than ingredient. > I had a look at the Django admin login and it visually made this look a bit > easier - i.e. building the one to many relationship. How is this done in > web2py? > > Any help or advice would be much appreciated. > > Toby > > P.S. If I have a database file in web2py and open the file through the > web2py IDE and replace the contents with a totally different database > structure and save it, what happens? Does web2py just remove what was there > in the database and replace the database tables with the new ones or does > it manage it in a different way (i.e. only add new elements etc.)? > > > > -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/groups/opt_out. > > > > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2013.0.2899 / Virus Database: 2639/6113 - Release Date: 02/18/13 > Internal Virus Database is out of date. >
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

