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


"""

  Qualifier API

    * Predefined Operators

    * Module functions (building qualifiers, in-memory filtering, etc.)

    * Qualifiers: AND, NOT, ...

  CVS Information

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

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

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

# Predefined Operators
def QualifierOperatorEqual(value1, value2):
  ""

def QualifierOperatorNotEqual(value1, value2):
  ""

def QualifierOperatorGreaterThan(value1, value2):
  ""

def QualifierOperatorLessThan(value1, value2):
  ""

def QualifierOperatorGreaterThanOrEqualTo(value1, value2):
  ""

def QualifierOperatorLessThanOrEqualTo(value1, value2):
  ""

def QualifierOperatorContains(value1, value2):
  ""

def QualifierOperatorLike(value1, value2):
  ""

def QualifierOperatorCaseInsensitiveLike(value1, value2):
  ""

# Module functions
def allQualifierOperators():
  """
  Returns all strings which can be turned into a QualifierOperator by
  method 'operatorForString()'
  """

def filteredArrayWithQualifier(objects, qualifier):
  "Returns those objects in 'objects' which match the supplied qualifier"

def operatorForString(aString):
  "Returns the QualifierOperator corresponding to the supplied string"

def qualifierToMatchAllValues(aDictionary):
  """
  Returns an AndQualifier composed with KeyValueQualifier matching the keys
  in the dictionary with their values --used operator: OperatorQualifierEqual
  """
  
def qualifierToMatchAnyValues(aDictionary):
  """
  Returns an OrQualifier composed with KeyValueQualifier matching the keys
  in the dictionary with their values --used operator: OperatorQualifierEqual
  """
  
def qualifierWithQualifierFormat(qualifierFormat): #, arguments
  """
  Builds a Qualifier from a given expression, such as::

    NOT ( name=='truc' AND age>30 AND age < 65 )

  """
# We do not need any parameters 'arguments' here: python already offers a
# powerful mechanism for variable substitution within a string.
# NB: same for qualifierWithBindings
#
# Note2: well, this is only partially true, especially when you consider
# qualifier as a part of a FetchSpecification. It could be nice to be able to
# supply to a FetchSpec. a qualifier without the bindings, and then to use these bindings as 'parameters' for that fetchSpec. Okay, to be continued.

def relationalQualifierOperators():
  """
  Returns all operators except those dedicated to string comparisons, 'like'
  and 'caseInsensitiveLike'
  """

class QualifierInterface(Base):
  """
  """

  def addQualifierKeysToSet(self, qualifierKeysList): # must be overridden
    """Adds the receiver's qualifier keys to the supplied list. This must
    be overriden in subclasses"""
    
  def allQualifierKeys(self): 
    """
    Returns the set (tuple) of keys used in the qualifier. The returned tuple
    has no duplicate.

    For example, for a qualifier defined like this::

      NOT((age<=30 OR age>50) AND book.title caseInsensitiveLike "*hitchhiker*"

    the set ('age', 'book.title') is returned.

    Subclasses should not override this method: override addQualifierKeysToSet
    instead.
    """

  def bindingKeys(self):
    ""
  
  def evaluateWithObject(self, object): # object implements KeyValueCoding
    """
    Tests whether the supplied object matches the qualifier
    Parameter 'object' should be a subclass of KeyValueCoding
    """

  def keyPathForBindingKey(self, aKey):
    ""

  def validateKeysWithRootClassDescription(self, aClassDescription): # abstract
    """
    Checks that all qualifierKeys can be found in the supplied class
    description, either in attributes or relationships. When a keypath is
    involved, like 'book.title', only the first part, i.e. 'book', while
    be checked against the class description ; the remaining part is not
    checked at all.

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