On Sat, Mar 05, 2011 at 08:29:54AM +0000, Timothy W. Grove wrote:
> Thanks for the advice, Oleg. I found a solution which may not be  
> elegant, but it works for me! Instead of trying to work with two  
> different class definitions I've just kept one which declares the column  
> I wish to add to the database and run an update function which deletes  
> the column from the class before adding it again to both the class and  
> the database. My example follows.

   Sometimes I do the same.

> Best regards,
> Tim
>
>    class SignEntry(SQLObject):
>         explanatory_map = PickleCol()
>
>    def SignEntryUpdate():
>         cols = [i.name for i in
>    sqlhub.processConnection.columnsFromSchema("sign_entry", SignEntry)]
>         if 'explanatoryMap' not in cols:
>             SignEntry.sqlmeta.delColumn('explanatory_map') # I know
>    this exists in the class definition
>             SignEntry.sqlmeta.addColumn(PickleCol("explanatory_map"),
>    changeSchema=True)

   Minor optimization in case you are going to test many columns - a set
is perhaps faster for repeated 'in' testing:

        cols = set([i.name for i in 
sqlhub.processConnection.columnsFromSchema("sign_entry", SignEntry)])

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to