Re: Using modeling framework in long run

John Lenton <[email protected]> Mon, 19 Jul 2004 10:30:08 -0300
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
On Mon, 19 Jul 2004 00:41:33 +0300, Andrey Lebedev <[email protected]> wrote:
> The simplest procedure I can come up with is:
> 
>   1. Change database on sql server using regular tools
> 
>   2. Change generated files by adding get<attr>, set<attr> methods and
>          other necessary functions.
> 
>   3. Change model file (actually I'm not sure it is nesessary)
> 
> The procedure is somewhat too complex, expecially because generated
> python modules are not elementary and consist of relatively complex
> statements to be written by hand each time database schema changes.
> 
> So, the question is: what, generally I have to do when I have, say,
> developer and production project installations and I want add new column
> to a table? How do you handle such situations?

1. Change model file
2. Regenerate python code, using -B (you must've done this the first time too)

    The -B option gives you the validators (the business logic) in
files in the base
    directory of the generated package, and set/get/add/etc. (the
"pure" generated
    code that you don't add to).

3. Alter the database.

this leaves your python code without the new validators, which you
might have to add, but it's significantly less trouble than what you
described.

If your validators get very complex, you might find it easyer to put
them in a mixin class, and modify the generated classes via the mixin
(which would normally be just one line per class you need to add).

Also, if you keep all the revisions of the original, unmodified
generated code, you can update the validators automatically with
diff3.

-- 
John Lenton ([email protected]) -- Random fortune:
bash: fortune: command not found


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click