Please note: this project is inactive since early 2006

3.1.2.1 Dynamic generating of ``standard'' python code

The first method simply consists in building the exact same code as the one generated by mdl_generate_python_code.py:

### Load the model
def load_model():
  from Modeling import ModelSet, Model
  model=Model.searchModel('AuthorBooks', '.', verbose=1)
  ModelSet.defaultModelSet().addModel(model)

# build and use it!
from Modeling import dynamic
dynamic.build(model, define_properties=0)
from AuthorBooks.Book import Book

As expected, if you call build with define_properties=1, the method adds python properties (see property') in built-in functions for each attribute or relationship in the entity, so that you do not need anymore to use e.g. book.getTitle() or book.setTitle, but simply print book.title or book.title="my title".

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo