[CMF-checkins] SVN: CMF/trunk/CMFTopic/ - moved ITopic to the
standard location, added IMutableTopic
Yvo Schubbe
y.2006_ at wcm-solutions.de
Wed May 3 10:36:12 EDT 2006
Log message for revision 67932:
- moved ITopic to the standard location, added IMutableTopic
- minor profile changes
- related cleanup
Changed:
U CMF/trunk/CMFTopic/Topic.py
UU CMF/trunk/CMFTopic/configure.zcml
U CMF/trunk/CMFTopic/interfaces/__init__.py
UU CMF/trunk/CMFTopic/profiles/default/types/Topic.xml
U CMF/trunk/CMFTopic/tests/test_Topic.py
-=-
Modified: CMF/trunk/CMFTopic/Topic.py
===================================================================
--- CMF/trunk/CMFTopic/Topic.py 2006-05-03 14:28:52 UTC (rev 67931)
+++ CMF/trunk/CMFTopic/Topic.py 2006-05-03 14:36:10 UTC (rev 67932)
@@ -18,23 +18,19 @@
from AccessControl import ClassSecurityInfo
from Acquisition import aq_parent, aq_inner
from Globals import InitializeClass
+from zope.interface import implements
from Products.CMFDefault.SkinnedFolder import SkinnedFolder
from Products.CMFCore.utils import getToolByName
-from zope.interface import Interface
-from zope.interface import implements
-from zope.interface import implementedBy
+from interfaces import IMutableTopic
+from interfaces import ITopic
from permissions import View
from permissions import AddTopics
from permissions import ChangeTopics
-class ITopic(Interface):
- """ Marker interface.
- """
-
-def addTopic( self, id, title='', REQUEST=None ):
+def addTopic(self, id, title='', REQUEST=None):
""" Create an empty topic.
"""
topic = Topic( id )
@@ -48,12 +44,14 @@
class Topic(SkinnedFolder):
- """ Topics are 'canned queries'
-
+ """ Topics are 'canned queries'.
+
o Each topic holds a set of zero or more Criteria objects specifying
the query.
"""
- implements(ITopic, implementedBy(SkinnedFolder))
+
+ implements(IMutableTopic, ITopic)
+
meta_type='Portal Topic'
security = ClassSecurityInfo()
@@ -63,16 +61,13 @@
_criteriaTypes = []
security.declareProtected(ChangeTopics, 'listCriteria')
- def listCriteria( self ):
-
+ def listCriteria(self):
""" Return a list of our criteria objects.
"""
return self.objectValues( self._criteria_metatype_ids() )
-
security.declareProtected(ChangeTopics, 'listCriteriaTypes')
- def listCriteriaTypes( self ):
-
+ def listCriteriaTypes(self):
""" List the available criteria types.
"""
out = []
@@ -83,8 +78,7 @@
return out
security.declareProtected(ChangeTopics, 'listAvailableFields')
- def listAvailableFields( self ):
-
+ def listAvailableFields(self):
""" Return a list of available fields for new criteria.
"""
portal_catalog = getToolByName( self, 'portal_catalog' )
@@ -96,19 +90,17 @@
return availfields
security.declareProtected(ChangeTopics, 'listSubtopics')
- def listSubtopics( self ):
-
+ def listSubtopics(self):
""" Return a list of our subtopics.
"""
return self.objectValues( self.meta_type )
security.declareProtected(ChangeTopics, 'edit')
- def edit( self, acquireCriteria, title=None, description=None ):
-
+ def edit(self, acquireCriteria, title=None, description=None):
""" Set the flag which indicates whether to acquire criteria.
o If set, reuse creiteria from parent topics;
-
+
o Also update metadata about the Topic.
"""
self.acquireCriteria = bool(acquireCriteria)
@@ -119,8 +111,7 @@
self.reindexObject()
security.declareProtected(View, 'buildQuery')
- def buildQuery( self ):
-
+ def buildQuery(self):
""" Construct a catalog query using our criterion objects.
"""
result = {}
@@ -144,10 +135,9 @@
return result
security.declareProtected(View, 'queryCatalog')
- def queryCatalog( self, REQUEST=None, **kw ):
-
+ def queryCatalog(self, REQUEST=None, **kw):
""" Invoke the catalog using our criteria.
-
+
o Built-in criteria update any criteria passed in 'kw'.
"""
kw.update( self.buildQuery() )
@@ -155,22 +145,20 @@
return portal_catalog.searchResults(REQUEST, **kw)
security.declareProtected(View, 'synContentValues')
- def synContentValues( self ):
-
+ def synContentValues(self):
""" Return a limited subset of the brains for our query.
-
+
o Return no more brain objects than the limit set by the
syndication tool.
"""
syn_tool = getToolByName( self, 'portal_syndication' )
limit = syn_tool.getMaxItems( self )
brains = self.queryCatalog( sort_limit=limit )[ :limit ]
- return [ brain.getObject() for brain in brains ]
+ return [ brain.getObject() for brain in brains ]
### Criteria adding/editing/deleting
security.declareProtected(ChangeTopics, 'addCriterion')
- def addCriterion( self, field, criterion_type ):
-
+ def addCriterion(self, field, criterion_type):
""" Add a new search criterion.
"""
crit = None
@@ -188,8 +176,7 @@
self._setObject( newid, crit )
security.declareProtected(ChangeTopics, 'deleteCriterion')
- def deleteCriterion( self, criterion_id ):
-
+ def deleteCriterion(self, criterion_id):
""" Delete selected criterion.
"""
if type( criterion_id ) is type( '' ):
@@ -199,8 +186,7 @@
self._delObject( cid )
security.declareProtected(View, 'getCriterion')
- def getCriterion( self, criterion_id ):
-
+ def getCriterion(self, criterion_id):
""" Get the criterion object.
"""
try:
@@ -209,8 +195,7 @@
return self._getOb( criterion_id )
security.declareProtected(AddTopics, 'addSubtopic')
- def addSubtopic( self, id ):
-
+ def addSubtopic(self, id):
""" Add a new subtopic.
"""
ti = self.getTypeInfo()
@@ -220,8 +205,8 @@
#
# Helper methods
#
- security.declarePrivate( '_criteria_metatype_ids' )
- def _criteria_metatype_ids( self ):
+ security.declarePrivate('_criteria_metatype_ids')
+ def _criteria_metatype_ids(self):
result = []
@@ -239,6 +224,6 @@
SeachableText is used for full text seraches of a portal. It
should return a concatenation of all useful text.
"""
- return "%s %s" % (self.title, self.description)
+ return "%s %s" % (self.title, self.description)
InitializeClass(Topic)
Modified: CMF/trunk/CMFTopic/configure.zcml
===================================================================
--- CMF/trunk/CMFTopic/configure.zcml 2006-05-03 14:28:52 UTC (rev 67931)
+++ CMF/trunk/CMFTopic/configure.zcml 2006-05-03 14:36:10 UTC (rev 67932)
@@ -5,21 +5,20 @@
<adapter
factory=".exportimport.TopicExportImport"
provides="Products.GenericSetup.interfaces.IFilesystemExporter"
- for="Products.CMFTopic.Topic.ITopic"
+ for="Products.CMFTopic.interfaces.ITopic"
/>
<adapter
factory=".exportimport.TopicExportImport"
provides="Products.GenericSetup.interfaces.IFilesystemImporter"
- for="Products.CMFTopic.Topic.ITopic"
+ for="Products.CMFTopic.interfaces.ITopic"
/>
<adapter
factory=".exportimport.SubtopicFactory"
provides="Products.GenericSetup.interfaces.IContentFactory"
- for="Products.CMFTopic.Topic.ITopic"
+ for="Products.CMFTopic.interfaces.ITopic"
name="Topic"
/>
</configure>
-
Property changes on: CMF/trunk/CMFTopic/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFTopic/interfaces/__init__.py
===================================================================
--- CMF/trunk/CMFTopic/interfaces/__init__.py 2006-05-03 14:28:52 UTC (rev 67931)
+++ CMF/trunk/CMFTopic/interfaces/__init__.py 2006-05-03 14:36:10 UTC (rev 67932)
@@ -18,6 +18,27 @@
from zope.interface import Interface
+class ITopic(Interface):
+
+ """ Topics are 'canned queries'.
+
+ o Each topic holds a set of zero or more Criteria objects specifying
+ the query.
+ """
+
+ def queryCatalog(REQUEST=None, **kw):
+ """ Invoke the catalog using our criteria.
+
+ o Built-in criteria update any criteria passed in 'kw'.
+ """
+
+
+class IMutableTopic(ITopic):
+
+ """ Updatable form of ITopic.
+ """
+
+
class ICriterion(Interface):
"""\
A Topic is composed of Criterion objects which specify the query
Modified: CMF/trunk/CMFTopic/profiles/default/types/Topic.xml
===================================================================
--- CMF/trunk/CMFTopic/profiles/default/types/Topic.xml 2006-05-03 14:28:52 UTC (rev 67931)
+++ CMF/trunk/CMFTopic/profiles/default/types/Topic.xml 2006-05-03 14:36:10 UTC (rev 67932)
@@ -16,9 +16,10 @@
</property>
<property name="allow_discussion">False</property>
<alias from="(Default)" to="topic_view"/>
+ <alias from="index.html" to="topic_view"/>
<alias from="view" to="topic_view"/>
<action title="View" action_id="view" category="object" condition_expr=""
- url_expr="string:${object_url}/topic_view" visible="True">
+ url_expr="string:${object_url}" visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
Property changes on: CMF/trunk/CMFTopic/profiles/default/types/Topic.xml
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
Modified: CMF/trunk/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_Topic.py 2006-05-03 14:28:52 UTC (rev 67931)
+++ CMF/trunk/CMFTopic/tests/test_Topic.py 2006-05-03 14:36:10 UTC (rev 67932)
@@ -15,10 +15,8 @@
$Id$
"""
-from unittest import TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from Acquisition import Implicit
@@ -121,6 +119,7 @@
class TestTopic(SecurityTest):
+
""" Test all the general Topic cases.
"""
@@ -128,18 +127,20 @@
SecurityTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
- def _makeOne(self, id, *args, **kw):
+ def _getTargetClass(self):
from Products.CMFTopic.Topic import Topic
- return self.site._setObject( id, Topic(id, *args, **kw) )
+ return Topic
- def _initSite( self, max_items=15, index_ids=() ):
+ def _makeOne(self, id, *args, **kw):
+ return self.site._setObject(id,
+ self._getTargetClass()(id, *args, **kw))
+ def _initSite(self, max_items=15, index_ids=()):
self.site.portal_catalog = DummyCatalog( index_ids )
self.site.portal_syndication = DummySyndicationTool( max_items )
- def _initDocuments( self, **kw ):
-
+ def _initDocuments(self, **kw):
for k, v in kw.items():
document = DummyDocument( k )
@@ -156,21 +157,25 @@
import DynamicType as IDynamicType
from Products.CMFCore.interfaces.Folderish \
import Folderish as IFolderish
- from Products.CMFTopic.Topic import Topic
- verifyClass(IDynamicType, Topic)
- verifyClass(IFolderish, Topic)
- verifyClass(IOrderedContainer, Topic)
- verifyClass(WriteLockInterface, Topic)
+ verifyClass(IDynamicType, self._getTargetClass())
+ verifyClass(IFolderish, self._getTargetClass())
+ verifyClass(IOrderedContainer, self._getTargetClass())
+ verifyClass(WriteLockInterface, self._getTargetClass())
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFCore.interfaces import IDynamicType
from Products.CMFCore.interfaces import IFolderish
- from Products.CMFTopic.Topic import Topic
+ from Products.CMFCore.interfaces import IMutableMinimalDublinCore
+ from Products.CMFTopic.interfaces import IMutableTopic
+ from Products.CMFTopic.interfaces import ITopic
- verifyClass(IDynamicType, Topic)
- verifyClass(IFolderish, Topic)
+ verifyClass(IDynamicType, self._getTargetClass())
+ verifyClass(IFolderish, self._getTargetClass())
+ verifyClass(IMutableMinimalDublinCore, self._getTargetClass())
+ verifyClass(IMutableTopic, self._getTargetClass())
+ verifyClass(ITopic, self._getTargetClass())
def test_Empty( self ):
topic = self._makeOne('top')
@@ -337,9 +342,9 @@
def test_suite():
- return TestSuite((
- makeSuite(TestTopic),
+ return unittest.TestSuite((
+ unittest.makeSuite(TestTopic),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
More information about the CMF-checkins
mailing list