Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ CMFTopic product interfaces.
00014 
00015 $Id: __init__.py 67932 2006-05-03 14:36:10Z yuppie $
00016 """
00017 
00018 from zope.interface import Interface
00019 
00020 
00021 class ITopic(Interface):
00022 
00023     """ Topics are 'canned queries'.
00024 
00025     o Each topic holds a set of zero or more Criteria objects specifying
00026       the query.
00027     """
00028 
00029     def queryCatalog(REQUEST=None, **kw):
00030         """ Invoke the catalog using our criteria.
00031 
00032         o Built-in criteria update any criteria passed in 'kw'.
00033         """
00034 
00035 
00036 class IMutableTopic(ITopic):
00037 
00038     """ Updatable form of ITopic.
00039     """
00040 
00041 
00042 class ICriterion(Interface):
00043     """\
00044     A Topic is composed of Criterion objects which specify the query
00045     used for the Topic.  By supplying some basic information, the
00046     Criterion objects can be plugged into Topics without the Topic
00047     having to be too aware of the Criteria types.
00048     """
00049 
00050     def Type():
00051         """\
00052         Return the type of criterion object this is (ie - 'List Criterion')
00053         """
00054 
00055     def Field():
00056         """\
00057         Return the field this criterion object searches on.
00058         """
00059 
00060     def Description():
00061         """\
00062         Return a brief description of the criteria type.
00063         """
00064 
00065     def editableAttributes():
00066         """\
00067         Returns a tuble of editable attributes.  The values of this
00068         are used by the topic to build commands to send to the
00069         'edit' method based on each criterion's setup.
00070         """
00071 
00072     def getEditForm():
00073         """\
00074         Return the name of a DTML component used to edit criterion.
00075         Editforms should be specific to their type of criteria.
00076         """
00077 
00078     def apply(command):
00079         """\
00080         To make it easier to apply values from the rather dynamic
00081         Criterion edit form using Python Scripts, apply takes a
00082         mapping object as a default and applies itself to self.edit.
00083 
00084         It's basically a nice and protected wrapper around
00085         self.edit(**command).
00086         """
00087 
00088 # XXX: Interfaces have to specify the signature.
00089 ##    def edit(**kw):
00090 ##        """\
00091 ##        The signature of this method should be specific to the
00092 ##        criterion.  Using the values in the attribute
00093 ##        '_editableAttributes', the Topic can apply the right
00094 ##        commands to each criteria object as its being edited without
00095 ##        having to know too much about the structure.
00096 ##        """
00097 
00098     def getCriteriaItems():
00099         """\
00100         Return a sequence of key-value tuples, each representing
00101         a value to be injected into the query dictionary (and,
00102         therefore, tailored to work with the catalog).
00103         """
00104 
00105 
00106 # BBB: will be removed in CMF 2.2
00107 #      create zope2 interfaces
00108 from Interface.bridge import createZope3Bridge
00109 import Criterion
00110 
00111 createZope3Bridge(ICriterion, Criterion, 'Criterion')
00112 
00113 from Criterion import Criterion
00114 del createZope3Bridge