Re: Using modeling framework in long run

Sebastien Bigaret <[email protected]> 19 Jul 2004 21:00:29 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
        Hi Andrey,

  First at all, thanks for your interest!

The problem here is obviously that the default option (-C for
--compact-generation-scheme, see mdl_generate_python_code.py -h) is
nothing more than a example showing what are the basics for binding a
class to the framework. But nobody probably uses it in a real
dev. effort because it's difficult to deal with such a scheme when the
underlying DB-schema changes a lot --just what you noticed and felt
unconfortable with.

  As John Lenton has already explained, the -B switch in code generation
  will be a great help for you, since you can put all your code in
  subclasses of auto-generated classes which are put in a dedicated
  package (MDL/).

You can also look at John's original post and the corresponding thread
at:
https://sourceforge.net/mailarchive/forum.php?thread_id=3851852&forum_id=10674



Second, the framework does not anymore relies that heavily on code
generation, but how could you know since this hasn't been publicly
announced yet :/ ... (esp. because it's not fully documented)

--> dynamic, on-the-fly creation of package is available in the last 
    release 0.9pre17; look for a file named doc/README.dynamic.txt, also
    available here:
http://cvs.sourceforge.net/viewcvs.py/modeling/ProjectModeling/Modeling/doc/README.dynamic.txt?rev=1.1&view=auto

Using that feature allows you to bypass the modification of the needed
code since dynamic generation will always use your model to dynamically
create your classes.  Just a little note, Ernesto Revilla reported some
problems regarding properties and inheritance, so you may not want to
use properties right now; more details in Ernesto's original post here:
https://sourceforge.net/mailarchive/forum.php?thread_id=5035017&forum_id=10674

  Feel free to ask for more if some points remain obscure!

-- Sebastien.


Andrey Lebedev <[email protected]> wrote:
> Hello,
> 
> I'm currently evaluating several object-relational mappings available
> for python and I thing modeling is one of the best among them. However,
> I need some clarification on how projects, that are based on modeling
> framework, are supposed to be maintained.
> 
> As far as I understand, the framework is heavily relies on code
> generation. Developer creates single XML or python file, describing data
> model and then generates SQL schemas and python sources. Judging from
> comments inside those generated python sources, they are intended to be
> modified by developers after generation.
> 
> But what happens when database schema should be changed? What if there
> are data in database that can't be lost just by deleting and recreating
> tables? How to keep generated files' customizations after model
> modifications?
> 
> 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?
> 
> Thanks in advance.
> 
> -- 
> Andrey Lebedev aka -.- . -.. -.. . .-.
> Software engineer at UAB Mikromarketingas (http://micro.lt)
> Homepage: http://micro.lt/~andrey/
> Jabber ID: [email protected]



-------------------------------------------------------
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