GlobalID.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 » GlobalID.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.
#-----------------------------------------------------------------------------


"""
GlobalID  API

  This interface defines the API of classes GlobalID and TemporaryGlobalID.


  Notification:

    'GlobalIDChangedNotification' -- Posted by objects which change
    'TemporaryGlobalID' to 'KeyGlobalID' ; notification contains the following
    fileds: object: 'None', userInfo: a dictionary mapping temporary global
    ids to their corresponding 'KeyGlobalID'
    

  CVS information

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

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

def globalIDWithEntityName(entityName, informations):
  """
  Returns a new GlobalID based on the supplied informations.

  Parameter 'informations' can be either:

    - None, in which case a 'TemporaryGlobalID' is returned, or

    - an object implementing XXX,

    - a dictionary '{PK_name: value}', containing all entities' PKs

  In the two latter cases a 'KeyGlobalID' is returned.

  """


class GlobalIDInterface(Base):
  """
  GlobalID

  A GlobalID uniquely identifies an object. It is used within EditingContexts
  so that objects are kept unique.

  More precisely, a object fetched from a database (either ZODB or --later--
  any other DB) will be referenced by the same GlobalID in every
  EditingContexts it is referenced into, wherever these EditingContexts were
  instanciated, i.e. they could be within the same application/process or even
  distributed over the network (with multiple application instances, for
  load-balancing e.g.).

  On the other hand, a newly created object which has not been stored yet will
  receive a TemporaryGlobalID. This temporary global ID will be turned into
  a solid GlobalID as soon as it is made persistent.


  Implemented by: KeyGlobalID, TemporaryGlobalID
  
  """
  def __init__(self, entityName, informations):
    """
    (called by 'globalIDWithEntityName()')
    """

  # NB: do we need to add this to the root interface??
  #     only if a TemporaryGlobalID is a valid object to be passed along with
  #     the ObjectStoreCoordinator.CooperatingObjectStoreWasAddedNotification
  #def entityName(self):
  #  "Returns the name of the underlying entity"
    
  def isTemporary(self):
    """
    Returns 'true' if the receiver is a TemporaryGlobalID, 'false' otherwise
    """

  def __str__(self):
    """
    Returns a string representation of the GlobalID. This string representation
    has the same properties as a GlobalID in terms of uniquing.
    """
    
class IKeyGlobalID(GlobalIDInterface):
  """
  KeyGlobalID

    Implements: GlobalIDInterface

    You should not create a GlobalID by yourself. Instead, use:

      - either 'globalIDWithEntityName()',

      - or (better) Entity.globalIDForRow() __TBD
  """
  
  def __init__(self, entityName, keyValues):
    """
    Initializes a KeyGlobalID with the following parameters:

      - 'entityName' ('string')

      - 'keyValues' ('dictionary'), a mapping between PKs' names and values.

    """

class ITemporaryGlobalID(GlobalIDInterface):
  """
  TemporaryGlobalID

    Implements: GlobalIDInterface

    You should not create a GlobalID by yourself. Instead, use:

      - either 'globalIDWithEntityName()',

      - or (better) Entity.globalIDForRow() __TBD
  """
  
  def __init__(self, *args, **kw):
    """
    NB: all arguments are ignored.
    __TBD
    """
    
  def __str__(self):
    """
    Returns a string representation of the GlobalID. This string representation
    is unique among GlobalIDs.
    """
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.