Re: [SQLObject] Patch: adding by[IndexName] method for unique indexes.
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Leandro L. <lu...@ll...> - 2005-10-31 18:44:46
|
Ian Bicking, el lunes 31 de octubre a las 11:04 me escribiste: > I don't want anymore automatic addition of methods to SQLObject classes > -- I'm not very happy with the ones that already exist. > > Instead, I'd like index objects to become smarter, since they are > already being explicitly named and put on the class as attributes. > Potentially these objects could be callable, or have a .get() method. > So it would be like: > > class Contact(SQLObject): > > areaCode = StringCol() > number = StringCol() > phoneIndex = DatabaseIndex('areaCode', 'number', unique=True) > > Contact.phoneIndex.get('555', '555-5555') > # Also allowable: > Contact.phoneIndex.get(number='555-5555', areaCode='555') I'm trying to fix my patch to work this way but I'm having a problem because now it doesn't seems to be possible to access to the index in this way: print Contact.phoneIndex AttributeError: type object 'Contact' has no attribute 'phoneIndex' The indexes are added to sqlmeta.indexes and sqlmeta.indexDefinitions lists and I don't even know which index (DatabaseIndex or SODatabaseIndex) should be exposed. If I can get some help in this matter, I think I could make the patch work. -- LUCA - Leandro Lucarella - JID: luca(en)lugmen.org.ar - Debian GNU/Linux .------------------------------------------------------------------------, \ GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05 / '--------------------------------------------------------------------' La máquina de la moneda, mirá como te queda! -- Sidharta Kiwi |