[Zope-CMF] something wrong with portal_metadata tool

Tres Seaver tseaver@digicool.com
Mon, 21 May 2001 00:43:15 -0400


marc lindahl wrote:
> 
> I think I fixed it.... of course it could use some more testing.  In
> MetadataTool.py, change the following function:
> 
>     def updateElementPolicy( self
>                            , element
>                            , content_type
>                            , is_required
>                            , supply_default
>                            , default_value
>                            , enforce_vocabulary
>                            , allowed_vocabulary
>                            , REQUEST=None
>                            ):
>         """
>             Update a policy for one of our elements ('content_type'
>             will be '<default>' when we edit the default).
>         """
>         if content_type == '<default>':
>             content_type = None
>         spec = self.getElementSpec( element )
>         policy = spec.getPolicy( content_type )
>         policy.edit( is_required
>                    , supply_default
>                    , default_value
>                    , enforce_vocabulary
>                    , allowed_vocabulary
>                    )
>         spec.policies._p_changed=1  # added 2001/05/20 MSL tracker#274
>         if REQUEST is not None:
>             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
>                + '/elementPoliciesForm'
>                + '?element=' + element
>                + '&manage_tabs_message=Policy+updated.'
>                )


Aaargh!  I thought (foolishly) that I had fixed that by making
the 'policies' a PersistentMapping.  The issue is actually not
with the 'policies', but with the policy objects themselves, which
are not "persistence aware".  The proper fix is to make them (and
the ElementSpec class, for good measure) derive from Persistent;
here's the diff

diff -u -r1.4 MetadataTool.py
--- MetadataTool.py	2001/05/11 03:41:43	1.4
+++ MetadataTool.py	2001/05/21 05:02:53
@@ -93,11 +93,12 @@
 
 
 from Globals import InitializeClass, DTMLFile
+from Persistence import Persistent
 from AccessControl import ClassSecurityInfo, getSecurityManager
 from Products.CMFCore import CMFCorePermissions
 from utils import _dtmldir
 
-class MetadataElementPolicy:
+class MetadataElementPolicy( Persistent ):
     """
         Represent a type-specific policy about a particular DCMI element.
     """
@@ -175,7 +176,7 @@
                         , ( 'Rights', 0 )
                         )
 
-class ElementSpec:
+class ElementSpec( Persistent ):
     """
         Represent all the tool knows about a single metadata element.
     """

Thanks for doing the detective work on this!

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org