EditingContext.py :  » Database » Modeling-Framework » Modeling-0.9 » Modeling » interfaces » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Database » Modeling Framework 
Modeling Framework » Modeling 0.9 » Modeling » interfaces » EditingContext.py
# -*- coding: iso-8859-1 -*-
#-----------------------------------------------------------------------------
# Modeling Framework: an Object-Relational Bridge for python
#
# Copyright (c) 2001-2004 Sbastien Bigaret <sbigaret@users.sourceforge.net>
# All rights reserved.
#
# This file is part of the Modeling Framework.
#
# This code is distributed under a "3-clause BSD"-style license;
# see the LICENSE file for details.
#-----------------------------------------------------------------------------


"""
EditingContext API

  CVS information

    $Id: EditingContext.py 932 2004-07-20 06:21:57Z sbigaret $
  
"""
__version__='$Revision: 932 $'[11:-2]

try:
  from Interface import Base
except:
  class Base:
    pass

from Modeling.interfaces.ObjectStoreInterface import ObjectStoreInterface
from Modeling.interfaces.ObservingInterface import ObservingInterface

def defaultParentObjectStore():
 """

 If unset, defaults to 'CooperatingObjectStore.defaultCoordinator()'.

 See EditingContext.__init__
 """
 
def setDefaultParentObjectStore():
  """
  Returns the parent 'ObjectStore' to be used by EditingContexts.
  See EditingContext.__init__
  """

class IEditingContext(ObjectStoreInterface, ObservingInterface):
  """
  EditingContext: an in-memory world/graph of objects, with the ability
  to ensure its own persistance, to check its consistency, etc.
  
  """

  # initializer
  def __init__(self, parentObjectStore=None):
    """
    Initializes an 'EditingContext'.
    
    Parameter 'parentObjectStore'

      determines which 'ObjectStore' the receiver will use to fetch its data
      and to save changes made in it ; the default (i.e. when the parameter is
      omitted or equals to 'None') is to use the one returned by
      'defaultParentObjectStore()' --which in turn defaults to the
      application-wide shared 'CooperatingObjectStore.defaultCoordinator()'.

      Note that the parent 'ObjectStore' of an 'EditingContext' cannot be
      changed during the whole object's lifetime.

      You will typically use the default behaviour, or provide an parent
      'EditingContext' to make the newly created 'EditingContext' a child of
      the former one (not supported yet __TBD).
    """

  # Changes within the editing context
  def deletedObjects(self):
    """
    """

  def insertedObjects(self):
    """
    """

  def updatedObjects(self):
    """
    """

  def hasChanges(self):
    """
    """

  # Processing changes
  def saveChanges(self):
    """
    """

  # Object identification
  def objectForGlobalID(self, aGlobalID):
    """
    Returns the object corresponding to the given 'aGlobalID', or 'None' if
    it cannot be found in the receiver's uniquing table.
    """

  def globalIDForObject(self, anObject):
    """
    Returns the GlobalID for 'anObject', or 'None' if 'anObject' is not
    under the receiver's control.
    """
    
  # Object and graph of objects manipulation
  def deleteObject(self, anObject):
    """
    Informs the 'EditingContext' that the supplied object should be marked as
    deleted, so that it will actually be deleted when the receiver saves
    changes. This is n ot an error to mark an object as deleted more than
    once: this will be silently ignored.

    Parameter 'anObject' should already be registered within the
    'EditingContext' ; if not, 'ValueError' is raised.
    
    """
    
  def forgetObject(self, aDatabaseObject):
    """
    _TBD
    Do not call this: for internal use.
    """
    
  def insertObject(self, anObject):
    """
    Inserts a new object within the graph of objects. The 'EditingContext'
    builds a 'TemporaryGlobalID' for that object, registers the object as
    a new one in its graph of objects and registers itself as an observer for
    that object (see ObserverCenter).

    An object should not be inserted more than once. The only valid situation
    where an object can be re-inserted is when this object has previously been
    marked as deleted (hence un-deleting the object), otherwise 'ValueError'
    is raised.
    """
    
  def insertObjectWithGlobalID(self, anObject, aTemporaryGlobalID):
    """
    You should normally not call this method directly.

    Parameter 'aTemporaryGlobalID' must respond 'true' to message 'isTemporary'
    (raises 'ValueError' otherwise)
    """

  def recordObject(self, anObject, aGlobalID):
    """
    """

  def registeredObjects(self):
    "Returns all objects managed by the EditingContext"
    

  # ObjectStore hierarchy related methods
  def parentObjectStore(self):
    """
    Returns the parent ObjectStore for the receiver
    See the initializer '__init__' for details ; note that the parent
    ObjectStore cannot be changed during the whole object's lifetime.
    """

  # ObjectStore API
  def initializeObject(self, anObject, aGlobalID, anEditingContext):
    """
    Forwards the message to the parentObjectStore(), with the following
    exception: if 'anEditingContext' 's 'parentObjectStore()' is 'self', i.e.
    it is a child of 'self', and if 'self' already has an real object (not a
    fault) with that globalID, the values of this object is used to initialize
    'anObject'.

    Conformance to the ObjectStore API

    Parameters:

      anObject -- a DatabaseObject instance

      aGlobalID -- the GlobalID of 'anObject'

      anEditingContext -- the EditingContext which holds 'anObject'
      
    """
    
  def objectsWithFetchSpecification(self, aFetchSpecification,
                                    anEditingContext=None):
    """

    If parameter 'anEditingContext' is omitted or 'None', it defaults to
    'self', then the message is forwarded down the hierarchy of ObjectStores,
    i.e. to the 'parentObjectStore()'

    Conformance to the ObjectStore API
    """
    
  def rootObjectStore(self):
    """
    Returns the 'ObjectStoreCoordinator' in the underlying hierarchy of
    'ObjectStore'.
    Works by forwarding the 'rootObjectStore' message to the
    'parentObjectStore()'.

    Conformance to the ObjectStore API
    """

  # ObservingInterface
  def objectWillChange(self, anObject):
    """
    ObservingInterface implementation
    """
    
  # Behaviour when garbage-collected
  def invalidatesObjectsWhenFinalized(self):
    """
    default==true==when finalized, sends 'clearProperties' to all objects
    """

  def setInvalidatesObjectsWhenFinalized(self, aBool):
    "-"

  def __del__(self):
    "cf. invalidatesObjectsWhenFinalized()"


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.