[CMF-checkins] SVN: CMF/trunk/CMF - split off IMinimalDublinCore
and IMutableMinimalDublinCore as used in PortalFolder
Yvo Schubbe
y.2006_ at wcm-solutions.de
Sun Feb 19 17:18:45 EST 2006
Log message for revision 41708:
- split off IMinimalDublinCore and IMutableMinimalDublinCore as used in PortalFolder
- added some other content interfaces needed for writing views
Changed:
U CMF/trunk/CMFCore/PortalFolder.py
U CMF/trunk/CMFCore/interfaces/_content.py
U CMF/trunk/CMFCore/tests/test_PortalFolder.py
U CMF/trunk/CMFDefault/Document.py
U CMF/trunk/CMFDefault/Favorite.py
U CMF/trunk/CMFDefault/Link.py
U CMF/trunk/CMFDefault/NewsItem.py
U CMF/trunk/CMFDefault/interfaces/_content.py
U CMF/trunk/CMFDefault/tests/test_Favorite.py
U CMF/trunk/CMFDefault/tests/test_Link.py
U CMF/trunk/CMFDefault/tests/test_NewsItem.py
-=-
Modified: CMF/trunk/CMFCore/PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/PortalFolder.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFCore/PortalFolder.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -34,6 +34,7 @@
from exceptions import BadRequest
from exceptions import zExceptions_Unauthorized
from interfaces import IFolderish
+from interfaces import IMutableMinimalDublinCore
from interfaces.Folderish import Folderish as z2IFolderish
from permissions import AddPortalContent
from permissions import AddPortalFolders
@@ -53,7 +54,7 @@
meta_type = 'Portal Folder Base'
- implements(IFolderish)
+ implements(IFolderish, IMutableMinimalDublinCore)
__implements__ = (z2IFolderish, DynamicType.__implements__,
Folder.__implements__)
@@ -69,16 +70,35 @@
self.title = title
#
- # 'MutableDublinCore' interface methods
+ # 'IMutableMinimalDublinCore' interface methods
#
+ security.declareProtected(View, 'Title')
+ def Title(self):
+ """ Dublin Core Title element - resource name.
+ """
+ return self.title
+
+ security.declareProtected(View, 'Description')
+ def Description(self):
+ """ Dublin Core Description element - resource summary.
+ """
+ return self.description
+
+ security.declareProtected(View, 'Type')
+ def Type(self):
+ """ Dublin Core Type element - resource type.
+ """
+ ti = self.getTypeInfo()
+ return ti is not None and ti.Title() or 'Unknown'
+
security.declareProtected(ManageProperties, 'setTitle')
- def setTitle( self, title ):
+ def setTitle(self, title):
""" Set Dublin Core Title element - resource name.
"""
self.title = title
security.declareProtected(ManageProperties, 'setDescription')
- def setDescription( self, description ):
+ def setDescription(self, description):
""" Set Dublin Core Description element - resource summary.
"""
self.description = description
@@ -153,7 +173,7 @@
return result
#
- # 'Folderish' interface methods
+ # 'IFolderish' interface methods
#
security.declarePublic('contentItems')
def contentItems(self, filter=None):
@@ -207,28 +227,6 @@
return self.listFolderContents()
#
- # 'DublinCore' interface methods
- #
- security.declareProtected(View, 'Title')
- def Title( self ):
- """ Dublin Core Title element - resource name.
- """
- return self.title
-
- security.declareProtected(View, 'Description')
- def Description( self ):
- """ Dublin Core Description element - resource summary.
- """
- return self.description
-
- security.declareProtected(View, 'Type')
- def Type( self ):
- """ Dublin Core Type element - resource type.
- """
- ti = self.getTypeInfo()
- return ti is not None and ti.Title() or 'Unknown'
-
- #
# other methods
#
security.declarePublic('encodeFolderFilter')
Modified: CMF/trunk/CMFCore/interfaces/_content.py
===================================================================
--- CMF/trunk/CMFCore/interfaces/_content.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFCore/interfaces/_content.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -189,9 +189,9 @@
#
# DublinCore interfaces
#
-class IDublinCore(Interface):
+class IMinimalDublinCore(Interface):
- """ Dublin Core metadata elements supported by CMF and their semantics.
+ """ Minimal set of Dublin Core metadata elements.
"""
def Title():
@@ -200,6 +200,29 @@
o Permission: View
"""
+ def Description():
+ """ Return the DCMI Description element (resource summary).
+
+ o Result is a natural language description of this object.
+
+ o Permission: View
+ """
+
+ def Type():
+ """ Return the DCMI Type element (resource type).
+
+ o Result a human-readable type name for the resource (typically
+ the Title of its type info object).
+
+ o Permission: View
+ """
+
+
+class IDublinCore(IMinimalDublinCore):
+
+ """ Dublin Core metadata elements supported by CMF and their semantics.
+ """
+
def listCreators():
""" Return a sequence of DCMI Creator elements (resource authors).
@@ -223,14 +246,6 @@
o Permission: View
"""
- def Description():
- """ Reuturn the DCMI Description element (resource summary).
-
- o Result is a natural language description of this object.
-
- o Permission: View
- """
-
def Publisher():
""" Return the DCMI Publisher element (resource publisher).
@@ -298,15 +313,6 @@
o Permission: View
"""
- def Type():
- """ Return the DCMI Type element (resource type).
-
- o Result a human-readable type name for the resource (typically
- the Title of its type info object).
-
- o Permission: View
- """
-
def Format():
""" Return the DCMI Format element (resource format).
@@ -373,9 +379,9 @@
"""
-class IMutableDublinCore(Interface):
+class IMutableMinimalDublinCore(IMinimalDublinCore):
- """ Update interface for mutable metadata.
+ """ Update interface for minimal set of mutable metadata.
"""
def setTitle(title):
@@ -384,6 +390,18 @@
o Permission: Modify portal content
"""
+ def setDescription(description):
+ """ Set DCMI Description element - resource summary.
+
+ o Permission: Modify portal content
+ """
+
+
+class IMutableDublinCore(IMutableMinimalDublinCore, IDublinCore):
+
+ """ Update interface for mutable metadata.
+ """
+
def setCreators(creators):
""" Set DCMI Creator elements - resource authors.
@@ -396,12 +414,6 @@
o Permission: Modify portal content
"""
- def setDescription(description):
- """ Set DCMI Description element - resource summary.
-
- o Permission: Modify portal content
- """
-
def setContributors(contributors):
""" Set DCMI Contributor elements - resource collaborators.
@@ -491,7 +503,7 @@
#
-# Folderish interface
+# Folderish interfaces
#
class IFolderish(Interface):
@@ -541,10 +553,13 @@
o Permission -- List folder contents
"""
+
class ISiteRoot(IFolderish):
+
""" Marker interface for the object which serves as the root of a site.
"""
+
#
# IOpaqueItems interfaces
#
Modified: CMF/trunk/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalFolder.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFCore/tests/test_PortalFolder.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -117,11 +117,15 @@
SecurityTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
- def _makeOne(self, id, *args, **kw):
+ def _getTargetClass(self):
from Products.CMFCore.PortalFolder import PortalFolder
- return self.site._setObject( id, PortalFolder(id, *args, **kw) )
+ return PortalFolder
+ def _makeOne(self, id, *args, **kw):
+ return self.site._setObject(id,
+ self._getTargetClass()(id, *args, **kw))
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.IOrderSupport import IOrderedContainer
@@ -130,21 +134,21 @@
import DynamicType as IDynamicType
from Products.CMFCore.interfaces.Folderish \
import Folderish as IFolderish
- from Products.CMFCore.PortalFolder import PortalFolder
- verifyClass(IDynamicType, PortalFolder)
- verifyClass(IFolderish, PortalFolder)
- verifyClass(IOrderedContainer, PortalFolder)
- verifyClass(WriteLockInterface, PortalFolder)
+ 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.CMFCore.PortalFolder import PortalFolder
+ from Products.CMFCore.interfaces import IMutableMinimalDublinCore
- verifyClass(IDynamicType, PortalFolder)
- verifyClass(IFolderish, PortalFolder)
+ verifyClass(IDynamicType, self._getTargetClass())
+ verifyClass(IFolderish, self._getTargetClass())
+ verifyClass(IMutableMinimalDublinCore, self._getTargetClass())
def test_contents_methods(self):
ttool = self.site._setObject( 'portal_types', TypesTool() )
Modified: CMF/trunk/CMFDefault/Document.py
===================================================================
--- CMF/trunk/CMFDefault/Document.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/Document.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -60,8 +60,8 @@
"""A Document - Handles both StructuredText and HTML.
"""
- implements(IDocument, IMutableDocument, IDAVAware)
- __implements__ = (z2IDocument, z2IMutableDocument,
+ implements(IMutableDocument, IDocument, IDAVAware)
+ __implements__ = (z2IMutableDocument, z2IDocument,
PortalContent.__implements__,
DefaultDublinCoreImpl.__implements__)
Modified: CMF/trunk/CMFDefault/Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/Favorite.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/Favorite.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -20,10 +20,13 @@
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
+from zope.interface import implements
from Products.CMFCore.utils import getToolByName
from DublinCore import DefaultDublinCoreImpl
+from interfaces import IFavorite
+from interfaces import IMutableFavorite
from Link import Link
from permissions import View
@@ -45,6 +48,7 @@
"""A Favorite (special kind of Link).
"""
+ implements(IMutableFavorite, IFavorite)
__implements__ = Link.__implements__ # redundant, but explicit
meta_type='Favorite'
@@ -145,10 +149,8 @@
security.declareProtected(View, 'getObject')
def getObject(self):
+ """ Get the actual object that the Favorite is linking to.
"""
- Return the actual object that the Favorite is
- linking to
- """
# try getting the remote object by unique id
remote_obj = self._getObjectByUid()
if remote_obj is not None:
Modified: CMF/trunk/CMFDefault/Link.py
===================================================================
--- CMF/trunk/CMFDefault/Link.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/Link.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -30,6 +30,8 @@
from DublinCore import DefaultDublinCoreImpl
from exceptions import ResourceLockedError
+from interfaces import ILink
+from interfaces import IMutableLink
from permissions import ModifyPortalContent
from permissions import View
from utils import _dtmldir
@@ -54,7 +56,7 @@
"""A Link.
"""
- implements(IDAVAware)
+ implements(IMutableLink, ILink, IDAVAware)
__implements__ = ( PortalContent.__implements__
, DefaultDublinCoreImpl.__implements__
)
Modified: CMF/trunk/CMFDefault/NewsItem.py
===================================================================
--- CMF/trunk/CMFDefault/NewsItem.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/NewsItem.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -17,8 +17,11 @@
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
+from zope.interface import implements
from Document import Document
+from interfaces import IMutableNewsItem
+from interfaces import INewsItem
from permissions import ModifyPortalContent
from permissions import View
@@ -46,6 +49,7 @@
"""A News Item.
"""
+ implements(IMutableNewsItem, INewsItem)
__implements__ = Document.__implements__ # redundant, but explicit
meta_type='News Item'
@@ -55,9 +59,8 @@
security.declareProtected(ModifyPortalContent, 'edit')
def edit( self, text, description=None, text_format=None ):
+ """Edit the News Item.
"""
- Edit the News Item
- """
if text_format is None:
text_format = getattr(self, 'text_format', 'structured-text')
if description is not None:
Modified: CMF/trunk/CMFDefault/interfaces/_content.py
===================================================================
--- CMF/trunk/CMFDefault/interfaces/_content.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/interfaces/_content.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -20,10 +20,12 @@
class IDocument(Interface):
+
""" Textual content, in one of several formats.
o Allowed formats include: structured text, HTML, plain text.
"""
+
def CookedBody():
""" Get the "cooked" (ready for presentation) form of the text.
"""
@@ -34,8 +36,10 @@
class IMutableDocument(IDocument):
+
""" Updatable form of IDocument.
"""
+
def edit(text_format, text, file='', safety_belt=''):
""" Update the document.
@@ -44,9 +48,27 @@
"""
+class INewsItem(IDocument):
+
+ """A special document for news.
+ """
+
+ def edit(text, description=None, text_format=None):
+ """Edit the News Item.
+ """
+
+
+class IMutableNewsItem(INewsItem):
+
+ """Updatable form of INewsItem.
+ """
+
+
class ILink(Interface):
+
""" URL as content.
"""
+
def getRemoteUrl():
""" Return the URL to which the link points, as a string.
"""
@@ -56,6 +78,7 @@
""" Updatable form of ILink.
"""
+
def edit(remote_url):
""" Update the link.
@@ -63,3 +86,19 @@
o If 'remote_url' is unparseable by urllib, raise ValueError.
"""
+
+
+class IFavorite(ILink):
+
+ """ Link to an internal object.
+ """
+
+ def getObject():
+ """ Get the actual object that the Favorite is linking to.
+ """
+
+
+class IMutableFavorite(IFavorite, IMutableLink):
+
+ """ Updatable form of IFavorite.
+ """
Modified: CMF/trunk/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Favorite.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/tests/test_Favorite.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -39,6 +39,18 @@
self.site._setObject( 'portal_membership', DummyTool() )
self.site._setObject( 'portal_url', DummyTool() )
+ def test_z3interfaces(self):
+ from zope.interface.verify import verifyClass
+ from Products.CMFDefault.interfaces import IFavorite
+ from Products.CMFDefault.interfaces import ILink
+ from Products.CMFDefault.interfaces import IMutableFavorite
+ from Products.CMFDefault.interfaces import IMutableLink
+
+ verifyClass(IFavorite, self._getTargetClass())
+ verifyClass(ILink, self._getTargetClass())
+ verifyClass(IMutableFavorite, self._getTargetClass())
+ verifyClass(IMutableLink, self._getTargetClass())
+
def test_Empty( self ):
utool = self.site.portal_url
f = self.site._setObject('foo', self._makeOne('foo'))
Modified: CMF/trunk/CMFDefault/tests/test_Link.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Link.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/tests/test_Link.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -46,6 +46,14 @@
d.edit(orig)
self.assertEqual(d.getRemoteUrl(), wanted)
+ def test_z3interfaces(self):
+ from zope.interface.verify import verifyClass
+ from Products.CMFDefault.interfaces import ILink
+ from Products.CMFDefault.interfaces import IMutableLink
+
+ verifyClass(ILink, self._getTargetClass())
+ verifyClass(IMutableLink, self._getTargetClass())
+
def test_Empty( self ):
d = self._makeOne('foo')
self.assertEqual( d.Title(), '' )
Modified: CMF/trunk/CMFDefault/tests/test_NewsItem.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_NewsItem.py 2006-02-19 18:53:08 UTC (rev 41707)
+++ CMF/trunk/CMFDefault/tests/test_NewsItem.py 2006-02-19 22:18:44 UTC (rev 41708)
@@ -37,6 +37,19 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def test_z3interfaces(self):
+ from zope.interface.verify import verifyClass
+ from Products.CMFDefault.interfaces import IDocument
+ from Products.CMFDefault.interfaces import IMutableDocument
+ from Products.CMFDefault.interfaces import IMutableNewsItem
+ from Products.CMFDefault.interfaces import INewsItem
+
+ verifyClass(IDocument, self._getTargetClass())
+ # XXX: different signature
+ # verifyClass(IMutableDocument, self._getTargetClass())
+ verifyClass(IMutableNewsItem, self._getTargetClass())
+ verifyClass(INewsItem, self._getTargetClass())
+
def test_Empty_html(self):
d = self._makeOne('empty', text_format='html')
More information about the CMF-checkins
mailing list