2006/1/24, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Wow, thank you. This will be very useful.
>
> One more question, the table to be queried depends a parameter passed
> from the web form. How can I make the table name dynamic in the class?

You mean, you have one class that  represents several tables? I don't
know if this will work, but you can try:

MyTable.sqlmeta.table = 'table1'
results = MyTable.select()

If you have one class per table (the usual situation), than getattr will do:

import model #assuming all classes are defined in model file
cls = getattr(model, class_name)
results = cls.select()

If class' name is uknown, but table name is, style object can  help:

from sqlobject.styles import MixedCaseUnderscoreStyle  # default
SQLObject naming style
style = MixedCaseUnderscoreStyle()
class_name = style.dbTableToPythonClass(table_name)

--
Ksenia

Reply via email to