vendor/CMF/1.5.5-beta/CMFTopic

view SimpleStringCriterion.py @ 0:4341d8feb2f9

Vendor import of CMF 1.5.5-beta
author fguillaume
date Mon, 07 Nov 2005 22:03:41 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
4 #
5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10 # FOR A PARTICULAR PURPOSE.
11 #
12 ##############################################################################
13 """ Simple string-matching criterion class
15 $Id: SimpleStringCriterion.py 36457 2004-08-12 15:07:44Z jens $
16 """
17 from Globals import InitializeClass
18 from AccessControl import ClassSecurityInfo
20 from permissions import View
21 from permissions import ChangeTopics
22 from AbstractCriterion import AbstractCriterion
23 from Topic import Topic
24 from interfaces import Criterion
26 class SimpleStringCriterion( AbstractCriterion ):
27 """
28 Represent a simple field-match for a string value.
29 """
30 __implements__ = ( Criterion, )
32 meta_type = 'String Criterion'
34 security = ClassSecurityInfo()
36 _editableAttributes = ( 'value', )
38 def __init__(self, id, field):
39 self.id = id
40 self.field = field
41 self.value = ''
43 security.declareProtected( ChangeTopics, 'getEditForm' )
44 def getEditForm( self ):
45 """
46 Return the skinned name of the edit form.
47 """
48 return 'ssc_edit'
50 security.declareProtected( ChangeTopics, 'edit' )
51 def edit( self, value ):
52 """
53 Update the value we are to match up against.
54 """
55 self.value = str( value )
57 security.declareProtected(View, 'getCriteriaItems')
58 def getCriteriaItems( self ):
59 """
60 Return a sequence of criteria items, used by Topic.buildQuery.
61 """
62 result = []
64 if self.value is not '':
65 result.append( ( self.field, self.value ) )
67 return tuple( result )
70 InitializeClass( SimpleStringCriterion )
72 # Register as a criteria type with the Topic class
73 Topic._criteriaTypes.append( SimpleStringCriterion )