[web2py] Re: Many to many to many?

2015-08-23 Thread Gael Princivalle
Thank you Massimo that works perfectly. Il giorno domenica 23 agosto 2015 02:16:04 UTC+2, Massimo Di Pierro ha scritto: > > Should'd that be > > override_code = override[k].ceo_schemes_and_overrides_and_override_codes. > override_code.code1 > > anyway this should be faster (no nested queries) > >

Re: [web2py] Re: many to many fields representation

2015-08-23 Thread Itamar Cohen
Thanks for the info. Best Regards Itamar Cohen Picatek Ahornvej 27 DK-7700 Thisted Denmark www.picatek.dk i...@picatek.dk T: +45 97 91 07 82 M:+45 29 89 07 82 On 22 August 2015 at 20:19, Anthony wrote: > Yes, I forgot to mention, the dropdowns in the forms are based in the > IS_IN_DB validator

[web2py] Re: Many to many to many?

2015-08-22 Thread Massimo Di Pierro
Should'd that be override_code = override[k].ceo_schemes_and_overrides_and_override_codes. override_code.code1 anyway this should be faster (no nested queries) override = db((db.ceo_schemes_and_overrides_and_override_codes.ceo_scheme == ceo_scheme.id) & (db.ceo_schemes_and_overrides_and_overrid

Re: [web2py] Re: many to many fields representation

2015-08-22 Thread Anthony
Yes, I forgot to mention, the dropdowns in the forms are based in the IS_IN_DB validator attached to each field. So, you will also have to overwrite the "requires" attribute of these two fields with a custom IS_IN_BD validator. Anthony -- Resources: - http://web2py.com - http://web2py.com/book

Re: [web2py] Re: many to many fields representation

2015-08-22 Thread Itamar Cohen
Thanks Anthony, It works (both solutions) in the grid but not in the edit/new forms you get when clicking on the auth_memebership link in the grid (the id still appended to the name/role. May be it is OK as you mentioned regarding uniqueness. Best Regards Itamar Cohen Picatek Ahornvej 27 DK-7700 T

[web2py] Re: many to many fields representation

2015-08-22 Thread Anthony
By default, the "represent" attribute of a reference field is based on the "format" attribute of the table it references. So, you have two options -- you could either change the "format" attributes of the auth_user and auth_group tables: db.auth_user._format = '%(first_name)s %(last_name)s' #

Re: [web2py] Re: many to many with SQLFORM.grid

2015-06-01 Thread Ben Lawrence
Thanks, so the use of field_id is important! I tried your first test which can be written with the proper field_id *m.id.* This Works: > def test1(): id_company = 1 m, cm = db.meeting, db.co_meet q = cm.ref_company == id_company q = q & (m.id == cm.ref_meeting) grid = SQLFORM

Re: [web2py] Re: many to many with SQLFORM.grid

2015-05-31 Thread Massimiliano
Sorry. What I wrote is wrong. Try this ways: def test1(): id_company = 1 m, cm = db.meeting, db.co_meet cm.ref_company.default = id_company cm.ref_company.readable = cm.ref_company.writable = False cm.ref_meeting.requires = IS_IN_DB(db, m.id ,'%(title)s') q = cm.ref_co

Re: [web2py] Re: many to many with SQLFORM.grid

2015-05-31 Thread Massimiliano
m, cm = db.meeting, db.co_meet q = m.id == cm.ref_meeting q = q & (cm.ref_company == 1) grid = SQLFORM.grid(q, field_id=m.id, fields=[m.id, m.title]) On Sun, May 31, 2015 at 4:48 AM, Ben Lawrence wrote: > Both of your answers give a grid of co_meet. > > What would the query be i

[web2py] Re: many to many with SQLFORM.grid

2015-05-30 Thread Ben Lawrence
Both of your answers give a grid of co_meet. What would the query be in SQLFORM.grid such that it would be a grid of db.meeting for one company (not db.co_meet)? On Thursday, May 7, 2015 at 8:26:47 PM UTC-7, 黄祥 wrote: > > had you tried it? > another work around is u can use smartgrid constraint

[web2py] Re: many to many with SQLFORM.grid

2015-05-07 Thread 黄祥
had you tried it? another work around is u can use smartgrid constraints e.g. def test(): table = db.co_meet query = db.co_meet.ref_company == 1 # whatever value that refer to table company grid = SQLFORM.smartgrid(table, constraints = dict(co_meet=query) ) return locals() best reg

[web2py] Re: many to many with SQLFORM.grid

2015-05-07 Thread Ben Lawrence
Thanks! But wouldn't that just give me a grid of 'co_meet' and not 'meeting'? On Monday, May 4, 2015 at 9:20:01 AM UTC-7, 黄祥 wrote: > > perhaps, you can do > e.g. > def test(): > query = db.co_meet.ref_company == 1 # whatever value that refer to > table company > grid=SQLFORM.grid(quer

[web2py] Re: many to many with SQLFORM.grid

2015-05-04 Thread 黄祥
perhaps, you can do e.g. def test(): query = db.co_meet.ref_company == 1 # whatever value that refer to table company grid=SQLFORM.grid(query) return locals() best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/

[web2py] Re: Many to many

2013-10-31 Thread Gael Princivalle
Thanks a lot Anthony. Now it works. Il giorno giovedì 31 ottobre 2013 00:12:43 UTC+1, Anthony ha scritto: > > > {{for company_image in company_images.select():}} >> > > You've already done a select, so don't call .select() again. > > >> {{for company_image in company_ima

[web2py] Re: Many to many

2013-10-30 Thread Anthony
> {{for company_image in company_images.select():}} > You've already done a select, so don't call .select() again. > {{for company_image in company_images:}} > {{=A(IMG(_src=URL('download', > args=company_image.image_file_s)), _href=URL('download', > arg

[web2py] Re: Many to many

2013-10-30 Thread Gael Princivalle
Hi Anthony. This is discussed here: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Many-to-many I've read it before posting. Result was the same as with the code you've post: 'Rows' object has no attribute 'select' Now I've update my db as you've suggest: db.d

[web2py] Re: Many to many

2013-10-30 Thread Anthony
Also, you might consider shortening the name of db.int_table_galleries_images to just db.galleries_images? You already know it's a table, so no need for "table" in the name, and "galleries_images" already implies it's a many-to-many intermediate table. Anthony On Wednesday, October 30, 2013 8:

[web2py] Re: Many to many

2013-10-30 Thread Anthony
This is discussed here: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Many-to-many db((db.images.id == db.int_table_galleries_images.image) & (db.galleries.id == db.int_table_galleries_images.gallery) & (db.galleries.id == 1)).select() Anthony On Wednesday,

[web2py] Re: Many to many

2013-10-30 Thread Gael Princivalle
Thanks Andreas. Sorry I've made a mistake. "Now in the company page, I want to show only images from the "1" gallery." With "images = db(db.int_table_galleries_images.gallery.id==1).select()" I'm still having all images, also from gallery.id==2. I've also tried with "images = db(db.int_table_g

[web2py] Re: Many to many

2013-10-30 Thread Andreas Wienes
I'm not sure if I understand you right. What do you mean with "category"? Maybe you could try this to get all images with a specific gallery-id: images = db(db.int_table_galleries_images.gallery.id==1).select() return dict(images=images) - Andreas Am Mittwoch, 30. Oktober 2013 11:51:19 UTC+1 s

[web2py] Re: Many to many skills matrix

2013-06-15 Thread villas
As Alan says, you don't seem to have a score field. Maybe try this: db.define_table('online_team', Field('first_name', notnull=True), Field('last_name', notnull=True), Field('email', requires=IS_EMAIL(), notnull=True, unique=True), Field('initials', notnull=True, unique=True))

[web2py] Re: Many to many skills matrix

2013-06-15 Thread Alan Etkin
> I have a group of employees and a set of skills. One employee can have > many skills and one skill can be had by many employees. What I want to do > is to represent the skills of all employees in one table, where the score > of each employee in each skill is given on a scale from 0 to 5 lik

Re: [web2py] Re: Many to many relationships

2013-02-26 Thread Massimo Di Pierro
*From:* web...@googlegroups.com [mailto: > web...@googlegroups.com ] *On Behalf Of *Massimo Di Pierro > *Sent:* Tuesday, 26 February 2013 4:36 PM > *To:* web...@googlegroups.com > *Subject:* [web2py] Re: Many to many relationships > > > > we need to che change the book. &qu

RE: [web2py] Re: Many to many relationships

2013-02-25 Thread Toby Wilson
Thanks Massimo. Is the second point regarding the shell I raise a known issue as well? From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of Massimo Di Pierro Sent: Tuesday, 26 February 2013 4:36 PM To: web2py@googlegroups.com Subject: [web2py] Re: Many to

[web2py] Re: Many to many relationships

2013-02-25 Thread Massimo Di Pierro
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 yo

[web2py] Re: Many to many relationships

2013-02-25 Thread Toby Wilson
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 me

[web2py] Re: Many to many relationships

2013-02-25 Thread Cliff Kachinske
Toby, The online Web2py manual explains how to set up many-to-many relationships. If this is new to you, start reading about one-to-many relationships and continue from there. http://web2py.com/books/default/chapter/29/06#One-to-many-relation On Monday, February 25, 2013 2:24:48 AM UTC-5, T

[web2py] Re: Many to many relationships

2013-02-25 Thread Niphlod
On Monday, February 25, 2013 8:24:48 AM UTC+1, 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 >

[web2py] Re: Many to Many?

2012-03-12 Thread Derek
I think your idea will work, that sounds the best. On Friday, March 9, 2012 5:21:33 AM UTC-7, Wikus van de Merwe wrote: > > What pbreit suggested assumes that all the company servers are at the same > location as the company, which I guess is not what you wanted. > It think it should rather be:

[web2py] Re: Many to Many?

2012-03-09 Thread Wikus van de Merwe
What pbreit suggested assumes that all the company servers are at the same location as the company, which I guess is not what you wanted. It think it should rather be: db.define_table('company', Field('name'), Field('location', db.location)) db.define_table('server', Field('name'),

[web2py] Re: Many to Many?

2012-03-08 Thread lyn2py
Nope, your way is the better way :) On Friday, March 9, 2012 8:14:57 AM UTC+8, Derek wrote: > > Let's say I am designing a database. > > It has these elements: > Companies, Locations, Servers > > Each company has one location, and one or more servers. > Each server has one and only one location. >

[web2py] Re: Many to Many?

2012-03-08 Thread pbreit
I don't really understand the question but I would think something like this: db.define_table('company', Field('name')) db.define_table('server', Field('name'), Field('company', db.company), Field('location', db.location)) db.define_table('location', Field('name')) Or since

[web2py] Re: Many-to-many relations with CRUD Insert

2012-01-17 Thread Christian Winterhager
Anthony, the basic recommendation was to use SQLFORM.factory, and that was a good idea. I tried it again and i had now more success than some weeks before. So now i can insert rows in the table "book" and the table "verb" in one FORM and with only one submit-button. The FORM looks like this: fo

[web2py] Re: Many-to-many relations with CRUD Insert

2012-01-17 Thread Christian Winterhager
Antony, thank you, i tried exactly this some weeks ago and it did not work. Since now... may be, that i worked not enough. I will try more and we will see.

[web2py] Re: Many-to-many relations with CRUD Insert

2012-01-17 Thread Anthony
This might give you some ideas: http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables. I suppose you would have to loop through the list of submitted authors to insert multiple records into the "verb" table. Anthony On Monday, January 16, 2012 3:35:16 PM UTC-5, Christian W

Re: [web2py] Re: Many-to-many admin form

2011-12-28 Thread Bruce Wade
OK thanks, I will take a look through the resources you have provided. -- Regards, Bruce On Wed, Dec 28, 2011 at 12:35 PM, Christopher Steel wrote: > OK, > > Here are some resources you will want to check out if you have not found > them on your own already. > > # Web2py Plugins > ## http://web2

[web2py] Re: Many-to-many admin form

2011-12-28 Thread Christopher Steel
OK, Here are some resources you will want to check out if you have not found them on your own already. # Web2py Plugins ## http://web2py.com/plugins/default ### looks good http://web2py.com/plugins/default/tagging ### interesting http://web2py.com/plugins/default/multiselect http://web2py.com/

Re: [web2py] Re: Many-to-many admin form

2011-12-25 Thread Bruce Wade
Hi Christopher, * * *That is pretty much what I am after.* * * *table = keywords values ('Art', 'Games', 'Money') # Used to find all ads related based on keywords they select* *table = ad (* * url,* * created_by* * keywords - can have 0 or more keywords, keywords can belong to 0 or more ad's* *)

Re: [web2py] Re: Many-to-many admin form

2011-12-25 Thread Christopher Steel
I think what you mean to say is that you are are looking for the ability to make multiple selections in one or more tables using a single form that allows you create a user record. So for example a table of users, a table of email address types and a table of email addresses but the user on se

[web2py] Re: Many-to-many admin form

2011-12-25 Thread Cliff
>> That example doesn't look like a true many-to-many it looks like a >> one-to-many. Because in the example it searches for both id's already being >> in the many-to-many table and if they are it only updates. Where as a true >> many to many you would have multiple entries IE: (1, 1, 20), (1, 1, 4

Re: [web2py] Re: Many-to-many admin form

2011-12-25 Thread Christopher Steel
OK, If your database table is setup correctly then in the database examples section you should be able to create a form similar to the one in example 33 for a many to many relationship. http://web2py.com/examples/database_examples/buy ( http://web2py.com/examples/default/examples#database_exampl

Re: [web2py] Re: Many-to-many admin form

2011-12-24 Thread Bruce Wade
I looked at the examples they seem to just show how to link at the database level. From my example code I already have that part working. It is at the form/view level I am looking at adding functionality. On Sat, Dec 24, 2011 at 9:41 AM, Christopher Steel wrote: > For an example of a Web2py datab

[web2py] Re: Many-to-many admin form

2011-12-24 Thread Christopher Steel
For an example of a Web2py database with a many to many relationship you can see example number 29 under the database examples section: http://web2py.com/examples/default/examples Go to the section called Database Examples See the first example

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Vincent
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 wrote: > web2py wraps each request in a single transaction by default, so if you > make multiple inserts during a request an

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Anthony
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. See http://web2py.com/books/default/chapter/29/4#Workflow and http://web2py.com/books

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
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 rec

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Cliff
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 poten

[web2py] Re: Many-to-many admin form

2011-12-23 Thread DenesL
On Dec 23, 10:11 am, Bruce Wade 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.

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
I understand that, but you can also use the database portion to create new data. That is mainly the part I am talking about. When clicking database then insert in a table, it would be nice if the relationships could be linked on that insert. This would make performing inserts more efficiently. An

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Alvaro Lizama Molina
The web2py admin works diferently to the django admin. The web2py admin is for install apps and manage instances. 2011/12/23 Bruce Wade > I am guessing from the lack of responses this is not possible with > Web2py's current admin? > > > On Wed, Dec 21, 2011 at 4:49 PM, Bruce Wade wrote: > >> H

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
I am guessing from the lack of responses this is not possible with Web2py's current admin? On Wed, Dec 21, 2011 at 4:49 PM, Bruce Wade wrote: > Hello, I know django has this ability so I am assuming web2py also does. > (Here is to hoping :D) > > First the models: > db.define_table('adreports', >

[web2py] Re: Many to many query with two left joins - how to do in Web2py?

2011-10-07 Thread Cliff
Grazie. This unlocks a door. I thought I had to repeat the call to left() same as the SQL. On Oct 6, 5:13 pm, Massimo Di Pierro wrote: > Here is your SQL: > > SELECT purchase_orders.issue_date, purchase_orders.number, > products.name > FROM purchase_orders LEFT JOIN  purchase_order_products ON

[web2py] Re: Many to many query with two left joins - how to do in Web2py?

2011-10-06 Thread Massimo Di Pierro
Here is your SQL: SELECT purchase_orders.issue_date, purchase_orders.number, products.name FROM purchase_orders LEFT JOIN purchase_order_products ON purchase_order_products.purchase_order_id = purchase_orders.id LEFT JOIN products ON purchase_order_products.product_id = products.id web2py-ese:

[web2py] Re: Many to many query with two left joins - how to do in Web2py?

2011-10-06 Thread Cliff
Actually 'name' comes from products. Maybe it would be clearer this way: SELECT purchase_orders.issue_date, purchase_orders.number, products.name FROM purchase_orders LEFT JOIN purchase_order_products ON purchase_order_products.purchase_order_id = purchase_orders.id LEFT JOIN products ON purcha

[web2py] Re: Many to many query with two left joins - how to do in Web2py?

2011-10-06 Thread Massimo Di Pierro
Why do you left join products if you do not select anything from it? On Oct 6, 7:40 am, Cliff wrote: > Here is the model, simplified: > > db.define_table('purchase_orders', >     Field('issue_date', 'date', >           comment = SPAN(a_comment, _style='color:orange;')), >     Field('number', leng

[web2py] Re: Many to Many on GAE

2010-12-13 Thread howesc
where and how are the pictures stores? will you be adding them to the blobstore or references pictures elsewhere?

[web2py] Re: Many to Many on GAE

2010-12-12 Thread Arun K.Rajeevan
Thank you for reply. My problem is, I have problem in choosing one approach over other. 1) Use a mapping table 2) Or use list reference. My tables are something like this: Table :Picture & Word Word: Coffee: Picture: Both the picture below represent word coffee. (ie., for one word many pictures)

[web2py] Re: Many to Many on GAE

2010-12-11 Thread howesc
Arun, this line: persons_and_dogs = db((db.person.id==db.ownership.person) & (db.dog.id==db.ownership.dog)) won't run on GAE because of the joins. You can choose to keep the data structure as you have it and run 2 queries and mesh the results. before the advent of list properties i was doing that

[web2py] Re: many to many inline form

2010-11-17 Thread Joe Wakefield
I'm still learning widget stuff, and while I can design a many-to-many widget, I am having trouble visualizing how to produce one with extra fields and buttons for adding/removing. I might strike an epiphany, but I'll likely just wait for you to make something available. On Nov 12, 11:27 am, mdipi

[web2py] Re: many to many inline form

2010-11-12 Thread mdipierro
We do not have a widget for that but it is time to make one. It is not difficult. If I have time I will do this over the week-end. Other users may have already something working. On Nov 12, 10:17 am, Joe Wakefield wrote: > So I'm trying to migrate an old rails app that broke a while back, and > I

[web2py] Re: many-to-many, use list:reference or separate table?

2010-11-09 Thread mdipierro
Speedwise, you should use many2many if you plan to search the referee by the refereed. If you only need the refereed after you already have the referee you can use list:reference. If you are on GAE list:reference is better because native and GAe has no joins. On Nov 9, 2:43 pm, Carlos wrote: > Hi

[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'

2010-09-29 Thread mdipierro
Models are executed alphabetically. Make sure that auth=Auth(...) auth.define_tables() are executed before your table definition. On Sep 29, 1:13 am, johntynan wrote: > Thank you for the suggestions, Massimo. > > I've tried to update the model here: > > http://code.google.com/p/publicradioroadt

[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'

2010-09-28 Thread johntynan
Thank you for the suggestions, Massimo. I've tried to update the model here: http://code.google.com/p/publicradioroadtrip/source/browse/models/db_custom.py based on your suggestions, and the example app here: http://www.web2py.com/book/default/chapter/03#A-Wiki However, if I use the line: Fie

[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'

2010-09-28 Thread mdipierro
just use auth.user_id is the same created_by should be type=db.auth_user On Sep 28, 10:31 pm, johntynan wrote: > if auth.is_logged_in(): >     me=auth.user.id > else: >     me=None > > On Sep 29, 5:19 am, mdipierro wrote: > > > what is me? Do you use auth? why the type of created_by is a stri

[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'

2010-09-28 Thread johntynan
if auth.is_logged_in(): me=auth.user.id else: me=None On Sep 29, 5:19 am, mdipierro wrote: > what is me? Do you use auth? why the type of created_by is a string? > > On Sep 28, 10:01 pm, johntynan wrote: > > > > > I would like to create a many-to-many relationship in the following > > mo

[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'

2010-09-28 Thread mdipierro
what is me? Do you use auth? why the type of created_by is a string? On Sep 28, 10:01 pm, johntynan wrote: > I would like to create a many-to-many relationship in the following > model, where many "stories" can appear in many different > "roadtrips" (think songs to mixtapes). > > db.define_table(

[web2py] Re: Many To Many Select

2010-06-29 Thread Al
Ah, belongs() + a clever select SQL. Thanks. Al On Jun 29, 7:04 pm, mdipierro wrote: > If I understand: > > for row in db(db.link_table.table1==r.id) > (db.table2.id==db.linked_table.table2).select(db.table2.id,db.table2.other)­: >     print row.id, row.other > > if no double links else > > sub=

[web2py] Re: Many To Many Select

2010-06-29 Thread mdipierro
If I understand: for row in db(db.link_table.table1==r.id) (db.table2.id==db.linked_table.table2).select(db.table2.id,db.table2.other): print row.id, row.other if no double links else sub=db(db.link_table.table1==r.id)._select(db.linked_table.table2) for row in db(db.table2.id.belongs(sub)).