This is the summary of changes (copied from the patch).
User-visible Changes:
Now, fo each DatabaseIndex with unique=True you
have an extra method
by[IndexName] like by[AlternateID], that takes
as parameters the columns
used in the index. You can specify an extra
option when creating
DatabaseIndex, alternateMethodName, just like
with Columns with
alternateID=True.
Internal Changes:
Now dbconnection.DBAPI._SO_selectOneAlt() can
accept a sequence for
'column' and 'value' parameters. Both must have
the same len() and it's
mapped in the query as column[0] = value[0] AND
... column[N] = value[N]
index.SODatabaseIndex() constructor takes an
extra optional parameter
'alternateMethodName' wich is set by default to
by[IndexName].
main.sqlmeta.addIndex() now adds the proper
by[IndexName] method to
soClass, using
main.sqlmeta._SO_fetchAlternateID() to retrieve the data.
main.sqlmeta._SO_fetchAlternateID() now takes
an extra optional
parameter 'idxName' with the index name (when
it's called for an index)
for error reporting purpose. 'column' and
'value' parameters can accept
a sequence just like
dbconnection.DBAPI._SO_selectOneAlt().
Logged In: YES
user_id=240225
Here's a simple example of use.
Logged In: YES
user_id=210337
(copied from email comments)
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')
Patch to expose indexes in soClass, so you can access an index via soClass.indexName
New patch that implements SODabatabesIndex.get() method.
New test for the SODabatabesIndex.get() method.
Logged In: YES
user_id=4799
Applied at the revision 1192 to the trunk. Thank you!