Back to index

plone3  3.1.7
simplestring.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # ATContentTypes http://plone.org/products/atcontenttypes/
00004 # Archetypes reimplementation of the CMF core types
00005 #
00006 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00007 # Copyright (c) 2003-2006 AT Content Types development team
00008 #
00009 # This software is subject to the provisions of the Zope Public License,
00010 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
00011 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00012 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00013 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00014 # FOR A PARTICULAR PURPOSE
00015 #
00016 ##############################################################################
00017 """ Topic:
00018 
00019 
00020 """
00021 
00022 __author__  = 'Christian Heimes <tiran@cheimes.de>'
00023 __docformat__ = 'restructuredtext'
00024 __old_name__ = 'Products.ATContentTypes.types.criteria.ATSimpleStringCriterion'
00025 
00026 from Products.CMFCore.permissions import View
00027 from AccessControl import ClassSecurityInfo
00028 
00029 from Products.Archetypes.atapi import Schema
00030 from Products.Archetypes.atapi import StringField
00031 from Products.Archetypes.atapi import StringWidget
00032 
00033 from Products.ATContentTypes.criteria import registerCriterion, \
00034     STRING_INDICES
00035 from Products.ATContentTypes.interfaces import IATTopicSearchCriterion
00036 from Products.ATContentTypes.permission import ChangeTopics
00037 from Products.ATContentTypes.criteria.base import ATBaseCriterion
00038 from Products.ATContentTypes.criteria.schemata import ATBaseCriterionSchema
00039 
00040 from Products.ATContentTypes import ATCTMessageFactory as _
00041 
00042 ATSimpleStringCriterionSchema = ATBaseCriterionSchema + Schema((
00043     StringField('value',
00044                 required=1,
00045                 mode="rw",
00046                 write_permission=ChangeTopics,
00047                 accessor="Value",
00048                 mutator="setValue",
00049                 default="",
00050                 widget=StringWidget(
00051                     label=_(u'label_string_criteria_value', default=u'Value'),
00052                     description=_(u'help_string_criteria_value',
00053                                   default=u'A string value.'))
00054                 ),
00055     ))
00056 
00057 
00058 class ATSimpleStringCriterion(ATBaseCriterion):
00059     """A simple string criterion"""
00060 
00061     __implements__ = ATBaseCriterion.__implements__ + (IATTopicSearchCriterion, )
00062     security       = ClassSecurityInfo()
00063     schema         = ATSimpleStringCriterionSchema
00064     meta_type      = 'ATSimpleStringCriterion'
00065     archetype_name = 'Simple String Criterion'
00066     shortDesc      = 'Text'
00067 
00068     security.declareProtected(View, 'getCriteriaItems')
00069     def getCriteriaItems(self):
00070         result = []
00071 
00072         if self.Value() is not '':
00073             result.append((self.Field(), self.Value()))
00074 
00075         return tuple( result )
00076 
00077 registerCriterion(ATSimpleStringCriterion, STRING_INDICES)