Re: [web2py] IS_IN_DB() multiple tables

2015-05-25 Thread Richard Vézina
Thanks Anthony to clarify, now I understand... I never had such an issue I guess, I never thought the set were preventing the form submission... Let say that the IP address doesn't change, he could also have put the field in readable true and writable false... Richard On Wed, May 20, 2015 at 4:34

Re: [web2py] IS_IN_DB() multiple tables

2015-05-20 Thread Anthony
@Richard, the problem is that even when doing an update, the update will not be allowed because the validator will exclude IP addresses marked as being used (and the IP address of the current record will be marked as used). When doing an update, you need to conditionally change the validator to

Re: [web2py] IS_IN_DB() multiple tables

2015-05-20 Thread Richard Vézina
As I said, I don't understand your requirement... What you wrote seems ok (really quick looks), but I don't understand why you would need to do such a thing to get your field populated correctly... If you create a new record, you have to build a set that will allow to pick only the FREE IP address

Re: [web2py] IS_IN_DB() multiple tables

2015-05-19 Thread kecajkecaj123
Rich, Can You have a quick look at this? Thanks, On Tuesday, 12 May 2015 17:34:38 UTC+2, kecajk...@gmail.com wrote: > > Sure, it's pretty simple: > > DB: > > db.define_table('ipaddress', >Field('ip', unique=True, length=200,requires=IS_NOT_EMPTY()), >Field('status', length=200, defaul

Re: [web2py] IS_IN_DB() multiple tables

2015-05-12 Thread kecajkecaj123
Sure, it's pretty simple: DB: db.define_table('ipaddress', Field('ip', unique=True, length=200,requires=IS_NOT_EMPTY()), Field('status', length=200, default="Free", requires=IS_IN_SET(['Free','Used'])), format = '%(ip)s') db.define_table('server', Field('servername', length=200),

Re: [web2py] IS_IN_DB() multiple tables

2015-05-11 Thread Richard Vézina
Ok, so the problem is that when you edit your record the dropbox field shouldn't be blank... That is your issue, would you share the code of you form and grid and the exact validators... There shoud be something that don't work somewhere... And it you may start here : requires=IS_IN_DB(db(db.ipad

Re: [web2py] IS_IN_DB() multiple tables

2015-05-11 Thread 黄祥
why not use conditional requires base on url? e.g. if 'free' in request.controllers: On Monday, May 11, 2015 at 4:19:03 PM UTC+7, kecajk...@gmail.com wrote: > > Richard, > > Let say that I have two IPs in ipaddress table: > > 10.1.1.1 FREE > 10.2.2.2 FREE > > I add a server into server table, i

Re: [web2py] IS_IN_DB() multiple tables

2015-05-11 Thread kecajkecaj123
Richard, Let say that I have two IPs in ipaddress table: 10.1.1.1 FREE 10.2.2.2 FREE I add a server into server table, i put name as server1 and chose IP from dropdown menu 10.1.1.1. Then my ipaddress table looks like that 10.1.1.1 USED 10.2.2.2 FREE But i noticed that i did a typo in server

Re: [web2py] IS_IN_DB() multiple tables

2015-05-07 Thread Richard Vézina
Anthony, do you mean that the set can be define before ipaddress table get defines? On Thu, May 7, 2015 at 10:13 AM, Anthony wrote: > On Wednesday, May 6, 2015 at 10:52:05 AM UTC-4, Richard wrote: >> >> A set which you have, but your validator has wrong syntax : >> >> IS_IN_DB(db(db.ipaddress.st

Re: [web2py] IS_IN_DB() multiple tables

2015-05-07 Thread Anthony
On Wednesday, May 6, 2015 at 10:52:05 AM UTC-4, Richard wrote: > > A set which you have, but your validator has wrong syntax : > > IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, '%(ip)s') > > free_ip_set = db(db.ipaddress.status=='Free') > IS_IN_DB(free_ip_set, 'ipaddress.ip', '%(ip)s')

Re: [web2py] IS_IN_DB() multiple tables

2015-05-07 Thread Richard Vézina
Ok, I don't understand... Can you go back one step and explain what kind of information you want to manage and why you think you have to update the IP address... Is there multiple records with the same server name if so why... It seems to me that you want to manage kind of history of IP attached to

Re: [web2py] IS_IN_DB() multiple tables

2015-05-07 Thread kecajkecaj123
Hi, What's the difference between what i wrote and what You wrote? And i believe You didn't get my point. Checking if IP is Free works correctly. Point is that i want do update the one row in Server table and change i.e. server name. I click on update button provided by grid, and i can change

Re: [web2py] IS_IN_DB() multiple tables

2015-05-06 Thread Richard Vézina
A set which you have, but your validator has wrong syntax : IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, '%(ip)s') free_ip_set = db(db.ipaddress.status=='Free') IS_IN_DB(free_ip_set, 'ipaddress.ip', '%(ip)s') Try this... You define the set before you server table and after the ipadd