yes
class IS_IN_DB_OR_ADD:
def __init__(self,db,table_and_field):
self.db = db
self.table,self.field = str(table_and_field).split('.')
def __call__(self,value):
if not self.db(self.db[self.table][self.field]==value):
self.db[self.table].insert(**{self.field:value})
return (value, None)
use it as
db.define_table('keys_table",SQLField('key_name'))
db.define_table("other_table",SQLField("mykey"))
db.other_table.mykey.requires=IS_NOT_EMPTY(), IS_IN_DB_OR_ADD
(db,'keys_table.key_name')
Hope it make sense.
(may contain a typo). If it works fine, could you post an AlterEgo
entry about this?
Massimo
On Feb 26, 10:03 am, kralin <[email protected]> wrote:
> Hi everybody,
> this is my first post here.
> I'm learning to use web2py since a month now, and I really appreciate
> it's simplicity and speed of use.
> However, I've got a problem I'm not able to solve by myself.
> I read the manual and searched everywhere, but I still cannot find any
> hint. So you guys are my last hope...
>
> I'm building a simple database and I need to build an Input/modify
> mask with a contraint.
> In almost all the fields the user may be able to choose between
> selecting the values stored in an other table, or add a new value.
> This value should be added to the other table, and returned the next
> time.
> Is there a way to figure this out while maintaining a single input
> page?
> Maybe I'm asking something that is obvious to you, 'cause I'm sure I'm
> not the only one to have this problem. But I cannot find any example
> or documentation.
> I've got some strange ideas to solve this, but I was looking ad a
> simpler, web2py, way.
>
> Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---