AdaptorOperation.py :  » Database » Modeling-Framework » Modeling-0.9 » Modeling » 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 » AdaptorOperation.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.
#-----------------------------------------------------------------------------

"""
AdaptorOperation

  CVS information

    $Id: AdaptorOperation.py 932 2004-07-20 06:21:57Z sbigaret $

"""
__version__='$Revision: 932 $'[11:-2]


from DatabaseOperation import \
     ADAPTOR_LOCK_OPERATOR,\
     ADAPTOR_INSERT_OPERATOR,\
     ADAPTOR_UPDATE_OPERATOR,\
     ADAPTOR_DELETE_OPERATOR,\
     ADAPTOR_STORED_PROCEDURE_OPERATOR,\
     ADAPTOR_OPERATORS

#
class AdaptorOperation:
  """

  """
  
  def __init__(self, anEntity, adaptorOperator):
    """
    """
    self.__entity=anEntity
    self.setAdaptorOperator(adaptorOperator)
    self.__changedValues=None
    self.__qualifier=None
    
  def adaptorOperator(self):
    """
    Returns the type of the operation the AdaptorOperation performs
    """
    return self.__operator
  
  def attributes(self):
    """
    __TBD for lock only

    """
    self.__unimplemented__()
    
  def changedValues(self):
    """
    See setChangedValues() for details
    """
    return self.__changedValues
  
  def entity(self):
    """
    Returns the Entity corresponding to the object concerned by this 
    AdaptorOperation.

    See also: setEntity()
    """
    return self.__entity
  
  def exception(self):
    """
    """

  def qualifier(self):
    """
    Returns the qualifier that should be used for LOCK, UPDATE or DELETE
    operations.

    See also: setQualifier()
    """
    return self.__qualifier
    
  def setAdaptorOperator(self, anAdaptorOperator):
    """
    Sets the type of the operation the AdaptorOperation performs

    Raises ValueError in anAdaptorOperator is not in ADAPTOR_OPERATORS.
    """
    if anAdaptorOperator not in ADAPTOR_OPERATORS:
      raise ValueError, 'Invalid adaptor operator (%s)'%str(anAdaptorOperator)
    self.__operator=anAdaptorOperator
    
  def setAttributes(self, attributes):
    """
    __TBD for lock only

    """
    self.__unimplemented__()
    
  def setChangedValues(self, changedValues):
    """

    INSERT: the full set of value to be inserted within the underlying database

    UPDATE: the values to changed

    LOCK: the values to be compared with the row in the database
    
    Parameter:

      changedValues -- a dictionary made of attributes' names and their
      corresponding values.
      
    """
    self.__changedValues=changedValues
    
  def setException(self, anException):
    """
    """
    self.__unimplemented__()

  def setQualifier(self, aQualifier):
    """
    Sets the object's quelifier

    Used by for LOCK, UPDATE and DELETE.

    """
    self.__qualifier=aQualifier
    
  def setStoredProcedure(self, aStoredProcedure):
    """
    Unimplemented yet
    """
    self.__unimplemented__()

  def storedProcedure(self):
    """
    Unimplemented yet
    """
    self.__unimplemented__()

  def __cmp__(self, anAdaptorOperation):
    """
    Compares 'self' to 'anAdaptorOperation'. Comparison is based on the
    AdaptorOperations' adaptorOperators, whose order is:
    LOCK, INSERT, UPDATE, DELETE, STORED_PROCEDURE (the latter is not supported
    yet).
    """
    return cmp(self.__operator, anAdaptorOperation.adaptorOperator())
  
  def __str__(self):
    """
    Returns a string representation for this object, made of:
    'repr(self)', the operator and the entity's name.
    """
    return '[%s at %s operator: %s, entity: %s]'%(str(self.__class__),
                                                  hex(id(self)),
                                                  self.__operatorToString(),
                                                  self.__entity.name())

  def __repr__(self):
    return self.__str__()
  
  def __operatorToString(self):
    """
    Internally used by __str__
    """
    op=self.__operator
    if op is ADAPTOR_LOCK_OPERATOR: return 'LOCK'
    elif op is ADAPTOR_INSERT_OPERATOR: return 'INSERT'
    elif op is ADAPTOR_UPDATE_OPERATOR: return 'UPDATE'
    elif op is ADAPTOR_DELETE_OPERATOR: return 'DELETE'
    elif op is ADAPTOR_STORED_PROCEDURE_OPERATOR: return 'STORED_PROCEDURE'
    else: return '<Unknown operator>'
    
  def __unimplemented__(self):
    "-"
    raise 'Unimplemented'
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.