On Wed, Jan 18, 2006 at 02:46:57PM +0100, jt wrote:
> ------------------------------------------------------------------------------
> import sys
> sys.path.insert(0, 'lib/FormEncode-0.4-py2.4.egg')
> sys.path.insert(0, 'lib/SQLObject-0.7.0-py2.4.egg')
> import sqlobject as so
> import sqlobject.inheritance
> 
> so.sqlhub.processConnection = so.connectionForURI('sqlite:/:memory:')
> 
> class Entity(so.inheritance.InheritableSQLObject):
>         name = so.UnicodeCol(notNone=1)
> class Country(Entity):
>         code = so.StringCol(length=2) # iso3166-1 Alpha-2
> 
> Entity.createTable(ifNotExists=True)
> Country.createTable(ifNotExists=True)
> 
> Country(name='Switzerland', code='CH')
> Country(name='South Africa', code='ZA')
> 
> print list(Country.select(orderBy='code'))
> print list(Country.select(orderBy='name'))

   The second statement generates a query that joins tables Entity and
Country. You have to advice the DB what table the column is from. Try

print list(Country.select(orderBy='entity.name'))

   Even better would be to got a habit to use q-magic for all attribute
access:

print list(Country.select(orderBy=Country.q.code))
print list(Country.select(orderBy=Country.q.name))

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to