Lee McFadden, el 4 de agosto a las 02:59 me escribiste:
>
> You could always use custom _get_ and _set_ methods to enforce your
> own compound keys. I've never tried it but it should be possible
> (bearing in mind I'm writing this at 3am ;)
>
> Using your example:
[snip]
On svn's SQLObject you can do this:
class Person(SQLObject):
firstName = StringCol()
lastName = StringCol()
age = IntCol(alternateID=True)
nameIndex = DatabaseIndex(firstName, lastName, unique=True)
Person(firstName='Eric', lastName='Idle', age=62)
Person(firstName='Terry', lastName='Gilliam', age=65)
Person(firstName='John', lastName='Cleese', age=66)
print Person.nameIndex.get('Terry', 'Gilliam')
print Person.nameIndex.get(firstName='John', lastName='Cleese')
You'll get an exception if you try to do this:
Person.nameIndex.get(firstName='Graham', lastName='Chapman') # NOT FOUND
Person(firstName='John', lastName='Cleese', age=64) # DUPLICATED
Person.nameIndex.get('Terry') # NOT ENOUGH ARGUMENTS
And there is a *real* UNIQUE INDEX on the database checking for this
integrity, so you get the best from both worlds ;)
Here are the patches and examples:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1341999&group_id=74338
Hope it helps (and hope it get released soon ;)
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
.------------------------------------------------------------------------,
\ GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05 /
'--------------------------------------------------------------------'
Me encanta el éxito; por eso prefiero el estado de progreso constante,
con la meta al frente y no atrás.
-- Ricardo Vaporeso. Punta del Este, Enero de 1918.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---