Yarko,

thank you for your support on this.
I was obviously not good in describing the problem well. Sorry for
that. Let me try to rephrase it from an different point of view.

Lets take the example code below as starting point. The tables shape
and color are working like needed. The problem comes with the
shapecolormonth table. The requirement in this case is to define a
table where the combination of the 3 fields [shape+color+month] must
be unique. For example a calendar which allows a 'red triangle' only
once every calendar months.

I kind of got into the direction (not completely, but until 2 row
column unique key) from the model layer side but lost the dropdown
selection in the viewer.

What would be the best way in this code example to get the multi-
column-key (shapename+colorname+month) unique while keeping the
dropdown functionality of shapename and colorname and the date
(widget) selection for the month ?

Side question: Is there a widget (-option) or another more elegant way
to select only the %Y and %m part of the date? The need to select a
day in this example is a kind of pointless since only %Y+%m should be
processed and part of the unique key. The widget return values are not
even passing the form requirements IS_DATE('%Y-%m') and hence the
before forced selection of the day part of the field would need to be
deleted manually to pass the form requirements. I'm sure you guys have
experience with more elegant ways to solve also that.

Thanks,
Hans


db=SQLDB('sqlite://test.db')

db.define_table('shape',
  SQLField('name'))
db.shape.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'shape.name')]

db.define_table('color',
  SQLField('name'))
db.color.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'color.name')]

db.define_table('shapecolormonth',
  SQLField('shapename','reference shape'),
  SQLField('colorname','reference color'),
  SQLField('month','date'))
db.shapecolormonth.shapename.requires=requires=IS_IN_DB
(db,'shape.id','%(name)s')
db.shapecolormonth.colorname.requires=IS_IN_DB(db,'color.id','%(name)
s')
db.shapecolormonth.month.requires=IS_DATE('%Y-%m')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to