vendor/CMF/1.5.5-beta/CMFTopic

view AbstractCriterion.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 """ Home of the abstract Criterion base class.
15 $Id: AbstractCriterion.py 36457 2004-08-12 15:07:44Z jens $
16 """
17 from Acquisition import Implicit
18 from AccessControl import ClassSecurityInfo
19 from Persistence import Persistent
20 from Globals import InitializeClass
21 from OFS.SimpleItem import Item
23 from permissions import AccessContentsInformation
24 from permissions import ChangeTopics
27 class AbstractCriterion( Persistent, Item, Implicit ):
28 """
29 Abstract base class for Criterion objects.
30 """
32 security = ClassSecurityInfo()
34 security.declareProtected(ChangeTopics, 'apply')
35 def apply( self, command ):
36 """
37 Apply 'command', which is expected to be a dictionary,
38 to 'self.edit' (makes using Python Scripts easier).
39 """
40 self.edit(**command)
42 security.declareProtected( ChangeTopics, 'editableAttributes' )
43 def editableAttributes( self ):
44 """
45 Return a list of editable attributes, used by topics
46 to build commands to send to the 'edit' command of each
47 criterion, which may vary.
49 Requires concrete subclasses to implement the attribute
50 '_editableAttributes' which is a tuple of attributes
51 that can be edited, for example:
53 _editableAttributes = ( 'value', 'direction' )
54 """
55 return self._editableAttributes
57 security.declareProtected( AccessContentsInformation, 'Type' )
58 def Type( self ):
59 """
60 Return the Type of Criterion this object is. This
61 method can be overriden in subclasses, or those
62 concrete subclasses must define the 'meta_type'
63 attribute.
64 """
65 return self.meta_type
67 security.declareProtected( AccessContentsInformation, 'Field' )
68 def Field( self ):
69 """
70 Return the field that this criterion searches on. The
71 concrete subclasses can override this method, or have
72 the 'field' attribute.
73 """
74 return self.field
76 security.declareProtected( AccessContentsInformation, 'Description' )
77 def Description( self ):
78 """
79 Return a brief but helpful description of the Criterion type,
80 preferably based on the classes __doc__ string.
81 """
82 lines = [ line.strip() for line in self.__doc__.splitlines() ]
83 return ' '.join( [ line for line in lines if line ] )
85 InitializeClass( AbstractCriterion )