class Entry(Entity):
    has_field('title', Unicode(255), unique=True, required=True)
    has_and_belongs_to_many('tags', unique=True, of_kind='Tag',
inverse='ideas')

    def __repr__(self):
        return '<Idea "%s">' % (self.title,)

class Tag(Entity):
    has_field('tag', Unicode(50), unique=True, required=True)
    has_and_belongs_to_many('ideas', of_kind='Idea', inverse='tags')

With the above code how can i assert that Tags can only be added once
to an Entry?

t = model.Tag(tag="test")
t1 = model.Tag(tag="secret")

model.entry.append(t)
model.entry.appen(t1)

now i would expect the following to cause an error or prevent it
somehow:
model.entry.append(t)
because entry has Tag t already and it makes no sense to append it
once more.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to