Woah... way beyond me here.
My tables are like this...
---
db.define_table('page',
Field('name', 'string', length=25),
Field('description', 'text'),
Field('created', 'datetime', default=now, readable=True,
writable=False))
db.define_table('article',
Field('title', 'string', length=25),
Field('text', 'text'),
Field('media', 'upload', autodelete= True),
Field('created', 'datetime', default=now, readable=True,
writable=False),
Field('types', requires=IS_IN_SET(['One', 'Two', 'Three'])),
Field('columns', requires=IS_IN_SET(['One', 'Two', 'Three'])),
Field('author',
requires=IS_IN_DB(db,db.author.id,'%(full_name)s')))
db.define_table('page_articles',
Field('page', requires=IS_IN_DB(db,db.page.id,'%(name)s')),
Field('article',
requires=IS_IN_DB(db,db.article.id,'%(title)s')),
Field('placement', requires=IS_IN_SET(range(1,21)))
---
By how do I declare the request.var.page and request.var.placement in
the model. Should it be the the controller?
If so here is that page just in case....
---
def page_creator():
if len(request.args):
pages = db(db.page_articles.id==request.args[0]).select()
if len(request.args) and len(pages):
page_form = SQLFORM(db.page_articles, pages[0], deletable=True)
else:
page_form = SQLFORM(db.page_articles)
if page_form.accepts(request.vars, session):
response.flash = 'Action Commited Succesfully'
elif page_form.errors:
response.flash = 'Hmmm, something went wrong.'
all_pages = db((db.page.id==db.page_articles.page) &
(db.article.id==db.page_articles.article))
return dict(page_form=page_form, all_pages=all_pages)
---
Thanks in advance guys,
Jason
On Tue, 2009-09-22 at 12:55 -0700, mr.freeze wrote:
> If you can describe your constraint with as a DAL set, you can pass it
> to IS_NOT_IN_DB. Maybe something like this?
>
> existing = db((db.page.number==request.vars.page)&
> (db.placement.code==request.vars.placement))
> db.article.number.requires = IS_NOT_IN_DB(existing,'article.number')
>
> On Sep 22, 12:59 pm, Jason Brower <[email protected]> wrote:
> > I have three major fields in a table:
> > Page, Article and Placement
> > I want to make sure that the placement is unique to that article
> > so...
> > Page1, Article1, 1
> > Page2, Article2, 1
> > Page1, Article3, 2
> > But it will not alow placement of...
> > Page1, Article4, 1
> > or...
> > Page1, Article1, 3
> >
> > I hope that makes sence.
> > Regards,
> > Jason Brower
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---