[CMF-checkins] CVS: CMF/CMFDefault - MetadataTool.py:1.14
Tres Seaver
tseaver@zope.com
Mon, 17 Jun 2002 13:29:21 -0400
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv5143/CMFDefault
Modified Files:
MetadataTool.py
Log Message:
- Extended the metadata tool to permit passing the type name
directly (e.g., when building a new object, one might need to
know the allowed subjects before construction).
=== CMF/CMFDefault/MetadataTool.py 1.13 => 1.14 ===
from Globals import InitializeClass, DTMLFile
-from Persistence import Persistent
from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.CMFCore import CMFCorePermissions
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from utils import _dtmldir
-class MetadataElementPolicy( Persistent ):
+class MetadataElementPolicy( SimpleItem ):
"""
Represent a type-specific policy about a particular DCMI element.
"""
@@ -116,7 +115,7 @@
, ( 'Rights', 0 )
)
-class ElementSpec( Persistent ):
+class ElementSpec( SimpleItem ):
"""
Represent all the tool knows about a single metadata element.
"""
@@ -397,7 +396,7 @@
Return an ElementSpec representing the tool's knowledge
of 'element'.
"""
- return self.element_specs[ element ]
+ return self.element_specs[ element ].__of__( self )
security.declareProtected( CMFCorePermissions.ManagePortal
, 'addElementSpec' )
@@ -465,46 +464,47 @@
return self.publisher
security.declarePublic( 'listAllowedVocabulary' )
- def listAllowedVocabulary( self, element, content=None ):
+ def listAllowedVocabulary( self, element, content=None, content_type=None ):
"""
List allowed keywords for a given meta_type, or all
possible keywords if none supplied.
"""
spec = self.getElementSpec( element )
- typ = content and content.Type() or None
- return spec.getPolicy( typ ).allowedVocabulary()
+ if content_type is None:
+ content_type = content and content.Type() or None
+ return spec.getPolicy( content_type ).allowedVocabulary()
security.declarePublic( 'listAllowedSubjects' )
- def listAllowedSubjects( self, content=None ):
+ def listAllowedSubjects( self, content=None, content_type=None ):
"""
List allowed keywords for a given meta_type, or all
possible keywords if none supplied.
"""
- return self.listAllowedVocabulary( 'Subject', content )
+ return self.listAllowedVocabulary( 'Subject', content, content_type )
security.declarePublic( 'listAllowedFormats' )
- def listAllowedFormats( self, content=None ):
+ def listAllowedFormats( self, content=None, content_type=None ):
"""
List the allowed 'Content-type' values for a particular
meta_type, or all possible formats if none supplied.
"""
- return self.listAllowedVocabulary( 'Format', content )
+ return self.listAllowedVocabulary( 'Format', content, content_type )
security.declarePublic( 'listAllowedLanguages' )
- def listAllowedLanguages( self, content=None ):
+ def listAllowedLanguages( self, content=None, content_type=None ):
"""
List the allowed language values.
"""
- return self.listAllowedVocabulary( 'Language', content )
+ return self.listAllowedVocabulary( 'Language', content, content_type )
security.declarePublic( 'listAllowedRights' )
- def listAllowedRights( self, content=None ):
+ def listAllowedRights( self, content=None, content_type=None ):
"""
List the allowed values for a "Rights"
selection list; this gets especially important where
syndication is involved.
"""
- return self.listAllowedVocabulary( 'Rights', content )
+ return self.listAllowedVocabulary( 'Rights', content, content_type )
security.declareProtected( CMFCorePermissions.ModifyPortalContent
, 'setInitialMetadata' )