#####################################################################
#####################################################################
## Versavant Topic Map Application Bus / Subject Addressing Engine ##
## Copyright 2005 Steven R. Newcomb                                ##
##                                                                 ##
## This software is licensed under the Apache License, Version 2.0 ##
## (the "License"); you may not use this file except in compliance ##
## with the License.  Copies of the License are available at       ##
##        http://www.apache.org/licenses/LICENSE-2.0               ##
##                                                                 ##
## Unless required by applicable law or agreed to in writing,      ##
## software distributed under the License is distributed on an "AS ##
## IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ##
## express or implied.  See the License for the specific language  ##
## governing permissions and limitations under the License.        ##
##                                                                 ##
## Copies of the source code and the license are available at      ##
##        http://www.versavant.org                                 ##
#####################################################################
#####################################################################

####################################
cvsRevision = "$Revision: 1.3 $" ##
####################################

#####################################################################
## A ContextOf__PropertyIsInvalid() function that checks to see
## whether another property of the same TMA is present in the same
## proxy, and, if it's not present, complains and dies.
#####################################################################

#######################################################
def ContextOf__PropertyIsInvalid( vsv,
    propertyInstance,                      ## the property instance
    nameOfPropertyClassBeingCheckedFor     ## extra arg: pass name of class to check for
    ):
    
    TMAName = propertyInstance.propertyClass.TMA.TMAName
    propertyInProxyKey = vsv.catKey( TMAName, nameOfPropertyClassBeingCheckedFor)
    if not propertyInstance.proxy.propertyInstances.has_key( propertyInProxyKey):
        return 'Proxy has no %s property.' % ( propertyInProxyKey)
    else:
        return ''
