Please note: this project is inactive since early 2006

 
A.1 Core

Warning: Environment variable MDL_PERMANENT_DB_CONNECTION has been deprecated and has no effect anymore. It has been replaced by MDL_TRANSIENT_DB_CONNECTION which has the opposite semantics.

Name  Description  Possible values 
MDL_DB_CONNECTIONS_CFG  
  It happens that a model can be written in different places: in an xml file, in a python file, and even in a pickle when you use mdl_compile_model.py. The consequence is that the connection dictionary itself for each model, containing the user and its password, is written two or three times in the filesystems. For security and administrative reasons, one would prefer that this sensitive information should be written in a single place.
 
This environment variable allows you to externalize the connection dictionaries of all your models in a single file; you'll typically remove the user and password from your models, and add these informations to a single file, say /full/path/to/db_conn_dicts.cfg, in a dedicated section for each model, like this:

[<ModelName>]
user: <username>
password: <passwd>

Then, simply assign to the env. variable MDL_DB_CONNECTIONS_CFG the full path to your db_conn_dicts.cfg, and your models' connection dictionaries will automatically be updated when they are loaded.
Last, every parameter normally assigned to a connection dictionary can be defined in this file, such as: host, port, etc. An extra field can be specified, adaptor, which overrides the adaptor's name in your model (example value: Postgresql, MySQL).
See also python documentation for ConfigParser.
full path to an ini-file
MDL_ENABLE_DATABASE_LOGGING  
  DatabaseAdaptors for Postgresql and MySQL use a common logging mechanism, whose methods are located in module Modeling.logging. This logging is not activated by default, except for error and fatal errors. To enable it, you set this variable to any non-empty string ; log outputs go to the sys.stderr. To disable it, just unset this variable, or set it to the empty string. e.g. '1', 'YES' (plus the empty string for de-activation)
MDL_ENABLE_SIMPLE_METHOD_CACHE  
  When this variable is set to any non-empty string, the framework automatically caches the simple methods of models and class description (by simple methods, we mean methods taking self as their only argument). Since both of these objects are heavily used at runtime (because model introspection is needed at various stages), enabling this cache speeds up the simple operations (for example, the inverse relationship for a given relation is computed once, then it is cached).
There are situations, however, where you do not want to enable this. For example, if after loading your model you need to change anything in it (such as modifying the connection string, changing an attribute's external type, adding a relationship, etc.), this shouldn't be enabled; if it is, the changes won't have any effect on the model themselves: e.g. you can set the connection dictionary but connectionDictionary() will keep returning its initial value. In such situations, you can either:
  • not enable this cache for the whole application,
  • or enable it after all changes have been made, by executing the following code:
     
    import os
    from Modeling.ModelSet import defaultModelSet
    os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE']='Y'
    for model in defaultModelSet().models():
      model.cacheSimpleMethods()

    Attention: once the caching mechanism has been enabled, it cannot be disabled (so no more changes can be made to your models)
Note: The environment variable MDL_DB_CONNECTIONS_CFG is taken into account to update a model's properties before it is cached, no particular action is needed in this case.
e.g. '1', 'YES' (plus the empty string for de-activation)
MDL_TRANSIENT_DB_CONNECTION  
  By default, a database connection is left opened after each request, so that it can be re-used for subsequent requests. When this environment variable is set to any true value, any opened database connection is closed after it's been used -for example, the database connections needed to perform the actions defined in ec.objectsWithFetchSpecification(), ec.objectsCountWithFetchSpecification or ec.saveChanges() are closed as soon before these functions return.
e.g. '1', 'YES' (plus the empty string for de-activation)

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