Please note: this project is inactive since early 2006

4.1 Ensuring unicity of an object

An other feature assumed by EditingContexts is that they make sure that a given object has a single instance within them. So, if you fetch a particular object, then later access the same object e.g. by traversing some relationships, you are sure that the two are the same object (exactly the same, not only the same values). Put differently, say you have B in relation to A and C in relation to A, (and given that A, B and C are in the same EditingContext as they should be), you will always have this situation:

            B       C
             \     /
              \   /
               \ /

and you will NEVER get such a graph:

            B       C
             \       \
              \       \
               A       A'
with objects A and A' ultimately referring to the very same row in the database.

To create an EditingContext, simply use the statements:

        >>> from Modeling.EditingContext import EditingContext
        >>> ec=EditingContext()

Note: You can refer to modeling/tests/ for examples of use - it covers all topics described here.

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted Logo