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 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 name... in fact server name 
> should be server111, so i use grid to display server table and use update 
> button next to "server1" record. I change server name to server111 and i 
> need to chose an IP again (as IP dropdown field is blank). So now i would 
> like to chose same IP as before, but I'm not able to do it, because 
> dropdown shows just 10.2.2.2 which make sense as i used 
>
>  requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
> '%(ip)s')),
>
> So my question is how to make IP 10.1.1.1 visiable on the list when i'm 
> updating the record? 
>
> Regards.
>
> On Thursday, 7 May 2015 15:52:07 UTC+2, Richard wrote:
>>
>> 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 a given device... If so, you DB schema is not sufficient, you 
>> will need an archive table which will contains the old state of your server 
>> record... In your server table there will be only a single record for each 
>> of your server and in the history table when you update this single record 
>> the old state of the record will be copied there, so you can track all the 
>> IP a given server had in the past... An history table is easy achieve in 
>> web2py with record versioning...
>>
>> Richard
>>
>> On Thu, May 7, 2015 at 6:52 AM, <kecajk...@gmail.com> wrote:
>>
>>> 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 the name of the server (withouth changing its IP), but i need to 
>>> chose an IP as well. Problem is that on the IP list, IP i used for that 
>>> server before is marked as Used, so i won't see it on the list and i can't 
>>> chose it again. How to make it available for selection while i'm updating 
>>> the row.
>>>
>>> Thanks
>>> On Wednesday, 6 May 2015 16:52:05 UTC+2, 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')
>>>>
>>>> Try this... You define the set before you server table and after the 
>>>> ipaddress table..
>>>>
>>>> Richard
>>>>
>>>> On Tue, May 5, 2015 at 9:46 AM, <kecajk...@gmail.com> wrote:
>>>>
>>>>> Hi All, 
>>>>>
>>>>> I have very basic dtabasae where in one table i have IPs which are 
>>>>> used in second table:
>>>>>
>>>>> db.define_table('ipaddress',
>>>>>    Field('ip', unique=True, length=200,requires=IS_NOT_EMPTY()),
>>>>>    Field('subnet', 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),
>>>>>    Field('port', length=200, requires=IS_NOT_EMPTY()),
>>>>>    Field('ipaddress', unique=True, length=200, 
>>>>> requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
>>>>> '%(ip)s')),
>>>>>   
>>>>>
>>>>> The problem i'm having is that with grid i can delete and add new 
>>>>> values to "server" table and i added function which update status of IP 
>>>>> for 
>>>>> USED or FREE after insert/delete. 
>>>>> Problem is with Update function as when i try to update server name i 
>>>>> need to chose IP again and i can't chose same IP as it is marked in 
>>>>> ipaddress table as USED hence it's not displayed in dropdown menu.
>>>>> How can i display all IPs that are marked as FREE in ipaddress table 
>>>>> AND IPs that where currently assign to the record i'm updateing in table 
>>>>> server? 
>>>>>
>>>>> Regards.
>>>>>
>>>>> -- 
>>>>> Resources:
>>>>> - http://web2py.com
>>>>> - http://web2py.com/book (Documentation)
>>>>> - http://github.com/web2py/web2py (Source code)
>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>> --- 
>>>>> 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 web2py+un...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> --- 
>>> 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 web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to