[Cubicweb] UniqueConstraint - Data Model

Carlos Balderas carlos.balderas at gmail.com
Mon Aug 10 18:48:50 CEST 2009


In my application there is a part where I create a link to a specific
selected entity, example of the relative url: {Entity}/{eid}, but if I
define an attribute (or more attributes) within the entity which has to be
unique, I lost the way to link my entity with eid in the url, and now I have
to use the last unique attribute defined in the schema for that Entity.

Here is an example:

class Person(EntityType):
        name = String()
        folder = Int (constraint = [UniqueConstraint()])

Without the constraint I can use this url to find person entity:
http://localhost/person/301  <-- {eid}, but if I use the unique constraint
then I have to use this url http://localhost/person/1 <--- {folder}

I would like to use the attribute eid for my urls, doesn't matters if I have
another unique attributes defined in the entity, could this be possible? or
do you recommand me to use this unique attribute instead?

Thank you very much!
Best Regards
Carlos Balderas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20090810/e582f6b6/attachment-0186.html>

More information about the Cubicweb mailing list