Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions | Static Private Attributes
CMFDefault.MetadataTool.MetadataTool Class Reference
Inheritance diagram for CMFDefault.MetadataTool.MetadataTool:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.MetadataTool.MetadataTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def editProperties
def manage_addSchema
def manage_removeSchemas
def getFullName
def getPublisher
def listAllowedSubjects
def listAllowedFormats
def listAllowedLanguages
def listAllowedRights
def listAllowedVocabulary
def listSchemas
def addSchema
def removeSchema
def setInitialMetadata
def validateMetadata

Public Attributes

 publisher

Static Public Attributes

string id = 'portal_metadata'
string meta_type = 'Default Metadata Tool'
string publisher = ''
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_overview = DTMLFile( 'explainMetadataTool', _dtmldir )
tuple propertiesForm = DTMLFile( 'metadataProperties', _dtmldir )

Properties

 DCMI = property(_get_DCMI, None)

Private Member Functions

def _get_DCMI

Static Private Attributes

tuple __implements__ = (z2IMetadataTool, )
 _DCMI = None

Detailed Description

Definition at line 374 of file MetadataTool.py.


Constructor & Destructor Documentation

def CMFDefault.MetadataTool.MetadataTool.__init__ (   self,
  publisher = None 
)

Definition at line 415 of file MetadataTool.py.

00415 
00416     def __init__( self, publisher=None ):
00417 
00418         self.editProperties( publisher )

Here is the call graph for this function:


Member Function Documentation

Definition at line 383 of file MetadataTool.py.

00383 
00384     def _get_DCMI( self ):
00385 
00386         if self._DCMI is None:
00387             dcmi = self._DCMI = MetadataSchema( 'DCMI', _DCMI_ELEMENT_SPECS )
00388 
00389             old_specs = getattr( self, 'element_specs', None )
00390             if old_specs is not None:
00391                 del self.element_specs
00392                 for element_id, old_spec in old_specs.items():
00393                     new_spec = dcmi.getElementSpec( element_id )
00394                     for typ, policy in old_spec.listPolicies():
00395                         if typ is not None:
00396                             new_spec.addPolicy( typ )
00397                         tp = new_spec.getPolicy( typ )
00398                         tp.edit( is_required=policy.isRequired()
00399                                , supply_default=policy.supplyDefault()
00400                                , default_value=policy.defaultValue()
00401                                , enforce_vocabulary=policy.enforceVocabulary()
00402                                , allowed_vocabulary=policy.allowedVocabulary()
00403                                )
00404 
00405         return self._DCMI

def CMFDefault.MetadataTool.MetadataTool.addSchema (   self,
  schema_id,
  elements = () 
)
See IMetadataTool.

Definition at line 563 of file MetadataTool.py.

00563 
00564     def addSchema( self, schema_id, elements=() ):
00565         """ See IMetadataTool.
00566         """
00567         if schema_id == 'DCMI' or schema_id in self.objectIds():
00568             raise KeyError, 'Duplicate schema ID: %s' % schema_id
00569 
00570         schema = MetadataSchema( schema_id, elements )
00571         self._setObject( schema_id, schema )
00572 
00573         return self._getOb( schema_id )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.MetadataTool.MetadataTool.editProperties (   self,
  publisher = None,
  REQUEST = None 
)
Form handler for "tool-wide" properties 

Definition at line 442 of file MetadataTool.py.

00442 
00443                       ):
00444         """ Form handler for "tool-wide" properties 
00445         """
00446         if publisher is not None:
00447             self.publisher = publisher
00448 
00449         if REQUEST is not None:
00450             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00451                                         + '/propertiesForm'
00452                                         + '?manage_tabs_message=Tool+updated.'
00453                                         )

Here is the caller graph for this function:

See IMetadataTool.

Definition at line 488 of file MetadataTool.py.

00488 
00489     def getFullName( self, userid ):
00490         """ See IMetadataTool.
00491         """
00492         return userid   # TODO: do lookup here

See IMetadataTool.

Definition at line 494 of file MetadataTool.py.

00494 
00495     def getPublisher( self ):
00496         """ See IMetadataTool.
00497         """
00498         return self.publisher

def CMFDefault.MetadataTool.MetadataTool.listAllowedFormats (   self,
  content = None,
  content_type = None 
)
See IMetadataTool.

Definition at line 510 of file MetadataTool.py.

00510 
00511     def listAllowedFormats( self, content=None, content_type=None ):
00512         """ See IMetadataTool.
00513         """
00514         return self.listAllowedVocabulary( 'DCMI'
00515                                          , 'Format'
00516                                          , content
00517                                          , content_type
00518                                          )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.listAllowedLanguages (   self,
  content = None,
  content_type = None 
)
See IMetadataTool.

Definition at line 520 of file MetadataTool.py.

00520 
00521     def listAllowedLanguages( self, content=None, content_type=None ):
00522         """ See IMetadataTool.
00523         """
00524         return self.listAllowedVocabulary( 'DCMI'
00525                                          , 'Language'
00526                                          , content
00527                                          , content_type
00528                                          )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.listAllowedRights (   self,
  content = None,
  content_type = None 
)
See IMetadata Tool.

Definition at line 530 of file MetadataTool.py.

00530 
00531     def listAllowedRights( self, content=None, content_type=None ):
00532         """ See IMetadata Tool.
00533         """
00534         return self.listAllowedVocabulary( 'DCMI'
00535                                          , 'Rights'
00536                                          , content
00537                                          , content_type
00538                                          )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.listAllowedSubjects (   self,
  content = None,
  content_type = None 
)
See IMetadataTool.

Definition at line 500 of file MetadataTool.py.

00500 
00501     def listAllowedSubjects( self, content=None, content_type=None ):
00502         """ See IMetadataTool.
00503         """
00504         return self.listAllowedVocabulary( 'DCMI'
00505                                          , 'Subject'
00506                                          , content
00507                                          , content_type
00508                                          )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.listAllowedVocabulary (   self,
  schema,
  element,
  content = None,
  content_type = None 
)
See IMetadataTool.

Definition at line 545 of file MetadataTool.py.

00545 
00546                              ):
00547         """ See IMetadataTool.
00548         """
00549         schema_def = getattr( self, schema )
00550         spec = schema_def.getElementSpec( element )
00551         if content_type is None and content:
00552             content_type = content.getPortalTypeName()
00553         return spec.getPolicy( content_type ).allowedVocabulary()

Here is the caller graph for this function:

See IMetadataTool.

Definition at line 555 of file MetadataTool.py.

00555 
00556     def listSchemas( self ):
00557         """ See IMetadataTool.
00558         """
00559         result = [ ( 'DCMI', self.DCMI ) ]
00560         result.extend( self.objectItems( [ MetadataSchema.meta_type ] ) )
00561         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.MetadataTool.MetadataTool.manage_addSchema (   self,
  schema_id,
  elements,
  REQUEST 
)
ZMI wrapper around addSchema

Definition at line 455 of file MetadataTool.py.

00455 
00456     def manage_addSchema( self, schema_id, elements, REQUEST ):
00457         """ ZMI wrapper around addSchema
00458         """
00459         massaged = []
00460         for element in elements:
00461             if isinstance(element, basestring):
00462                 element = element.split(',')
00463                 if len( element ) < 2:
00464                     element.append(0)
00465             massaged.append( element )
00466         self.addSchema( schema_id, massaged )
00467 
00468         REQUEST['RESPONSE'].redirect( self.absolute_url()
00469                                     + '/propertiesForm'
00470                                     + '?manage_tabs_message=Schema+added.'
00471                                     )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.manage_removeSchemas (   self,
  schema_ids,
  REQUEST 
)
ZMI wrapper around removeSchema

Definition at line 473 of file MetadataTool.py.

00473 
00474     def manage_removeSchemas( self, schema_ids, REQUEST ):
00475         """ ZMI wrapper around removeSchema
00476         """
00477         if not schema_ids:
00478             raise ValueError, 'No schemas selected!'
00479 
00480         for schema_id in schema_ids:
00481             self.removeSchema( schema_id )
00482 
00483         REQUEST['RESPONSE'].redirect( self.absolute_url()
00484                                     + '/propertiesForm'
00485                                     + '?manage_tabs_message=Schemas+removed.'
00486                                     )

Here is the call graph for this function:

def CMFDefault.MetadataTool.MetadataTool.removeSchema (   self,
  schema_id 
)
See IMetadataTool.

Definition at line 575 of file MetadataTool.py.

00575 
00576     def removeSchema( self, schema_id ):
00577         """ See IMetadataTool.
00578         """
00579         if schema_id == 'DCMI' or schema_id not in self.objectIds():
00580             raise KeyError, 'Invalid schema ID: %s' % schema_id
00581 
00582         self._delObject( schema_id )

Here is the call graph for this function:

Here is the caller graph for this function:

See IMetadataTool.

Definition at line 584 of file MetadataTool.py.

00584 
00585     def setInitialMetadata( self, content ):
00586         """ See IMetadataTool.
00587         """
00588         for schema_id, schema in self.listSchemas():
00589             for element, policy in schema.listPolicies(
00590                                     content.getPortalTypeName()):
00591 
00592                 if not getattr( content, element )():
00593 
00594                     if policy.supplyDefault():
00595                         setter = getattr( content, 'set%s' % element )
00596                         setter( policy.defaultValue() )
00597                     elif policy.isRequired():
00598                         raise MetadataError, \
00599                             'Metadata element %s is required.' % element
00600 
00601         # TODO:  Call initial_values_hook, if present

Here is the call graph for this function:

See IMetadataTool.

Definition at line 603 of file MetadataTool.py.

00603 
00604     def validateMetadata( self, content ):
00605         """ See IMetadataTool.
00606         """
00607         for schema_id, schema in self.listSchemas():
00608             for element, policy in schema.listPolicies(
00609                                     content.getPortalTypeName()):
00610 
00611                 value = getattr( content, element )()
00612                 if not value and policy.isRequired():
00613                     raise MetadataError, \
00614                             'Metadata element %s is required.' % element
00615 
00616                 if value and policy.enforceVocabulary():
00617                     values = policy.isMultiValued() and value or [ value ]
00618                     for value in values:
00619                         if not value in policy.allowedVocabulary():
00620                             raise MetadataError, \
00621                             'Value %s is not in allowed vocabulary for ' \
00622                             'metadata element %s.' % ( value, element )
00623 
00624 InitializeClass( MetadataTool )
00625 registerToolInterface('portal_metadata', IMetadataTool)

Here is the call graph for this function:


Member Data Documentation

tuple CMFDefault.MetadataTool.MetadataTool.__implements__ = (z2IMetadataTool, ) [static, private]

Definition at line 377 of file MetadataTool.py.

Definition at line 382 of file MetadataTool.py.

string CMFDefault.MetadataTool.MetadataTool.id = 'portal_metadata' [static]

Definition at line 379 of file MetadataTool.py.

Initial value:
( ( { 'label'      : 'Schema'
                         , 'action'     : 'propertiesForm'
                         }
                       , { 'label'      : 'Overview'
                         , 'action'     : 'manage_overview'
                         }
                       )
                     + Folder.manage_options
                     )

Definition at line 422 of file MetadataTool.py.

tuple CMFDefault.MetadataTool.MetadataTool.manage_overview = DTMLFile( 'explainMetadataTool', _dtmldir ) [static]

Definition at line 433 of file MetadataTool.py.

string CMFDefault.MetadataTool.MetadataTool.meta_type = 'Default Metadata Tool' [static]

Definition at line 380 of file MetadataTool.py.

tuple CMFDefault.MetadataTool.MetadataTool.propertiesForm = DTMLFile( 'metadataProperties', _dtmldir ) [static]

Definition at line 436 of file MetadataTool.py.

Definition at line 411 of file MetadataTool.py.

Definition at line 446 of file MetadataTool.py.

tuple CMFDefault.MetadataTool.MetadataTool.security = ClassSecurityInfo() [static]

Definition at line 413 of file MetadataTool.py.


Property Documentation

Definition at line 406 of file MetadataTool.py.


The documentation for this class was generated from the following file: